1

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 it 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.

  • 'Not working' does not explain what is not working exactly. If you get an error message, do provide that. If the snippet is not executed, then provide the full recipe you are working on, so we can see why is it not executed. Generally, use the following pattern when asking questions: a) what do you expect to happen, *specifically* b) what is actually happening, *specifically* – Alexander Kanavin Jan 22 '19 at 11:42
  • Hi @AlexanderKanavin, Thanks for the quick comment, I have updated my question. – Shishir Kumar Singh Jan 22 '19 at 11:59
  • FILES seems still to be missing the directory. – LetoThe2nd Jan 22 '19 at 12:04

3 Answers3

5

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}.

Tomas Novotny
  • 1,771
  • 9
  • 11
2

"Not working" is a rather bad error description, but the most probable issue is that it does not get included in the image. This is because bitbakes packaging mechanisms do not know about that directory, so add it with:

FILES_${PN} += "${etcdir}/oc_certs"

If you need further assistance, please extend your question with a precise error description, respectively the corresponding log.

LetoThe2nd
  • 1,161
  • 7
  • 13
0

You are missing a / after ${D}. To create a directory say mydir in your /etc folder, just add the following code in the do_install() of your recipe.

do_install() {
    install -d ${D}/etc/mydir
 }
Arpan G
  • 86
  • 1
  • 4
  • Well, the `${sysconfdir}` contains `/etc`, so in that particular question the slash isn't needed. But it is true that `${D}` doesn't contain the trailing slash. – Tomas Novotny Jan 23 '19 at 09:38