From d0d82cd6a11814b1a59b39154207c7552fac3434 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Thu, 27 Dec 2018 21:43:14 +0000 Subject: [PATCH] Preliminary support for systemd-boot bootloader. This adds preliminary support for systemd-boot using the kernel-install tool. It's dependent upon systemd pull request #11281 (https://github.com/systemd/systemd/pull/11281) to work properly with initrd files. It's a little ugly because it wipes (to avoid double copying files) it wipes out the ones that genkernel has already copied to /boot, since genkernel copies those in multiple different places in the code. Ideally those would be refactored and delayed until everything had built successfully, but that was a large refactoring, so for now this adds support as is. Signed-off-by: Mike Auty --- gen_bootloader.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gen_bootloader.sh b/gen_bootloader.sh index 28fa2920..aadad60a 100755 --- a/gen_bootloader.sh +++ b/gen_bootloader.sh @@ -8,12 +8,36 @@ set_bootloader() { grub2) set_bootloader_grub2 ;; + systemd-boot) + set_bootloader_systemd + ;; *) print_warning "Bootloader ${BOOTLOADER} is not currently supported" ;; esac } +set_bootloader_systemd() { + + if [[ ! -x `which kernel-install` ]]; then + gen_die "Unable to locate kernel-install, is systemd installed?" + fi + + # Clear out the mistakenly installed copies, since kernel-install copies its own versions over + # We do this first, to prevent people thinking they have enough free space but needing twice the amount + KERNEL_IMAGE=$(find_kernel_binary ${KERNEL_BINARY_OVERRIDE:-${KERNEL_BINARY}}) + rm "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}" + INITRD_FILE="" + if [[ -f "${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV}" ]]; then + rm "${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV}" + INITRD_FILE="${TMPDIR}/initramfs-${KV}" + fi + + # Do the call + echo "Executing: kernel-install add $KV \"${KERNEL_IMAGE}\" \"${INITRD_FILE}\"" + kernel-install add $KV "${KERNEL_IMAGE}" "${INITRD_FILE}" +} + set_bootloader_read_fstab() { local ROOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "/" ) { print $1; exit }' /etc/fstab) local BOOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "'${BOOTDIR}'") { print $1; exit }' /etc/fstab)