@@ -83,7 +83,7 @@ RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
8383 # Install systemd-ukify and systemd-boot for UKIs
8484 # This also installs systemd-boot for the grub UKI case which is not ideal...
8585 if [[ "${boot_type}" == "uki" ]]; then
86- pkgs_to_install+=(systemd-ukify)
86+ pkgs_to_install+=(systemd-ukify binutils )
8787 fi
8888
8989 if [[ ${#pkgs_to_install[@]} -gt 0 ]]; then
@@ -135,7 +135,10 @@ ARG pkgversion
135135ARG SOURCE_DATE_EPOCH
136136ENV SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}
137137# Build RPM directly from source, using cached target directory
138- RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/src/target --mount=type=cache,target=/var/roothome RPM_VERSION="${pkgversion}" /src/contrib/packaging/build-rpm
138+ RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
139+ --mount=type=cache,target=/src/target \
140+ --mount=type=cache,target=/var/roothome \
141+ RPM_VERSION="${pkgversion}" /src/contrib/packaging/build-rpm
139142
140143# Build a systemd-sysext containing just the bootc binary.
141144# Skips RPM machinery entirely for fast incremental rebuilds.
@@ -218,7 +221,7 @@ COPY --from=update-generated-from-code /src/docs/src/*.schema.json /docs/src/
218221# ----
219222
220223# Perform all filesystem transformations except generating the sealed UKI (if configured)
221- FROM base as base-penultimate
224+ FROM base as base-penultimate-source
222225ARG variant
223226ARG bootloader
224227ARG boot_type
@@ -246,6 +249,10 @@ rm -rf /var/cache
246249rm -rf /run/rhsm
247250
248251EORUN
252+
253+ FROM base-penultimate-source as base-penultimate
254+ ARG boot_type
255+
249256# Configure the rootfs
250257ARG rootfs=""
251258RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
@@ -260,9 +267,19 @@ RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp
260267COPY --from=packaging /usr-extras/ /usr/
261268# Clean up package manager caches
262269RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
263- --mount=type=bind,from=packaging,src=/,target=/run/packaging \
270+ --mount=type=bind,from=base-penultimate-source,src=/,target=/run/base-penultimate-src \
271+ --mount=type=bind,from=packaging,src=/,target=/run/packaging <<EORUN
264272 /run/packaging/cleanup
265273
274+ # Remove kernel + initrd if UKI
275+ if [[ "${boot_type}" == "uki" ]]; then
276+ kver=$(bootc container inspect --rootfs /run/base-penultimate-src --json | jq -r '.kernel.version' )
277+
278+ rm -v "/usr/lib/modules/$kver/vmlinuz"
279+ rm -v "/usr/lib/modules/$kver/initramfs.img"
280+ fi
281+ EORUN
282+
266283# Generate the sealed UKI in a separate stage
267284# This computes the composefs digest from base-penultimate and creates a signed UKI
268285# We need our newly-built bootc for the compute-composefs-digest command
@@ -278,18 +295,29 @@ RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp
278295RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
279296 --mount=type=secret,id=secureboot_key \
280297 --mount=type=secret,id=secureboot_cert \
298+ --mount=type=bind,from=base-penultimate-source,src=/,target=/run/base-penultimate-src \
281299 --mount=type=bind,from=packaging,src=/,target=/run/packaging \
282300 --mount=type=bind,from=base-penultimate,src=/,target=/run/target <<EORUN
283301set -xeuo pipefail
284302
285- allow_missing_verity=false
303+ allow_missing_verity=()
286304
287305if [[ $filesystem == "xfs" ]]; then
288- allow_missing_verity=true
306+ allow_missing_verity=(--allow-missing-verity)
289307fi
290308
291309if test "${boot_type}" = "uki" ; then
292- /run/packaging/seal-uki /run/target /out /run/secrets $allow_missing_verity $seal_state
310+ kver=$(bootc container inspect --rootfs /run/base-penultimate-src --json | jq -r '.kernel.version' )
311+
312+ /run/packaging/seal-uki \
313+ --target /run/target \
314+ --output /out \
315+ --secrets /run/secrets \
316+ "${allow_missing_verity[@]}" \
317+ --kernel "/run/base-penultimate-src/usr/lib/modules/$kver/vmlinuz" \
318+ --kver "$kver" \
319+ --initramfs "/run/base-penultimate-src/usr/lib/modules/$kver/initramfs.img" \
320+ --seal-state $seal_state
293321fi
294322EORUN
295323
@@ -299,11 +327,13 @@ ARG variant
299327ARG boot_type
300328# Copy the sealed UKI and finalize the image (remove raw kernel, create symlinks)
301329RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
330+ --mount=type=bind,from=base-penultimate-source,src=/,target=/run/base-penultimate-src \
302331 --mount=type=bind,from=packaging,src=/,target=/run/packaging \
303332 --mount=type=bind,from=sealed-uki,src=/,target=/run/sealed-uki <<EORUN
304333set -xeuo pipefail
305334if test "${boot_type}" = "uki" ; then
306- /run/packaging/finalize-uki /run/sealed-uki/out
335+ kver=$(bootc container inspect --rootfs /run/base-penultimate-src --json | jq -r '.kernel.version' )
336+ /run/packaging/finalize-uki /run/sealed-uki/out "$kver"
307337fi
308338EORUN
309339# And finally, test our linting
0 commit comments