Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging bitbake pkg_postinst_${PN}: Append to config-file installed by other recipe

I'm writing am openembedded/bitbake recipe for openembedded-classic. My recipe RDEPENDS on keyutils, and everything seems to work, except one thing: I want to append a single line to the /etc/request-key.conf file installed by the keyutils package. So I added the following to my recipe:

pkg_postinst_${PN} () {
  echo 'create ... more stuff ..' >> ${sysconfdir}/request-key.conf
}

However, the intended added line is missing in my resulting image. My recipe inherits update-rc.d if that makes any difference.

My main question is: How do i debug this? Currently I am constructing an entire rootfs image, and then poke-around in that to see, if the changes show up. Surely there is a better way?

UPDATE: Changed recipe to:

pkg_postinst_${PN} () {
  echo 'create ... more stuff ...' >> ${D}${sysconfdir}/request-key.conf
}

But still no luck.

like image 631
S.C. Madsen Avatar asked Oct 20 '25 05:10

S.C. Madsen


2 Answers

As far as I know, postinst runs at rootfs creation, and only at first boot if rootfs fails.

So there is a easy way to execute something only first boot. Just check for $D, like this:

pkg_postinst_stuff() {
#!/bin/sh -e
if [ x"$D" = "x" ]; then
    # do something at first boot here
else
    exit 1
fi
}
like image 145
zwerch Avatar answered Oct 22 '25 03:10

zwerch


postinst scripts are ran at roots time, so ${sysconfdir} is /etc on your host. Use $D${sysconfdir} to write to the file inside the rootfs being generated.

like image 44
Ross Burton Avatar answered Oct 22 '25 05:10

Ross Burton