diff --git a/src/create_disk.sh b/src/create_disk.sh index 8ffa798821..d67a7844ec 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,34 @@ 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_install_nons390x_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, and handles both BIOS and UEFI for x86_64 for example. + 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}" + case "${arch}" in + x86_64|aarch64) + inject_grub_uefi + ;; + ppc64le) + install_grub_cfg + ;; + *) + echo "Unhandled arch $arch"; exit 1 + esac +} + +bootupd_install_uefi_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 +496,50 @@ generate_gpgkeys() { rm -rf "${tmp_home}" } +bootloader_install_nons390x_bootupd_epoch_0() { + case $arch in + x86_64) + bootupd_install_uefi_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. + bootupd_install_uefi_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) + bootloader_install_nons390x_bootupd_epoch_0 + ;; + 1) + bootloader_install_nons390x_bootupd_epoch_1 + ;; + *) 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: []