-
Notifications
You must be signed in to change notification settings - Fork 167
build-sys: Rework sealing to be one build step #1898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,5 +7,3 @@ git-core | |
| jq | ||
| # We now always build a package in the container build | ||
| rpm-build | ||
| # Used for signing | ||
| sbsigntools | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||
| # Finalize UKI installation: copy to /boot, remove raw kernel/initramfs, create symlinks | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # For sealed UKI images, the kernel and initramfs are embedded inside the signed | ||||||||||||||||||||||||||
| # UKI PE binary. We remove the standalone vmlinuz/initramfs.img to: | ||||||||||||||||||||||||||
| # - Avoid duplication (they're inside the UKI) | ||||||||||||||||||||||||||
| # - Ensure tools use the UKI path | ||||||||||||||||||||||||||
| # - Make it clear this is a UKI-only boot configuration | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # NOTE: The old Dockerfile.cfsuki had a bug where the final-final stage started | ||||||||||||||||||||||||||
| # FROM base instead of FROM final, then only copied /boot. This meant the | ||||||||||||||||||||||||||
| # vmlinuz/initramfs removal in the final stage was lost. Running this script | ||||||||||||||||||||||||||
| # in the actual final image stage fixes that issue. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # IMPORTANT: bcvk needs to be updated to find .efi files inside kernel version | ||||||||||||||||||||||||||
| # subdirectories (e.g., /usr/lib/modules/<kver>/<kver>.efi) rather than at the | ||||||||||||||||||||||||||
| # top level of /usr/lib/modules/. See https://github.com/bootc-dev/bcvk/pull/144 | ||||||||||||||||||||||||||
| set -xeuo pipefail | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Path to directory containing the generated UKI | ||||||||||||||||||||||||||
| uki_src=$1 | ||||||||||||||||||||||||||
| shift | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Find the kernel version from the current system | ||||||||||||||||||||||||||
| kver=$(cd /usr/lib/modules && echo *) | ||||||||||||||||||||||||||
| if [ -z "$kver" ] || [ "$kver" = "*" ]; then | ||||||||||||||||||||||||||
| echo "Error: No kernel found" >&2 | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
Comment on lines
+25
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The command
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Create the EFI directory structure | ||||||||||||||||||||||||||
| mkdir -p /boot/EFI/Linux | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # The UKI in /boot is outside the composefs-verified tree, which is fine | ||||||||||||||||||||||||||
| # because the UKI itself is signed and verified by Secure Boot | ||||||||||||||||||||||||||
| target=/boot/EFI/Linux/${kver}.efi | ||||||||||||||||||||||||||
| cp "${uki_src}/${kver}.efi" "${target}" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Remove the raw kernel and initramfs since we're using a UKI now. | ||||||||||||||||||||||||||
| # NOTE: We intentionally keep these for now until bcvk is updated to extract | ||||||||||||||||||||||||||
| # kernel/initramfs from UKIs in subdirectories. Once bcvk PR #144 is fixed | ||||||||||||||||||||||||||
| # to look for .efi files in /usr/lib/modules/<kver>/, we can uncomment this. | ||||||||||||||||||||||||||
| # rm -v "/usr/lib/modules/${kver}/vmlinuz" "/usr/lib/modules/${kver}/initramfs.img" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # NOTE: We used to create a symlink from /usr/lib/modules/${kver}/${kver}.efi to the UKI | ||||||||||||||||||||||||||
| # for tooling compatibility. However, composefs-boot's find_uki_components() doesn't | ||||||||||||||||||||||||||
| # handle symlinks correctly and fails with "is not a regular file". The UKI is already | ||||||||||||||||||||||||||
| # found in /boot/EFI/Linux/, so the symlink is not needed. | ||||||||||||||||||||||||||
| # See: https://github.com/containers/composefs-rs/issues/XXX | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/bash | ||
| set -xeuo pipefail | ||
| . /usr/lib/os-release | ||
| case "${ID}${ID_LIKE:-}" in | ||
| *centos*|*rhel*) | ||
| # Enable EPEL for sbsigntools | ||
| dnf -y install epel-release | ||
| ;; | ||
| esac | ||
| dnf -y install systemd-ukify sbsigntools | ||
| # And in the sealing case, we're going to inject and sign systemd-boot | ||
| # into the target image. | ||
| mkdir -p /out | ||
| cd /out | ||
| dnf -y download systemd-boot-unsigned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of
lswith a glob to find thesystemd-bootEFI binary can be fragile. If the glob matches more than one file, thesdboot_unsignedvariable will contain a multi-line string, which could causesbsignto behave unexpectedly. It's safer to ensure exactly one file is found.