It is very important that you make sure all
post-Installation (pkg_postinst
) scripts
for packages that are installed into the image can be run
at the time when the root filesystem is created during the
build on the host system.
These scripts cannot attempt to run during first-boot on the
target device.
With the "read-only-rootfs" feature enabled,
the build system checks during root filesystem creation to make
sure all post-installation scripts succeed.
If any of these scripts still need to be run after the root
filesystem is created, the build immediately fails.
These build-time checks ensure that the build fails
rather than the target device fails later during its
initial boot operation.
Most of the common post-installation scripts generated by the build system for the out-of-the-box Yocto Project are engineered so that they can run during root filesystem creation (e.g. post-installation scripts for caching fonts). However, if you create and add custom scripts, you need to be sure they can be run during this file system creation.
Here are some common problems that prevent post-installation scripts from running during root filesystem creation:
Not using $D in front of absolute
paths:
The build system defines
$
D
when the root filesystem is created.
Furthermore, $D
is blank when the
script is run on the target device.
This implies two purposes for $D
:
ensuring paths are valid in both the host and target
environments, and checking to determine which
environment is being used as a method for taking
appropriate actions.
Attempting to run processes that are
specific to or dependent on the target
architecture:
You can work around these attempts by using native
tools, which run on the host system,
to accomplish the same tasks, or
by alternatively running the processes under QEMU,
which has the qemu_run_binary
function.
For more information, see the
qemu
class.