Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create symbolic link in bitbake recipe

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:~/yocto/genericx86-64-rocko-18.0.0/meta-datavision/recipes-devtools/oracle-java$ cat oracle-jse-jdk_1.7.0.bbappend 
FILES_${PN} += "/lib64/ld-linux-x86-64.so.2"

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

However, only the directory /lib64 is created in the sysroot. The symlink /lib64/ld-linux-x86-64.so.2 is not being generated.

What changes should I make in my recipe in order to have this symlink correctly created?

like image 447
Bernardo Rodrigues Avatar asked Jan 09 '18 11:01

Bernardo Rodrigues


3 Answers

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
like image 149
Fede Avatar answered Oct 17 '22 15:10

Fede


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

like image 38
Christopher Boyd Avatar answered Oct 17 '22 14:10

Christopher Boyd


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 
}
like image 7
ɛIc_ↄIз Avatar answered Oct 17 '22 13:10

ɛIc_ↄIз