Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing opkg post install script after image installation

Tags:

bitbake

opkg

We are creating a filesystem image in BitBake and one of the packages requires that its post install script be executed on the device, after the image itself has been installed on the device, and not while the rootfs image is being generated by the build server.

Looking at the package with "opkg status ", it says that the package has been successfully installed -- "install ok installed". However, none of the side effects have been performed, and simply running the .postinst file from /var/lib/opkg/info/.postinst works and reports no errors.

How do I get this to work? It seems that the package is being "installed" in the rootfs image with the incorrect status.

like image 241
Julie in Austin Avatar asked Dec 15 '25 14:12

Julie in Austin


1 Answers

Please see Dev manual section Post-Installation Scripts: With recent Yocto (>=2.7) you can use pkg_postinst_ontarget_${PN}() when you know your script should always run on target during first boot, and never during rootfs generation.

On older Yocto version you can just do what pkg_postinst_ontarget_${PN} does manually in your function pkg_postinst_${PN}():

if [ -n "$D" ]; then
    echo "Delaying until first boot"
    exit 1
fi

# actual post install script here

$D will be defined during rootfs generation so the postinstall script will fail. This means the script will be run again during first boot on target.

The best option is still fixing the postinstall script so that it works during rootfs generation -- sometimes this isn't possible of course.

like image 166
Jussi Kukkonen Avatar answered Dec 18 '25 07:12

Jussi Kukkonen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!