Search code examples
yoctobitbakeyocto-recipe

Yocto: Create a New Directory in etcdir


I am new to Yocto, I want to create a directory in /etc and copy my server certificates into that directory. I tried doing below, But it is not creating any directory in /etc, however I am not getting any compilation error:

DESCRIPTION = "OC sample service"

SUMMARY = "Install and start a systemd service and copy server certificates"

LICENSE = "MIT"

SRC_URI = "file://service.tar.gz"

inherit systemd

S = "${WORKDIR}/service"

SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE_${PN} = "sample.service"
SYSTEMD_AUTO_ENABLE = "enable"
INSANE_SKIP_${PN} += "installed-vs-shipped"

do_configure() {
        :
}

do_compile() {
        :
}

do_install() {

        install -d ${D}${systemd_unitdir}/system

        install -m 0755 ${S}/sample.service ${D}${systemd_unitdir}/system

        mkdir -p ${D}${etcdir}/oc_certs

        install -m 0755 ${S}/certs/* ${D}${etcdir}/oc_certs

}

FILES_${PN} = "${systemd_unitdir}/system

"

service.tar.gz contains following

Now the problem is, sample.service is successfully being placed to the location but /etc/oc_certs is not being created.


Solution

  • In addition to LetoThe2nd's answer: the ${etcdir} variable is usually empty. If you want a variable for /etc, it is ${sysconfdir}. So your files are probably installed to root directory.

    Check output of bitbake -e <your_recipe> and try to find etcdir to verify.

    Also drop INSANE_SKIP_${PN} += "installed-vs-shipped" which hides the error your are trying to find (you will see what is installed where but not shipped).

    BTW LetoThe2nd's answer is also needed, because you are overwriting (instead of appending FILES_${PN}, otherwise it wouldn't be needed. The ${sysconfdir} is already part of FILES_${PN}.