From 8a891ae4d547f1181a8e6a91063761a7bfb314d1 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 20 Sep 2023 16:49:39 -0400 Subject: [PATCH] create_disk: Add `bootupd-epoch = 0|1` This uses the new https://github.com/coreos/bootupd/ 0.2.11 release if `bootupd-epoch = "1"` in `image.yaml`. --- src/create_disk.sh | 85 +++++++++++++++++++++++++++++------------- src/image-default.yaml | 4 ++ 2 files changed, 63 insertions(+), 26 deletions(-) diff --git a/src/create_disk.sh b/src/create_disk.sh index 8ffa798821..15f04eac59 100755 --- a/src/create_disk.sh +++ b/src/create_disk.sh @@ -120,6 +120,7 @@ rootfs_args=$(getconfig_def "rootfs-args" "") bootfs=$(getconfig "bootfs") composefs=$(getconfig_def "composefs" "") grub_script=$(getconfig "grub-script") +bootupd_epoch=$(getconfig "bootupd-epoch") ostree_container=$(getconfig "ostree-container") commit=$(getconfig "ostree-commit") ref=$(getconfig "ostree-ref") @@ -396,11 +397,25 @@ cat > $rootfs/.coreos-aleph-version.json << EOF } EOF -install_uefi() { - # https://github.com/coreos/fedora-coreos-tracker/issues/510 - # See also https://github.com/ostreedev/ostree/pull/1873#issuecomment-524439883 +bootloader_bootupd_epoch_1() { + # For background on bootupd, see https://github.com/coreos/fedora-coreos-tracker/issues/510 + # This requires bootupd 0.2.11 in the target system + bootupd_args=() + if [ "${x86_bios_bootloader}" = 1 ]; then + bootupd_args+=("--device=$disk") + fi + chroot_run /usr/bin/bootupctl backend install --src-root="${deploy_root}" "${bootupd_args[@]}" "${rootfs}" + inject_grub_uefi +} + +install_uefi_bootupd_epoch_0() { + # For background on bootupd, see https://github.com/coreos/fedora-coreos-tracker/issues/510 # Unshare mount ns to work around https://github.com/coreos/bootupd/issues/367 unshare -m /usr/bin/bootupctl backend install --src-root="${deploy_root}" "${rootfs}" + inject_grub_uefi +} + +inject_grub_uefi() { # We have a "static" grub config file that basically configures grub to look # in the RAID called "md-boot", if it exists, or the partition labeled "boot". local target_efi="$rootfs/boot/efi" @@ -472,32 +487,50 @@ generate_gpgkeys() { rm -rf "${tmp_home}" } +install_bootloader_nons390x_bootupd_epoch_0() { + case $arch in + x86_64) + install_uefi_bootupd_epoch_0 + if [ "${x86_bios_bootloader}" = 1 ]; then + # And BIOS grub in addition. See also + # https://github.com/coreos/fedora-coreos-tracker/issues/32 + # Install BIOS/PReP bootloader using the target system's grub2-install, + # see https://github.com/coreos/coreos-assembler/issues/3156 + chroot_run /sbin/grub2-install \ + --target i386-pc \ + --boot-directory $rootfs/boot \ + --modules mdraid1x \ + "$disk" + fi + ;; + aarch64) + # Our aarch64 is UEFI only. + install_uefi_bootupd_epoch_0 + ;; + ppc64le) + # to populate PReP Boot, i.e. support pseries + chroot_run /sbin/grub2-install --target=powerpc-ieee1275 --boot-directory $rootfs/boot --no-nvram "${disk}${PREPPN}" + install_grub_cfg + ;; + *) "unhandled arch $arch 1>&2"; exit 1 + ;; + esac +} + # Other arch-specific bootloader changes # shellcheck disable=SC2031 case "$arch" in -x86_64) - # UEFI - install_uefi - if [ "${x86_bios_bootloader}" = 1 ]; then - # And BIOS grub in addition. See also - # https://github.com/coreos/fedora-coreos-tracker/issues/32 - # Install BIOS/PReP bootloader using the target system's grub2-install, - # see https://github.com/coreos/coreos-assembler/issues/3156 - chroot_run /sbin/grub2-install \ - --target i386-pc \ - --boot-directory $rootfs/boot \ - --modules mdraid1x \ - "$disk" - fi - ;; -aarch64) - # Our aarch64 is UEFI only. - install_uefi - ;; -ppc64le) - # to populate PReP Boot, i.e. support pseries - chroot_run /sbin/grub2-install --target=powerpc-ieee1275 --boot-directory $rootfs/boot --no-nvram "${disk}${PREPPN}" - install_grub_cfg +x86_64|aarch64|ppc64le) + case "${bootupd_epoch}" in + 0) + install_bootloader_nons390x_bootupd_epoch_0 + ;; + 1) + install_via_bootupd + ;; + *) echo "Unhandled ${bootupd_epoch} 1>&2; exit 1" + ;; + esac ;; s390x) ostree config --repo $rootfs/ostree/repo set sysroot.bootloader zipl diff --git a/src/image-default.yaml b/src/image-default.yaml index a3e6556729..ad72fd1212 100644 --- a/src/image-default.yaml +++ b/src/image-default.yaml @@ -7,6 +7,10 @@ rootfs-args: "" # Set to "true" to enable composefs composefs: false +# - "0": The default, only needs a version of bootupd too old for anyone to *not* have it +# - "1": adds a hard requirement of bootupd 0.2.11 +bootupd-epoch: "0" + # Additional default kernel arguments injected into disk images extra-kargs: []