From f8e40e26a92a8ba26181507e89ff0c8a0ff9f596 Mon Sep 17 00:00:00 2001 From: Alexandre CATTEAU Date: Thu, 15 Aug 2024 17:15:48 +0200 Subject: [PATCH] Add support for systemd-ukify --- README.md | 1 + build-uki.sh | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9315522..af76489 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ The auto-update of this script should be disabled! Make sure to create `.disable ### Dependencies Make sure that: +* if running Ubuntu 24.04+, Linux Mint 22+ or Debian 13+, `systemd-ukify` is installed * `binutils`, `efibootmgr` and `systemd-boot-efi` packages are installed * you [install](https://wiki.archlinux.org/title/Unified_kernel_image#Directly_from_UEFI) the UKI to your EFI configuration diff --git a/build-uki.sh b/build-uki.sh index 18131b6..650e20e 100755 --- a/build-uki.sh +++ b/build-uki.sh @@ -11,12 +11,19 @@ else fi # Build UKI -$sudo objcopy \ - --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ - --add-section .cmdline="/etc/kernel/cmdline" --change-section-vma .cmdline=0x30000 \ - --add-section .linux="$path_to_vmlinuz_link/vmlinuz" --change-section-vma .linux=0x40000 \ - --add-section .initrd="$path_to_vmlinuz_link/initrd.img" --change-section-vma .initrd=0x3000000 \ - /usr/lib/systemd/boot/efi/linuxx64.efi.stub $path_to_uki +if [ -x /usr/bin/ukify ]; then + echo "Building UKI using systemd-ukify..." + $sudo ukify build --linux $path_to_vmlinuz_link/vmlinuz --initrd $path_to_vmlinuz_link/initrd.img \ + --cmdline @/etc/kernel/cmdline --output $path_to_uki +else + echo "Building UKI using objcopy..." + $sudo objcopy \ + --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ + --add-section .cmdline="/etc/kernel/cmdline" --change-section-vma .cmdline=0x30000 \ + --add-section .linux="$path_to_vmlinuz_link/vmlinuz" --change-section-vma .linux=0x40000 \ + --add-section .initrd="$path_to_vmlinuz_link/initrd.img" --change-section-vma .initrd=0x3000000 \ + /usr/lib/systemd/boot/efi/linuxx64.efi.stub $path_to_uki +fi # Sign UKI if [[ -v secureboot_enabled ]] && [[ $secureboot_enabled = "yes" ]]; then