From 5470cd0a37044ef316bec00cc5c476b39876179c Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Fri, 12 Jun 2026 17:13:07 +0000 Subject: image-oci: auto-derive IMAGE_INSTALL from OCI_LAYERS packages layers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A multi-layer image recipe (OCI_LAYER_MODE = "multi") needs every package it puts into a packages: layer to also be reachable by do_rootfs's recrdeptask so the package is actually built before layer assembly tries to pull it from DEPLOY_DIR_*PK. The convention to date has been: list each package twice — once in OCI_LAYERS, once in IMAGE_INSTALL — and keep both in sync by hand. Any drift between the two sources of truth silently breaks the build at layer-assembly time. The error surfaces as "missing package in DEPLOY_DIR" rather than as a parse-time complaint about the recipe, so it's also annoying to debug. The parse-time anonymous python in this class already walks OCI_LAYERS, validates each entry, and collects every package name into a set. It then stops at bb.debug logging that set. Append the set to IMAGE_INSTALL instead. do_rootfs picks the entries up via the existing recrdeptask, the recipe gets one source of truth, and drift is no longer possible. The append is additive — a recipe is still free to add IMAGE_INSTALL entries that aren't named in any final layer (e.g. packages used only during a rootfs postprocess fixup). The auto-derivation only fires when OCI_LAYER_MODE = "multi" and at least one packages: layer is present, so single-layer recipes and pure directories/files/host multi-layer recipes are unaffected. Signed-off-by: Bruce Ashfield --- classes/image-oci.bbclass | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/classes/image-oci.bbclass b/classes/image-oci.bbclass index 716b6f81..1ceadc7f 100644 --- a/classes/image-oci.bbclass +++ b/classes/image-oci.bbclass @@ -371,8 +371,20 @@ python __anonymous() { " apt-native:do_populate_sysroot") bb.debug(1, "OCI: Added apt-native dependency for packages layers") - # Extract all packages from OCI_LAYERS and add do_package_write dependencies - # This allows IMAGE_INSTALL = "" for pure multi-layer builds + # Extract all packages from OCI_LAYERS and fold them into + # IMAGE_INSTALL so do_rootfs's recrdeptask actually builds them. + # + # Without this, multi-layer recipes have to duplicate every + # package across two source-of-truth lists: once in OCI_LAYERS + # (used at layer-assembly time) and once in IMAGE_INSTALL (to + # trigger the build via do_rootfs). Any drift between the two + # silently breaks builds at layer-assembly time when the + # missing package isn't in DEPLOY_DIR_*PK. + # + # We append rather than replace: a recipe is still free to add + # IMAGE_INSTALL entries that aren't named in OCI_LAYERS (e.g. + # for rootfs-only postprocess fixups that don't land in any + # final layer). all_packages = set() for layer_def in oci_layers.split(): parts = layer_def.split(':') @@ -383,9 +395,9 @@ python __anonymous() { all_packages.add(pkg) if all_packages: - # Note: Packages need to be in IMAGE_INSTALL to trigger builds - # via do_rootfs recrdeptask. We just log which packages we found. - bb.debug(1, f"OCI multi-layer: Found packages in OCI_LAYERS: {' '.join(all_packages)}") + d.appendVar('IMAGE_INSTALL', ' ' + ' '.join(sorted(all_packages))) + bb.debug(1, "OCI multi-layer: auto-added to IMAGE_INSTALL: " + + ' '.join(sorted(all_packages))) # Resolve base image and set up dependencies if base_image: -- cgit v1.2.3-54-g00ecf