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

5.8k views Asked by At

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.

4

There are 4 answers

2
zwerch On

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
}
2
Ross Burton On

One more thing. If foo RDEPENDS on bar that just means "when foo is installed, bar is also installed". I'm not sure it makes assertions about what is installed during the install phase, when your postinst is running.

If using $D doesn't fix the problem try editing your postinst to copy the existing file you're trying to edit somewhere else, so you can verify that it exists in the first place. Its possible that you're appending to a file that doesn't exist yet, and the the package that installs the file replaces it.

4
Ross Burton On

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.

2
balister On

OE-Classic is pretty ancient so you really should update to oe-core.

That said, Do postinst's run at first boot? I'm not sure. Also look in the recipes work directory in the temp directory and read the log and run files to see if there are any clues there.