Recipes that update a shared file
Hello All,
What's the best practice for recipes that need to update a shared file provided by a different recipe? For example let's say that the widget-watcher recipe creates /etc/ww.conf and the widget1, and widget2 recipes need to append a line to the config. I've searched through the recipes a bit and can't find a good example. The closest that I've seen is pkg_postinst(). Is that the best method?
Thanks!
Seth
Hi Seth,
Quoted 6 lines · On Wednesday 09 October 2013 19:16:15 seth bollinger wrote:
What's the best practice for recipes that need to update a shared file provided by a different recipe? For example let's say that the widget-watcher recipe creates
/etc/ww.confand the widget1, and widget2 recipes need to append a line to the config. I've searched through the recipes a bit and can't find a good example. The closest that I've seen ispkg_postinst(). Is that the best method?
That's really the recommended way to do it. If the software being configured supports it, another way is to set it up to read all configuration files from a directory and then you can simply install a new file into that directory from the other recipe (e.g. Apache is usually configured to read all configuration files in /etc/httpd/conf.d or similar).
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Quoted 10 lines · Paul Eggleton
That's really the recommended way to do it. If the software being configured
supports it, another way is to set it up to read all configuration files from a
directory and then you can simply install a new file into that directory from
the other recipe (e.g. Apache is usually configured to read all configuration
files in/etc/httpd/conf.dor similar).
Yes, I would have liked to solve the problem that way, but unfortunately the software doesn't support it, and we don't want to make changes currently. :)
I'm having a lot of trouble getting pkg_postinst() to work. From what I've read, it should happen during rootfs generation, but I'm not see the file in the rootfs.
I found an example in the xfce4-session_4.10.0.bb recipe. It looks like /etc/hosts is installed by netbase, so this is very similar to what my recipe is doing.
# protect from frightening message that xfce might not work correctly
pkg_postinst_${PN} () {
echo 127.0.0.1 ${MACHINE} >> /etc/hosts
}I've tried this in my recipe, and the file that I expect to be present in the rootfs is not there...not sure what I'm doing wrong. pkg_postinst_${PN} () {
echo test >> /etc/inittest2
}
Also, the documentation states that this mechanism can be used to do things on first boot. Do I need to add code to make sure that this doesn't happen on first boot?
Thanks!
Seth
Quoted 3 lines · Seth Bollinger
pkg_postinst_${PN} () {
echo 127.0.0.1 ${MACHINE} >> /etc/hosts
}Yeah, that's broken.
Quoted 5 lines
I've tried this in my recipe, and the file that I expect to be present in the rootfs is not there...not sure what I'm doing wrong. pkg_postinst_${PN} () {
echo test >>/etc/inittest2
}
You need to use $D so that you're not attempting to write to the *host's* /etc:
echo test >> $D/etc/inittest2
In a postinst $D may be set, and if it is then the postinst is being ran on the host at rootfs time, and points to where the rootfs is being constructed.
Ross
Quoted 9 lines · Ross
You need to use $D so that you're not attempting to write to the *host's* /etc:
echo test >> $D/etc/inittest2
In a postinst $D may be set, and if it is then the postinst is being ran on the host at rootfs time, and points to where the rootfs is being constructed.
Ok, I changed to as follows:
pkg_postinst_${PN} () {
echo "testtest" >> ${D}/etc/inittest
}After that I do a find and the file is only populated in the recipe's image directory, not the rootfs.
$ find . -iname inittest ./tmp/work/armv5te-dbl-linux-gnueabi/widget/1.0-r0/image/etc/inittest
Thanks!
Seth
Quoted 10 lines · Seth Bollinger
Quoted 8 lines
You need to use $D so that you're not attempting to write to the *host's* /etc:
echo test >> $D/etc/inittest2
In a postinst $D may be set, and if it is then the postinst is being ran on the host at rootfs time, and points to where the rootfs is being constructed.
Quoted 7 lines
Ok, I changed to as follows:
pkg_postinst_${PN} () { echo "testtest" >> ${D}/etc/inittest }After that I do a find and the file is only populated in the recipe's image directory, not the rootfs.
Use $D instead of ${D}. ${D} will get expanded when the package is created but you want to use the environment variable $D.
Ross
Quoted 3 lines · Ross
Use $D instead of ${D}. ${D} will get expanded when the package is created but you want to use the environment variable $D.
Looks like that worked! I apologize for missing the curly braces in your previous response.
Thanks very much!
Seth