Skip to content

Commit

Permalink
create_disk: Add bootupd-epoch = 0|1
Browse files Browse the repository at this point in the history
This uses the new https://github.com/coreos/bootupd/ 0.2.11 release
if `bootupd-epoch = "1"` in `image.yaml`.
  • Loading branch information
cgwalters committed Sep 20, 2023
1 parent 4479a8d commit 8a891ae
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 26 deletions.
85 changes: 59 additions & 26 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/image-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []

Expand Down

0 comments on commit 8a891ae

Please sign in to comment.