homer69
homer69

Reputation: 73

yocto recipe how to install file to rootfs

sorry I am a little new to syntax of yocto, this is how I have modified my recipe:

LICENSE  = "LGPLv2.1"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = "file://myscript.sh"
FILES_${PN} += "${sysconfdir}/init.d/myscript.sh"

do_install() {
    install -d ${D}${sysconfdir}/init.d
    install -m 0755 ${WORKDIR}/myscript.sh ${D}${sysconfdir}/init.d/
}

The recipe is added to the build, because if I remove the LICENSE line the yocto image will not be baked. The folder where the recipe is kept is named "customssh", inside this folder I have the recipe named customssh_0.1.bb and a subfolder named "files" where the myscript.sh is kept. After I have baked the image, I run this command to see if the myscript.sh has been placed in the rootfs: find . -name 'myscript*' which will return where the file is held:

./meta-swi/common/recipes-core/customssh/files/myscript.sh

In the recipe, is this line correct?

install -m 0755 ${WORKDIR}/myscript.sh ${D}${sysconfdir}/init.d/

Upvotes: 2

Views: 6114

Answers (1)

Talel BELHAJSALEM
Talel BELHAJSALEM

Reputation: 4294

If this is the root recipe and not a bbappend one use do_install instead of do_install_append

Make sure that ${D}${sysconfdir}/init.d is created before copying to it

do_install(){
   install -d ${D}${sysconfdir}/init.d
   install -m 0755 ${WORKDIR}/myscript.sh ${D}${sysconfdir}/init.d/
}

Now, make sure to specify the file you installed so that the do_package will not fail

FILES_${PN} += "${sysconfdir}/init.d/myscript.sh"

Upvotes: 1

Related Questions