@@ -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,12 @@ 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 \
139+ --mount=type=tmpfs,target=/run \
140+ --mount=type=tmpfs,target=/tmp \
141+ --mount=type=cache,target=/src/target \
142+ --mount=type=cache,target=/var/roothome \
143+ RPM_VERSION="${pkgversion}" /src/contrib/packaging/build-rpm
139144
140145# Build a systemd-sysext containing just the bootc binary.
141146# Skips RPM machinery entirely for fast incremental rebuilds.
@@ -218,7 +223,7 @@ COPY --from=update-generated-from-code /src/docs/src/*.schema.json /docs/src/
218223# ----
219224
220225# Perform all filesystem transformations except generating the sealed UKI (if configured)
221- FROM base as base-penultimate
226+ FROM base as base-penultimate-source
222227ARG variant
223228ARG bootloader
224229ARG boot_type
@@ -234,6 +239,7 @@ if [[ "${bootloader}" == "systemd" ]]; then
234239fi
235240
236241if [[ "${boot_type}" == "uki" ]]; then
242+ bootc container inspect --rootfs / --json | jq -r '.kernel.version' > /var/kernel_ver
237243 cp /run/packaging/seal-uki /usr/bin/seal-uki
238244 cp /run/packaging/finalize-uki /usr/bin/finalize-uki
239245 cp /run/packaging/initialize-sealing-tools /usr/bin/initialize-sealing-tools
@@ -246,6 +252,10 @@ rm -rf /var/cache
246252rm -rf /run/rhsm
247253
248254EORUN
255+
256+ FROM base-penultimate-source as base-penultimate
257+ ARG boot_type
258+
249259# Configure the rootfs
250260ARG rootfs=""
251261RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
@@ -260,9 +270,19 @@ RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp
260270COPY --from=packaging /usr-extras/ /usr/
261271# Clean up package manager caches
262272RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
263- --mount=type=bind,from=packaging,src=/,target=/run/packaging \
273+ --mount=type=bind,from=base-penultimate-source,src=/,target=/run/base-penultimate-src \
274+ --mount=type=bind,from=packaging,src=/,target=/run/packaging <<EORUN
264275 /run/packaging/cleanup
265276
277+ # Remove kernel + initrd if UKI
278+ if [[ "${boot_type}" == "uki" ]]; then
279+ kver=$(cat /run/base-penultimate-src/var/kernel_ver)
280+
281+ rm -v "/usr/lib/modules/$kver/vmlinuz"
282+ rm -v "/usr/lib/modules/$kver/initramfs.img"
283+ fi
284+ EORUN
285+
266286# Generate the sealed UKI in a separate stage
267287# This computes the composefs digest from base-penultimate and creates a signed UKI
268288# We need our newly-built bootc for the compute-composefs-digest command
@@ -278,18 +298,29 @@ RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp
278298RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
279299 --mount=type=secret,id=secureboot_key \
280300 --mount=type=secret,id=secureboot_cert \
301+ --mount=type=bind,from=base-penultimate-source,src=/,target=/run/base-penultimate-src \
281302 --mount=type=bind,from=packaging,src=/,target=/run/packaging \
282303 --mount=type=bind,from=base-penultimate,src=/,target=/run/target <<EORUN
283304set -xeuo pipefail
284305
285- allow_missing_verity=false
306+ allow_missing_verity=()
286307
287308if [[ $filesystem == "xfs" ]]; then
288- allow_missing_verity=true
309+ allow_missing_verity=(--allow-missing-verity)
289310fi
290311
291312if test "${boot_type}" = "uki" ; then
292- /run/packaging/seal-uki /run/target /out /run/secrets $allow_missing_verity $seal_state
313+ kver=$(cat "/run/base-penultimate-src/var/kernel_ver" )
314+
315+ /run/packaging/seal-uki \
316+ --target /run/target \
317+ --output /out \
318+ --secrets /run/secrets \
319+ "${allow_missing_verity[@]}" \
320+ --kernel "/run/base-penultimate-src/usr/lib/modules/$kver/vmlinuz" \
321+ --kver "$kver" \
322+ --initramfs "/run/base-penultimate-src/usr/lib/modules/$kver/initramfs.img" \
323+ --seal-state $seal_state
293324fi
294325EORUN
295326
@@ -299,11 +330,13 @@ ARG variant
299330ARG boot_type
300331# Copy the sealed UKI and finalize the image (remove raw kernel, create symlinks)
301332RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
333+ --mount=type=bind,from=base-penultimate-source,src=/,target=/run/base-penultimate-src \
302334 --mount=type=bind,from=packaging,src=/,target=/run/packaging \
303335 --mount=type=bind,from=sealed-uki,src=/,target=/run/sealed-uki <<EORUN
304336set -xeuo pipefail
305337if test "${boot_type}" = "uki" ; then
306- /run/packaging/finalize-uki /run/sealed-uki/out
338+ kver=$(cat "/run/base-penultimate-src/var/kernel_ver" )
339+ /run/packaging/finalize-uki /run/sealed-uki/out "$kver"
307340fi
308341EORUN
309342# And finally, test our linting
0 commit comments