Skip to content

Commit 104799c

Browse files
committed
build-sys: Simplify build recipes and add BOOTC_SKIP_PACKAGE
Remove the separate build-from-packages and _build-from-package helper recipes. The build logic is now inlined directly in the build recipe. Add BOOTC_SKIP_PACKAGE=1 environment variable support to skip the package build step when packages are provided externally (e.g. from CI artifacts). This is used in ci.yml for the test-integration job. Assisted-by: OpenCode (Sonnet 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent d220d98 commit 104799c

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ jobs:
189189

190190
- name: Build container
191191
run: |
192-
just build-from-packages target/packages
192+
BOOTC_SKIP_PACKAGE=1 just build
193193
# Extra cross-check (duplicating the integration test) that we're using the right base
194194
used_vid=$(podman run --rm localhost/bootc bash -c '. /usr/lib/os-release && echo ${ID}-${VERSION_ID}')
195195
test ${{ matrix.test_os }} = "${used_vid}"

Justfile

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@ sealed_buildargs := "--build-arg=variant=" + variant + " --secret=id=secureboot_
5252
# The default target: build the container image from current sources.
5353
# Note commonly you might want to override the base image via e.g.
5454
# `just build --build-arg=base=quay.io/fedora/fedora-bootc:42`
55-
#
56-
# This first builds RPMs via the `package` target, then injects them
5755
# into the container image.
56+
#
57+
# Note you can set `BOOTC_SKIP_PACKAGE=1` in the environment to bypass this stage.
5858
build: package _keygen && _pull-lbi-images
59-
@just _build-from-package target/packages
60-
61-
# Build container image using pre-existing packages from PATH.
62-
# This skips the package build step - useful when packages are provided
63-
# externally (e.g. downloaded from CI artifacts).
64-
build-from-packages PATH: _keygen && _pull-lbi-images
65-
@just _build-from-package {{PATH}}
59+
#!/bin/bash
60+
set -xeuo pipefail
61+
test -d target/packages
62+
# Resolve to absolute path for podman volume mount
63+
# Use :z for SELinux relabeling
64+
pkg_path=$(realpath target/packages)
65+
podman build --target=final -v "${pkg_path}":/run/packages:ro,z -t {{base_img}}-bin {{buildargs}} .
66+
./hack/build-sealed {{variant}} {{base_img}}-bin {{base_img}} {{sealed_buildargs}}
6667

6768
# Pull images used by hack/lbi
6869
_pull-lbi-images:
@@ -91,36 +92,32 @@ _git-build-vars:
9192
_keygen:
9293
./hack/generate-secureboot-keys
9394

94-
# Internal helper: build container image from packages at PATH
95-
_build-from-package PATH:
96-
#!/bin/bash
97-
set -xeuo pipefail
98-
# Resolve to absolute path for podman volume mount
99-
# Use :z for SELinux relabeling
100-
pkg_path=$(realpath "{{PATH}}")
101-
podman build --target=final -v "${pkg_path}":/run/packages:ro,z -t {{base_img}}-bin {{buildargs}} .
102-
./hack/build-sealed {{variant}} {{base_img}}-bin {{base_img}} {{sealed_buildargs}}
103-
10495
# Build a sealed image from current sources.
10596
build-sealed:
10697
@just --justfile {{justfile()}} variant=composefs-sealeduki-sdboot build
10798

108-
# Build packages (e.g. RPM) using a container buildroot
109-
_packagecontainer:
99+
# Build packages (e.g. RPM) into target/packages/
100+
# Any old packages will be removed.
101+
# Set BOOTC_SKIP_PACKAGE=1 in the environment to bypass this stage. We don't
102+
# yet have an accurate ability to avoid rebuilding this in CI yet.
103+
package:
110104
#!/bin/bash
111105
set -xeuo pipefail
106+
packages=target/packages
107+
if test -n "${BOOTC_SKIP_PACKAGE:-}"; then
108+
if test '!' -d "${packages}"; then
109+
echo "BOOTC_SKIP_PACKAGE is set, but missing ${packages}" 1>&2; exit 1
110+
fi
111+
exit 0
112+
fi
112113
eval $(just _git-build-vars)
113114
echo "Building RPM with version: ${VERSION}"
114115
podman build {{base_buildargs}} --build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} --build-arg=pkgversion=${VERSION} -t localhost/bootc-pkg --target=build .
115-
116-
# Build packages (e.g. RPM) into target/packages/
117-
# Any old packages will be removed.
118-
package: _packagecontainer
119-
mkdir -p target/packages
120-
rm -vf target/packages/*.rpm
121-
podman run --rm localhost/bootc-pkg tar -C /out/ -cf - . | tar -C target/packages/ -xvf -
122-
chmod a+rx target target/packages
123-
chmod a+r target/packages/*.rpm
116+
mkdir -p "${packages}"
117+
rm -vf "${packages}"/*.rpm
118+
podman run --rm localhost/bootc-pkg tar -C /out/ -cf - . | tar -C "${packages}"/ -xvf -
119+
chmod a+rx target "${packages}"
120+
chmod a+r "${packages}"/*.rpm
124121
# Keep localhost/bootc-pkg for layer caching; use `just clean-local-images` to reclaim space
125122

126123
# Build+test using the `composefs-sealeduki-sdboot` variant.

0 commit comments

Comments
 (0)