create symbolic link in bitbake recipe

前端 未结 6 1688
挽巷
挽巷 2021-01-14 02:03

I have a .bbappend recipe that I need to create a symbolic link in my system.

This is how it looks like now:

bernardo@bernardo-ThinkCentre-Edge72:~/y         


        
相关标签:
6条回答
  • 2021-01-14 02:37

    You can do:

    ln -s ../lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
    

    or if you don't require the symbolic-link until after your target system has booted up (i.e. it's not a dependency of other packages you are building) you can also do:

    ln -s /lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2
    

    ln doesn't care if your target is valid or exists when a symbolic-link is created. It will become valid after you boot your target-system (or somehow mount this filesystem to /). But indeed, relative links are recommended.

    0 讨论(0)
  • 2021-01-14 02:42

    The cleanest solution is to use the "-r" flag:

    do_install_append() {
        install -d ${D}/lib64
        ln -s -r ${D}/lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2 
    }
    

    From the gnu ln man page:

           -r, --relative            create symbolic links relative to link location
    
    0 讨论(0)
  • 2021-01-14 02:42
    do_install_append () {
    install -d 0755 ${D}/dir
    install -d 0755 ${D}/dir/subdir
    cd ${D}/dir/subdir
    ln -sf /source_so_the_symbilic_link <name_of_the_symbolic_link>
    

    } FILES_${PN} += "/dir"

    0 讨论(0)
  • 2021-01-14 02:43

    Since Yocto 2.3, lnr is recommended.

    e.g.

    do_install_append() {
        install -d ${D}/lib64
        lnr ${D}/lib/ld-2.26.so ${D}/lib64/ld-linux-x86-64.so.2 
    }
    

    Alternatively, you can also inherit relative_symlinks which will turn any absolute symlinks into relative ones, but this is less commonly used than lnr.

    Cf. https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#migration-2.3-absolute-symlinks

    0 讨论(0)
  • 2021-01-14 02:48

    Try to avoid usage of absolute paths:

    do_install_append() {
        install -d ${D}/lib64
        cd ${D}/lib64
        ln -s ../lib/ld-2.26.so ld-linux-x86-64.so.2 
    }
    
    0 讨论(0)
  • 2021-01-14 02:56

    I had a look at how other recipes create links in the rootfs, and most seem to do it this way:

    ln -sf /data/etc/bluetooth/main.conf ${D}/${sysconfdir}/bluetooth/main.conf
    

    This command in the recipe will create the following link on the device:

    /# ls -al /etc/bluetooth/main.conf
    lrwxrwxrwx 1 root root 29 Sep 11 15:34 /etc/bluetooth/main.conf -> /data/etc/bluetooth/main.conf
    

    You use the full, Yocto-generated path when creating the link, but you make it point to the "final" location in the rootfs.

    This way you can use "absolute" paths and won't have to change the working directory in the recipe.

    0 讨论(0)
提交回复
热议问题