Yocto: Create a New Directory in etcdir

╄→尐↘猪︶ㄣ 提交于 2019-12-08 06:31:41

问题


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

"

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


回答1:


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




回答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.




回答3:


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
 }


来源:https://stackoverflow.com/questions/54307437/yocto-create-a-new-directory-in-etcdir

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!