Reputation: 43
My yocto build/conf/auto.conf file contains a variable :
READ_ONLY_FS ?= "true"
I want to install a configuration file that can be modified, for that I want that if READ_ONLY_FS is "true", my.conf file is directly installed in /etc. But if READ_ONLY_FS is "false", I want that my.conf file is installed in /data/etc and then soft linked to /etc. (/data is a read write partition)
Currently my recipe contains this as an attempt to achieve what I wanted:
FILES_${PN} += " ${@bb.utils.contains('READ_ONLY_FS', 'true', '', '/data/${sysconfdir}/my.conf', d)}"
do_install_append() {
install -d ${D}/${sysconfdir}
if [ "${@bb.utils.contains('READ_ONLY_FS', 'true', 'true', 'false', d)} == "true" ]; then
install -d ${D}/data/${sysconfdir}
install -m 0755 ${S}/my.conf ${D}/data/${sysconfdir}/my.conf
ln -sf ${D}/data/${sysconfdir}/my.conf ${D}/${sysconfdir}/my.conf
else
install -m 0755 ${S}/my.conf ${D}/${sysconfdir}/my.conf
fi
}
But I get an error: Files/directories were installed but not shipped. What am I doing wrong?
Upvotes: 3
Views: 6295
Reputation: 584
I typically create a bbappend in my own layer to append to volatile-binds.bb,
eg: meta-mylayer/recipes-core/volatile-binds/volatile-binds.bbappend
contains
VOLATILE_BINDS += "\
/data/${sysconfdir}/my.conf /${sysconfdir}/my.conf\n\
"
I have to ensure my rootfs pulls in the volatile-binds
package via a package-group or IMAGE_INSTALL
.
The recipe installing my.conf
does not need to be aware of this redirection, just install into ${sysconfdir}/my.conf
.
volatile-binds
generates a startup script that only takes action if ${sysconfdir}/my.conf
is read-only. In that case it will copy ${sysconfdir}/my.conf
to /data/${sysconfdir}/my.conf
(if it doesn't exist there yet) and bind-mount the latter on top of the former.
I use
IMAGE_FEATURES += "read-only-rootfs"
in my 'read-only image' recipe.
Upvotes: 4
Reputation: 471
Bitbake should normally tell you which files were "installed but not shipped". In your case it seems, that you install /data/${sysconfdir}/my.conf
and the symlink at /${sysconfdir}/my.conf
, but only add the former path to FILES
.
BTW: I think, you can simplify your code by removing the condition in your assignment of FILES
and by accessing READ_ONLY_FS
directly.
Something like this should work (not tested at all):
FILES_${PN} += "/data/${sysconfdir}/my.conf /${sysconfdir}/my.conf"
do_install_append() {
install -d ${D}/${sysconfdir}
if [ ${READ_ONLY_FS} == "true" ]; then
install -d ${D}/data/${sysconfdir}
install -m 0755 ${S}/my.conf ${D}/data/${sysconfdir}/my.conf
ln -sf ${D}/data/${sysconfdir}/my.conf ${D}/${sysconfdir}/my.conf
else
install -m 0755 ${S}/my.conf ${D}/${sysconfdir}/my.conf
fi
}
Upvotes: 1