@@ -43,11 +43,39 @@ buildargs := base_buildargs + " --secret=id=secureboot_key,src=target/test-secur
4343# Args for build-sealed (no base arg, it sets that itself)
4444sealed_buildargs := " --build-arg=variant=" + variant + " --secret=id=secureboot_key,src=target/test-secureboot/db.key --secret=id=secureboot_cert,src=target/test-secureboot/db.crt"
4545
46+ # Compute SOURCE_DATE_EPOCH and VERSION from git for reproducible builds.
47+ # Outputs shell variable assignments that can be eval'd.
48+ _ git-build-vars :
49+ #!/ bin/ bash
50+ set -euo pipefail
51+ SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
52+ # Compute version from git (matching xtask.rs gitrev logic)
53+ if VERSION=$(git describe --tags --exact-match 2 >/ dev/ null); then
54+ VERSION=" ${VERSION#v}"
55+ VERSION=" ${VERSION//-/.}"
56+ else
57+ COMMIT=$(git rev-parse HEAD | cut -c1-10)
58+ COMMIT_TS=$(git show -s --format=%ct)
59+ TIMESTAMP=$(date -u -d @${COMMIT_TS} + %Y%m%d%H%M)
60+ VERSION=" ${TIMESTAMP}.g${COMMIT}"
61+ fi
62+ echo " SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}"
63+ echo " VERSION=${VERSION}"
64+
4665# The default target: build the container image from current sources.
4766# Note commonly you might want to override the base image via e.g.
4867# `just build --build-arg=base=quay.io/fedora/fedora-bootc:42`
49- build : package _keygen
50- podman build {{ base_buildargs}} -t {{ base_img}} -bin {{ buildargs}} .
68+ #
69+ # The Dockerfile builds RPMs internally in its 'build' stage, so we don't need
70+ # to call 'package' first. This avoids cache invalidation from external files.
71+ build : _keygen
72+ #!/ bin/ bash
73+ set -xeuo pipefail
74+ eval $(just _git-build-vars)
75+ podman build {{ base_buildargs}} --target=final \
76+ - -build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
77+ - -build-arg=pkgversion=${VERSION} \
78+ - t {{ base_img}} -bin {{ buildargs}} .
5179 ./ hack/ build-sealed {{ variant}} {{ base_img}} -bin {{ base_img}} {{ sealed_buildargs}}
5280
5381# Generate Secure Boot keys (only for our own CI/testing)
@@ -62,18 +90,9 @@ build-sealed:
6290_ packagecontainer :
6391 #!/ bin/ bash
6492 set -xeuo pipefail
65- # Compute version from git (matching xtask.rs gitrev logic)
66- if VERSION=$(git describe --tags --exact-match 2 >/ dev/ null); then
67- VERSION=" ${VERSION#v}"
68- VERSION=" ${VERSION//-/.}"
69- else
70- COMMIT=$(git rev-parse HEAD | cut -c1-10)
71- COMMIT_TS=$(git show -s --format=%ct)
72- TIMESTAMP=$(date -u -d @${COMMIT_TS} + %Y%m%d%H%M)
73- VERSION=" ${TIMESTAMP}.g${COMMIT}"
74- fi
93+ eval $(just _git-build-vars)
7594 echo " Building RPM with version: ${VERSION}"
76- podman build {{ base_buildargs}} --build-arg=pkgversion=${VERSION} -t localhost/ bootc-pkg --target=build .
95+ podman build {{ base_buildargs}} --build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} --build-arg= pkgversion=${VERSION} -t localhost/ bootc-pkg --target=build .
7796
7897# Build packages (e.g. RPM) into target/packages/
7998# Any old packages will be removed.
@@ -86,7 +105,8 @@ package: _packagecontainer
86105 podman rmi localhost/ bootc-pkg
87106
88107# Copy pre-existing packages from PATH into target/packages/
89- # Used to prepare for building with pre-built packages
108+ # Note: This is mainly for CI artifact extraction; build-from-package
109+ # now uses volume mounts directly instead of copying to target/packages/.
90110copy-packages-from PATH :
91111 #!/ bin/ bash
92112 set -xeuo pipefail
@@ -101,11 +121,15 @@ copy-packages-from PATH:
101121 chmod a+ r target/ packages/ *.rpm
102122
103123# Build the container image using pre-existing packages from PATH
104- # Note: The Dockerfile reads from target/packages/, so copy the packages there first
105- # if they're in a different location .
124+ # Uses the 'final- from-packages' target with a volume mount to inject packages,
125+ # avoiding Docker context cache invalidation issues .
106126build-from-package PATH : _keygen
107- @ if [ " {{ PATH}} " != " target/packages" ]; then just copy-packages-from {{ PATH}} ; fi
108- podman build {{ base_buildargs}} -t {{ base_img}} -bin {{ buildargs}} .
127+ #!/ bin/ bash
128+ set -xeuo pipefail
129+ # Resolve to absolute path for podman volume mount
130+ # Use :z for SELinux relabeling
131+ pkg_path=$(realpath " {{ PATH}} " )
132+ podman build {{ base_buildargs}} --target=final-from-packages -v " ${pkg_path}" :/ run/ packages:ro,z -t {{ base_img}} -bin {{ buildargs}} .
109133 ./ hack/ build-sealed {{ variant}} {{ base_img}} -bin {{ base_img}} {{ sealed_buildargs}}
110134
111135# Pull images used by hack/lbi
@@ -137,7 +161,10 @@ run-container-external-tests:
137161
138162# We build the unit tests into a container image
139163build-units :
140- podman build {{ base_buildargs}} --target units -t localhost/ bootc-units .
164+ #!/ bin/ bash
165+ set -xeuo pipefail
166+ eval $(just _git-build-vars)
167+ podman build {{ base_buildargs}} --build-arg=SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} --build-arg=pkgversion=${VERSION} --target units -t localhost/ bootc-units .
141168
142169# Perform validation (build, linting) in a container build environment
143170validate :
@@ -209,3 +236,10 @@ mdbook-serve: build-mdbook
209236# Use this after adding, removing, or modifying CLI options or schemas.
210237update-generated :
211238 cargo run -p xtask update-generated
239+
240+ # Verify build system properties (reproducible builds)
241+ #
242+ # This runs `just package` twice and verifies that the resulting RPMs
243+ # are bit-for-bit identical, confirming SOURCE_DATE_EPOCH is working.
244+ check-buildsys :
245+ cargo run -p xtask check-buildsys
0 commit comments