create symbolic link in bitbake recipe

Bernardo Rodrigues picture Bernardo Rodrigues · Jan 9, 2018 · Viewed 10.5k times · Source

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?

Answer

Fede picture Fede · Jun 28, 2018

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