Re: Install packages to an "image" without its dependencies being pulled in. #yocto

Chuck Wolber


This is a version of the question - "how do I build an image that *ONLY* includes the packages I explicitly specify". This involves bypassing a lot of guards and bitbake tooling, but it can be done.

Your mileage may vary depending on your distro setup. In particular this assumes you are configured to use the IPK package format. The dnf command had significant issues a while back, so I switched from RPM to IPK. If you use RPM, the OPKG_ARGS stuff not going to work for you.

OPKG_ARGS += "--no-install-recommends --nodeps --force-depends"

ROOTFS_POSTPROCESS_COMMAND_remove = "systemd_create_users; "
ROOTFS_POSTPROCESS_COMMAND_remove = "rootfs_update_timestamp; "
ROOTFS_POSTPROCESS_COMMAND_remove = "rootfs_reproducible; "

IMAGE_CMD_cpio_prepend() {

If you want the pre and postinstall scripts to trigger, you need to add an IMAGE_PREPROCESS_COMMAND function that takes your PACKAGE_INSTALL list and concatenates the package level control, preinst, and postinst scripts. This involves unpacking the ipk found in ${WORKDIR}/oe-rootfs-repo/*/${PKG}_*.ipk. You may also want to post-process the resulting script to remove "set -e" invocations, since those scripts make assumptions about dependencies that you are (hopefully) safe to ignore.

You may also want another IMAGE_PREPROCESS_COMMAND function that deletes stuff that can accidentally overwrite your image rootfs files, like /etc/passwd and /etc/group.

Once you get it all dialed in, you can probably abstract the useful bits to your own image-layer bbclass so you can trivially reuse it.


On Fri, Aug 20, 2021 at 12:36 AM <bibibobibo@...> wrote:
Greetings everyone, 

Is there a way to instruct Yocto's image class to install package(s) without its dependencies for an image target (i.e ext4)? For instance, we are trying to build a system where there is a main system partition and another partition that'll host additional lib, etc and during boot up we would overlay them together. Hence, the "other" partition does not really need all the same system libs, etc that already exists on the system partition. This other partition is developed by an external partner so we want to have the autonomy to update separately (i.e not mingled things together with system partition). I am having trouble finding a way to do this because Yocto seem to like to install a package long with all its dependencies (i.e glibc, etc).

PS. I apologize if this is not the right place to ask the question.


"Perfection must be reached by degrees; she requires the slow hand of time." - Voltaire

Join to automatically receive all group messages.