Once packages are split and stored in the Package Feeds area, the build system uses BitBake to generate the root filesystem image:
![]() |
The image generation process consists of several stages and
depends on several tasks and variables.
The
do_rootfs
task creates the root filesystem (file and directory
structure) for an image.
This task uses several key variables to help create the
list of packages to actually install:
IMAGE_INSTALL
:
Lists out the base set of packages from which to
install from the Package Feeds area.
PACKAGE_EXCLUDE
:
Specifies packages that should not be installed
into the image.
IMAGE_FEATURES
:
Specifies features to include in the image.
Most of these features map to additional packages
for installation.
PACKAGE_CLASSES
:
Specifies the package backend (e.g. RPM, DEB, or
IPK) to use and consequently helps determine where
to locate packages within the Package Feeds area.
IMAGE_LINGUAS
:
Determines the language(s) for which additional
language support packages are installed.
PACKAGE_INSTALL
:
The final list of packages passed to the package
manager for installation into the image.
With
IMAGE_ROOTFS
pointing to the location of the filesystem under
construction and the PACKAGE_INSTALL
variable providing the final list of packages to install,
the root file system is created.
Package installation is under control of the package manager (e.g. dnf/rpm, opkg, or apt/dpkg) regardless of whether or not package management is enabled for the target. At the end of the process, if package management is not enabled for the target, the package manager's data files are deleted from the root filesystem. As part of the final stage of package installation, post installation scripts that are part of the packages are run. Any scripts that fail to run on the build host are run on the target when the target system is first booted. If you are using a read-only root filesystem, all the post installation scripts must succeed on the build host during the package installation phase since the root filesystem on the target is read-only.
The final stages of the do_rootfs
task
handle post processing.
Post processing includes creation of a manifest file and
optimizations.
The manifest file (.manifest
) resides
in the same directory as the root filesystem image.
This file lists out, line-by-line, the installed packages.
The manifest file is useful for the
testimage
class, for example, to determine whether or not to run
specific tests.
See the
IMAGE_MANIFEST
variable for additional information.
Optimizing processes that are run across the image include
mklibs
, prelink
,
and any other post-processing commands as defined by the
ROOTFS_POSTPROCESS_COMMAND
variable.
The mklibs
process optimizes the size
of the libraries, while the prelink
process optimizes the dynamic linking of shared libraries
to reduce start up time of executables.
After the root filesystem is built, processing begins on
the image through the
do_image
task.
The build system runs any pre-processing commands as
defined by the
IMAGE_PREPROCESS_COMMAND
variable.
This variable specifies a list of functions to call before
the build system creates the final image output files.
The build system dynamically creates
do_image_*
tasks as needed, based
on the image types specified in the
IMAGE_FSTYPES
variable.
The process turns everything into an image file or a set of
image files and can compress the root filesystem image to
reduce the overall size of the image.
The formats used for the root filesystem depend on the
IMAGE_FSTYPES
variable.
Compression depends on whether the formats support
compression.
As an example, a dynamically created task when creating a
particular image type
would
take the following form:
do_image_type
So, if the type
as specified by
the IMAGE_FSTYPES
were
ext4
, the dynamically generated task
would be as follows:
do_image_ext4
The final task involved in image creation is the
do_image_complete
task.
This task completes the image by applying any image
post processing as defined through the
IMAGE_POSTPROCESS_COMMAND
variable.
The variable specifies a list of functions to call once the
build system has created the final image output files.