diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-06-12 17:13:07 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-06-12 17:13:07 +0000 |
| commit | 5470cd0a37044ef316bec00cc5c476b39876179c (patch) | |
| tree | 1e379d0a14d5614f750adf0deaf20dbe0864ab05 | |
| parent | 6fc1aa83552713dc03933115890badebb297e4ae (diff) | |
| download | meta-virtualization-5470cd0a37044ef316bec00cc5c476b39876179c.tar.gz | |
image-oci: auto-derive IMAGE_INSTALL from OCI_LAYERS packages layers
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 <bruce.ashfield@gmail.com>
| -rw-r--r-- | classes/image-oci.bbclass | 22 |
1 files 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() { | |||
| 371 | " apt-native:do_populate_sysroot") | 371 | " apt-native:do_populate_sysroot") |
| 372 | bb.debug(1, "OCI: Added apt-native dependency for packages layers") | 372 | bb.debug(1, "OCI: Added apt-native dependency for packages layers") |
| 373 | 373 | ||
| 374 | # Extract all packages from OCI_LAYERS and add do_package_write dependencies | 374 | # Extract all packages from OCI_LAYERS and fold them into |
| 375 | # This allows IMAGE_INSTALL = "" for pure multi-layer builds | 375 | # IMAGE_INSTALL so do_rootfs's recrdeptask actually builds them. |
| 376 | # | ||
| 377 | # Without this, multi-layer recipes have to duplicate every | ||
| 378 | # package across two source-of-truth lists: once in OCI_LAYERS | ||
| 379 | # (used at layer-assembly time) and once in IMAGE_INSTALL (to | ||
| 380 | # trigger the build via do_rootfs). Any drift between the two | ||
| 381 | # silently breaks builds at layer-assembly time when the | ||
| 382 | # missing package isn't in DEPLOY_DIR_*PK. | ||
| 383 | # | ||
| 384 | # We append rather than replace: a recipe is still free to add | ||
| 385 | # IMAGE_INSTALL entries that aren't named in OCI_LAYERS (e.g. | ||
| 386 | # for rootfs-only postprocess fixups that don't land in any | ||
| 387 | # final layer). | ||
| 376 | all_packages = set() | 388 | all_packages = set() |
| 377 | for layer_def in oci_layers.split(): | 389 | for layer_def in oci_layers.split(): |
| 378 | parts = layer_def.split(':') | 390 | parts = layer_def.split(':') |
| @@ -383,9 +395,9 @@ python __anonymous() { | |||
| 383 | all_packages.add(pkg) | 395 | all_packages.add(pkg) |
| 384 | 396 | ||
| 385 | if all_packages: | 397 | if all_packages: |
| 386 | # Note: Packages need to be in IMAGE_INSTALL to trigger builds | 398 | d.appendVar('IMAGE_INSTALL', ' ' + ' '.join(sorted(all_packages))) |
| 387 | # via do_rootfs recrdeptask. We just log which packages we found. | 399 | bb.debug(1, "OCI multi-layer: auto-added to IMAGE_INSTALL: " |
| 388 | bb.debug(1, f"OCI multi-layer: Found packages in OCI_LAYERS: {' '.join(all_packages)}") | 400 | + ' '.join(sorted(all_packages))) |
| 389 | 401 | ||
| 390 | # Resolve base image and set up dependencies | 402 | # Resolve base image and set up dependencies |
| 391 | if base_image: | 403 | if base_image: |
