From b06d7089e3772a94fbdb897da5410b05e0158656 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 2 Sep 2025 17:36:30 +0200 Subject: [PATCH 1/3] distro: Fix build container use in bootc distro This fixes two things: 1) If SetBuildContainer() is not called, buildImgRef is nil 2) If it is called, buildImgRef is properly set to the value passed. Without this, when using a build container, I got errors about a missing "target" pipeline when using https://github.com/osbuild/bootc-image-builder/pull/1014 --- pkg/distro/bootc/bootc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/distro/bootc/bootc.go b/pkg/distro/bootc/bootc.go index 9e315ca6c1..a65428f922 100644 --- a/pkg/distro/bootc/bootc.go +++ b/pkg/distro/bootc/bootc.go @@ -77,6 +77,7 @@ func (d *BootcDistro) SetBuildContainer(imgref string) (err error) { if err != nil { return err } + d.buildImgref = imgref d.buildSourceInfo = info return nil } @@ -399,8 +400,7 @@ func NewBootcDistro(imgref string) (bd *BootcDistro, err error) { sourceInfo: info, rootfsMinSize: cntSize * containerSizeToDiskSizeMultiplier, - imgref: imgref, - buildImgref: imgref, + imgref: imgref, } for _, archStr := range []string{"x86_64", "aarch64", "ppc64le", "s390x", "riscv64"} { From 553ab624974e5f12d7297dca732be57a58e9b6f5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 3 Sep 2025 09:02:11 +0200 Subject: [PATCH 2/3] distro: tweak the handling of build container By default initialize the bootc and build container to be the same and add comment about SetBuildContianer(). --- pkg/distro/bootc/bootc.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/distro/bootc/bootc.go b/pkg/distro/bootc/bootc.go index a65428f922..8888c10be2 100644 --- a/pkg/distro/bootc/bootc.go +++ b/pkg/distro/bootc/bootc.go @@ -397,10 +397,14 @@ func NewBootcDistro(imgref string) (bd *BootcDistro, err error) { name: nameVer, releasever: info.OSRelease.VersionID, defaultFs: defaultFs, - sourceInfo: info, rootfsMinSize: cntSize * containerSizeToDiskSizeMultiplier, - imgref: imgref, + imgref: imgref, + sourceInfo: info, + // default buildref/info to regular container, this can + // be overriden with SetBuildContainer() + buildImgref: imgref, + buildSourceInfo: info, } for _, archStr := range []string{"x86_64", "aarch64", "ppc64le", "s390x", "riscv64"} { From 42c1142e060ec2faff7c2517e03de0991d2e90b4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 3 Sep 2025 09:11:58 +0200 Subject: [PATCH 3/3] tools: extend gen-bootc-diff test to consider build-containers This commit adds support for manifest generation with build containers. The syntax is in gen-manifests-gen is a bit ugly and uses a `#` to separate the main bootc container and the build container. But this tool will go away and get replaced with https://github.com/osbuild/images/pull/1821 which has a nicer syntax. --- cmd/gen-manifests/main.go | 14 +++++++- tools/gen-bootc-diff | 70 +++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index b9e806411b..b7f356596a 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -513,11 +513,23 @@ func main() { } } } - for _, bootcRef := range bootcRefs { + for _, bootcRefTuple := range bootcRefs { + l := strings.SplitN(bootcRefTuple, "#", 2) + bootcRef := l[0] + var buildBootcRef string + if len(l) > 1 { + buildBootcRef = l[1] + } + distribution, err := bootc.NewBootcDistro(bootcRef) if err != nil { panic(err) } + if buildBootcRef != "" { + if err := distribution.SetBuildContainer(buildBootcRef); err != nil { + panic(err) + } + } // XXX: consider making this configurable but for now // we just need diffable manifests if distribution.DefaultFs() == "" { diff --git a/tools/gen-bootc-diff b/tools/gen-bootc-diff index 57ce4031e8..986fbd4430 100755 --- a/tools/gen-bootc-diff +++ b/tools/gen-bootc-diff @@ -81,43 +81,49 @@ for REF in quay.io/centos-bootc/centos-bootc:stream9 \ do for ARCH in x86_64 aarch64; do for BP in "$BP_FULL_FS" "$BP_LVM" "$BP_EMPTY"; do - echo "Testing $REF;$ARCH;$(basename "$BP")" - sudo podman pull -q --arch "$ARCH" "$REF" + for BUILD_REF in "" "quay.io/fedora/fedora-bootc:41"; do + echo "Testing $REF;$ARCH;$(basename "$BP")" + sudo podman pull -q --arch "$ARCH" "$REF" + if [ -n "$BUILD_REF" ]; then + sudo podman pull -q --arch "$ARCH" "$BUILD_REF" + fi - TMPDIR=$(mktemp -d) - trap 'rm -rf -- "$TMPDIR"' EXIT + TMPDIR=$(mktemp -d) + trap 'rm -rf -- "$TMPDIR"' EXIT - ROOTFS="" - if grep -q fedora <(echo "$REF"); then - ROOTFS="ext4" - fi + ROOTFS="" + if grep -q fedora <(echo "$REF"); then + ROOTFS="ext4" + fi - sudo go run \ - -buildvcs=false \ - github.com/osbuild/bootc-image-builder/bib/cmd/bootc-image-builder@main \ - manifest -v "$REF" \ - --config "$BP" \ - --target-arch "$ARCH" \ - --rootfs "$ROOTFS" \ - --type "$TYPE" | jq > "$TMPDIR/bib.json" + sudo go run \ + -buildvcs=false \ + github.com/osbuild/bootc-image-builder/bib/cmd/bootc-image-builder@main \ + manifest -v "$REF" \ + --config "$BP" \ + --target-arch "$ARCH" \ + --rootfs "$ROOTFS" \ + --build-container "$BUILD_REF" \ + --type "$TYPE" | jq > "$TMPDIR/bib.json" - # oh well, we need to convert our blueprint into the - # gen-manifests config :/ - echo '{"blueprint":' > "$TMPDIR"/gm-conf.json - cat "$BP" >> "$TMPDIR"/gm-conf.json - echo '}' >> "$TMPDIR"/gm-conf.json - sudo ./cmd/gen-manifests/gen-manifests \ - -types "$TYPE" \ - -arches "$ARCH" \ - -distros ignore \ - -metadata=false \ - -config "$TMPDIR"/gm-conf.json \ - -bootc-refs "$REF" \ - -output "$TMPDIR" + # oh well, we need to convert our blueprint into the + # gen-manifests config :/ + echo '{"blueprint":' > "$TMPDIR"/gm-conf.json + cat "$BP" >> "$TMPDIR"/gm-conf.json + echo '}' >> "$TMPDIR"/gm-conf.json + sudo ./cmd/gen-manifests/gen-manifests \ + -types "$TYPE" \ + -arches "$ARCH" \ + -distros ignore \ + -metadata=false \ + -config "$TMPDIR"/gm-conf.json \ + -bootc-refs "$REF#$BUILD_REF" \ + -output "$TMPDIR" - # ensure manifests are identical (but skip uuid diffs) - echo "Comparing images and bootc-image-builder generated manifests" - diff -u <(grep -v uuid "$TMPDIR"/bootc_*.json) <(grep -v uuid "$TMPDIR"/bib.json) + # ensure manifests are identical (but skip uuid diffs) + echo "Comparing images and bootc-image-builder generated manifests" + diff -u <(grep -v uuid "$TMPDIR"/bootc_*.json) <(grep -v uuid "$TMPDIR"/bib.json) + done done done done