From d64d9d2249e68e8e6d2e88f25b33f849f7e446d7 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 2 Sep 2020 14:17:26 +0000 Subject: [PATCH] create_disk: Use bootupd to install uefi if configured See https://github.com/coreos/bootupd and https://github.com/coreos/fedora-coreos-tracker/issues/510 Basically in order to handle *updates*, bootupd also takes care of installation. For example this also generates a JSON file with the versions. In order to sanely "ratchet" this change, only use bootupd if we find the ostree deployment is using it. --- src/create_disk.sh | 28 ++++++++++++++++++++++------ src/vmdeps.txt | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/create_disk.sh b/src/create_disk.sh index 2823c24d5f..c043ce918e 100755 --- a/src/create_disk.sh +++ b/src/create_disk.sh @@ -326,8 +326,7 @@ fi # be overridden below bootloader_backend=none -# Helper to install UEFI on supported architectures -install_uefi() { +install_uefi_without_bootupd() { # See also https://github.com/ostreedev/ostree/pull/1873#issuecomment-524439883 # In the future it'd be better to get this stuff out of the OSTree commit and # change our build process to download+extract it separately. @@ -352,6 +351,22 @@ install_uefi() { ) done + install_uefi_grub_cfg +} + +install_uefi() { + if test -d ${deploy_root}/usr/lib/bootupd/updates; then + # https://github.com/coreos/fedora-coreos-tracker/issues/510 + # See also https://github.com/ostreedev/ostree/pull/1873#issuecomment-524439883 + /usr/libexec/bootupd install --src-root=${deploy_root} ${rootfs} + else + install_uefi_without_bootupd + fi + # We have a "static" grub config file that basically configures grub to look + # in the partition labeled "boot". + local target_efi="$rootfs/boot/efi" + local grubefi=$(find "${target_efi}/EFI/" -maxdepth 1 -type d | grep -v BOOT) + local vendor_id="${grubefi##*/}" local vendordir="${target_efi}/EFI/${vendor_id}" mkdir -p "${vendordir}" cat > ${vendordir}/grub.cfg << 'EOF' @@ -360,8 +375,10 @@ set prefix=($prefix) configfile $prefix/grub2/grub.cfg boot EOF +} - # copy the grub config and any other files we might need +# copy the grub config and any other files we might need +install_grub_cfg() { mkdir -p $rootfs/boot/grub2 cp -v $grub_script $rootfs/boot/grub2/grub.cfg } @@ -379,6 +396,7 @@ x86_64) --boot-directory $rootfs/boot \ $disk fi + install_grub_cfg ;; aarch64) # Our aarch64 is UEFI only. @@ -387,9 +405,7 @@ aarch64) ppc64le) # to populate PReP Boot, i.e. support pseries grub2-install --target=powerpc-ieee1275 --boot-directory $rootfs/boot --no-nvram "${disk}${PREPPN}" - mkdir -p $rootfs/boot/grub2 - # copy the grub config and any other files we might need - cp $grub_script $rootfs/boot/grub2/grub.cfg + install_grub_cfg ;; s390x) bootloader_backend=zipl diff --git a/src/vmdeps.txt b/src/vmdeps.txt index 60a4fe8e01..b94f777060 100644 --- a/src/vmdeps.txt +++ b/src/vmdeps.txt @@ -24,6 +24,8 @@ python3 python3-gobject-base buildah podman skopeo iptables iptables-libs # luks cryptsetup +# How we install/update bootloaders +bootupd # filesystems/storage gdisk xfsprogs e2fsprogs dosfstools btrfs-progs