'YOCTO : recipe to insert a script in init.d doesn't work

I would insert a startuo.sh script in \etc\init.d\ directory of my devices. To do that I use this *.bb file:

DESCRIPTION = "System start up script"
PRIORITY = "optional"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://startup.sh"

do_install() {

      install -d ${D}/etc/init.d/
      install -m 0755 ${THISDIR}/files/startup.sh ${D}/etc/init.d/startup.sh
}



 

the bitbake works without error and warning but the ev board is not able to bring-up. It is blocked during boot phase. The problem should be in this recipes because without it, the board goes up and running

Any suggestion? Thanks!



Solution 1:[1]

THISDIR points to your recipe's folder.

It is recommended to use the file from the workding directory of the recipe.

Your file is located under WORKDIR because it is unpacked there based on your SRC_URI variable.

So, you need to change your recipe to:

DESCRIPTION = "System start up script"
PRIORITY = "optional"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://startup.sh"

do_install() {
      install -d ${D}/etc/init.d/
      install -m 0755 ${WORKDIR}/startup.sh ${D}/etc/init.d/startup.sh
#                         ^
#                         |
# Here --------------------
}

# Do not forget to specify the package's files:
FILES_${PN} += "/etc/init.d/startup.sh"

EDIT

I think you need to apply init.d service rules.

Check this link on how to use update-rc.d class for init.d scripts with Yocto.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1