Skip to content

Commit c1c2150

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 <[email protected]>
1 parent 4580b15 commit c1c2150

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:
@@ -93,36 +94,32 @@ fedora-coreos := "quay.io/fedora/fedora-coreos:testing-devel"
9394
_keygen:
9495
./hack/generate-secureboot-keys
9596

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

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

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

0 commit comments

Comments
 (0)