Skip to content

Commit ae5352a

Browse files
committed
create_disk: Add bootupd-epoch, hard require new bootupd
This hard requires - coreos/bootupd#543 - coreos/ignition#1728
1 parent 5824720 commit ae5352a

File tree

4 files changed

+23
-162
lines changed

4 files changed

+23
-162
lines changed

src/cosalib/cmdlib.py

-3
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@ def generate_image_json(srcfile):
397397
r = yaml.safe_load(open("/usr/lib/coreos-assembler/image-default.yaml"))
398398
for k, v in flatten_image_yaml(srcfile).items():
399399
r[k] = v
400-
# Serialize our default GRUB config
401-
with open("/usr/lib/coreos-assembler/grub.cfg") as f:
402-
r['grub-script'] = f.read()
403400
return r
404401

405402

src/create_disk.sh

+20-65
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ rootfs_args=$(getconfig_def "rootfs-args" "")
119119

120120
bootfs=$(getconfig "bootfs")
121121
composefs=$(getconfig_def "composefs" "")
122-
grub_script=$(getconfig "grub-script")
122+
bootupd_epoch=$(getconfig "bootupd-epoch")
123123
ostree_container=$(getconfig "ostree-container")
124124
commit=$(getconfig "ostree-commit")
125125
ref=$(getconfig "ostree-ref")
@@ -396,51 +396,10 @@ cat > $rootfs/.coreos-aleph-version.json << EOF
396396
}
397397
EOF
398398

399-
install_uefi() {
400-
# https://github.com/coreos/fedora-coreos-tracker/issues/510
401-
# See also https://github.com/ostreedev/ostree/pull/1873#issuecomment-524439883
402-
# Unshare mount ns to work around https://github.com/coreos/bootupd/issues/367
403-
unshare -m /usr/bin/bootupctl backend install --src-root="${deploy_root}" "${rootfs}"
404-
# We have a "static" grub config file that basically configures grub to look
405-
# in the RAID called "md-boot", if it exists, or the partition labeled "boot".
406-
local target_efi="$rootfs/boot/efi"
407-
local grubefi
408-
grubefi=$(find "${target_efi}/EFI/" -maxdepth 1 -type d | grep -v BOOT)
409-
local vendor_id="${grubefi##*/}"
410-
local vendordir="${target_efi}/EFI/${vendor_id}"
411-
mkdir -p "${vendordir}"
412-
cat > "${vendordir}/grub.cfg" << 'EOF'
413-
if [ -e (md/md-boot) ]; then
414-
# The search command might pick a RAID component rather than the RAID,
415-
# since the /boot RAID currently uses superblock 1.0. See the comment in
416-
# the main grub.cfg.
417-
set prefix=md/md-boot
418-
else
419-
if [ -f ${config_directory}/bootuuid.cfg ]; then
420-
source ${config_directory}/bootuuid.cfg
421-
fi
422-
if [ -n "${BOOT_UUID}" ]; then
423-
search --fs-uuid "${BOOT_UUID}" --set prefix --no-floppy
424-
else
425-
search --label boot --set prefix --no-floppy
426-
fi
427-
fi
428-
set prefix=($prefix)/grub2
429-
configfile $prefix/grub.cfg
430-
boot
431-
EOF
432-
install_grub_cfg
399+
bootloader_install_nons390x_bootupd_epoch_1() {
433400
}
434401

435-
# copy the grub config and any other files we might need
436-
install_grub_cfg() {
437-
# 0700 to match the RPM permissions which I think are mainly in case someone has
438-
# manually set a grub password
439-
mkdir -p $rootfs/boot/grub2
440-
chmod 0700 $rootfs/boot/grub2
441-
printf "%s\n" "$grub_script" | \
442-
sed -E 's@(^# CONSOLE-SETTINGS-START$)@\1'"${platform_grub_cmds:+\\n${platform_grub_cmds}}"'@' \
443-
> $rootfs/boot/grub2/grub.cfg
402+
install_platforms_json() {
444403
# Copy platforms table if it's non-empty for this arch
445404
# shellcheck disable=SC2031
446405
if jq -e ".$arch" < "$platforms_json" > /dev/null; then
@@ -472,32 +431,28 @@ generate_gpgkeys() {
472431
rm -rf "${tmp_home}"
473432
}
474433

434+
# Hard require epoch 1, but leave space for future versions
435+
case "${bootupd_epoch}" in
436+
1)
437+
;;
438+
*) echo "Unhandled ${bootupd_epoch} 1>&2; exit 1"
439+
;;
440+
esac
441+
475442
# Other arch-specific bootloader changes
476443
# shellcheck disable=SC2031
477444
case "$arch" in
478-
x86_64)
479-
# UEFI
480-
install_uefi
445+
x86_64|aarch64|ppc64le)
446+
# For background on bootupd, see https://github.com/coreos/fedora-coreos-tracker/issues/510
447+
# This requires bootupd 0.2.11 in the target system, and handles both BIOS and UEFI for x86_64 for example.
448+
bootupd_args=()
481449
if [ "${x86_bios_bootloader}" = 1 ]; then
482-
# And BIOS grub in addition. See also
483-
# https://github.com/coreos/fedora-coreos-tracker/issues/32
484-
# Install BIOS/PReP bootloader using the target system's grub2-install,
485-
# see https://github.com/coreos/coreos-assembler/issues/3156
486-
chroot_run /sbin/grub2-install \
487-
--target i386-pc \
488-
--boot-directory $rootfs/boot \
489-
--modules mdraid1x \
490-
"$disk"
450+
bootupd_args+=("--device=$disk")
451+
fi
452+
chroot_run env /usr/bin/bootupctl backend install --with-static-configs --src-root="${deploy_root}" "${bootupd_args[@]}" "${rootfs}"
453+
if test -n "${platform_grub_cmds}"; then
454+
echo "${platform_grub_cmds}" > $rootfs/boot/grub2/platform01.cfg
491455
fi
492-
;;
493-
aarch64)
494-
# Our aarch64 is UEFI only.
495-
install_uefi
496-
;;
497-
ppc64le)
498-
# to populate PReP Boot, i.e. support pseries
499-
chroot_run /sbin/grub2-install --target=powerpc-ieee1275 --boot-directory $rootfs/boot --no-nvram "${disk}${PREPPN}"
500-
install_grub_cfg
501456
;;
502457
s390x)
503458
ostree config --repo $rootfs/ostree/repo set sysroot.bootloader zipl

src/grub.cfg

-94
This file was deleted.

src/image-default.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ rootfs-args: ""
77
# Set to "true" to enable composefs
88
composefs: false
99

10+
# - "1": adds a hard requirement of bootupd 0.2.X and updated ignition
11+
bootupd-epoch: "1"
12+
1013
# Additional default kernel arguments injected into disk images
1114
extra-kargs: []
1215

0 commit comments

Comments
 (0)