Skip to content

Commit affee1f

Browse files
authored
Merge pull request bootc-dev#536 from cgwalters/add-grub-configs
Import static grub configuration
2 parents f657663 + b849ca3 commit affee1f

5 files changed

Lines changed: 118 additions & 0 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ install: install-units
4444
ln -f ${DESTDIR}$(LIBEXECDIR)/bootupd ${DESTDIR}$(PREFIX)/bin/bootupctl
4545
install -d "${DESTDIR}$(PREFIX)/lib/systemd/system/multi-user.target.wants"
4646
ln -s ../bootupd.socket "${DESTDIR}$(PREFIX)/lib/systemd/system/multi-user.target.wants"
47+
48+
install-grub-static:
49+
install -D -t ${DESTDIR}$(PREFIX)/lib/bootupd/grub2-static src/grub2/*.cfg

contrib/packaging/bootupd.spec

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,21 @@ replace-with = "vendored-sources"
4444
directory = "vendor"
4545
EOF
4646

47+
%package grub2-static
48+
Summary: Static grub2 configuration files for CoreOS-alike systems
49+
50+
%description grub2-static
51+
This package includes static grub2 configuration files.
52+
53+
%files grub2-static
54+
%{_prefix}/lib/bootupd
55+
4756
%build
4857
cargo build --release
4958

5059
%install
5160
%make_install INSTALL="install -p -c"
61+
make install-grub-static DESTDIR=%{?buildroot} INSTALL="%{__install} -p"
5262

5363
%post -n %{crate}
5464
%systemd_post bootupd.service bootupd.socket

src/grub2/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Static GRUB configuration files
2+
3+
These static files were taken from https://github.com/coreos/coreos-assembler/blob/5824720ec3a9ec291532b23b349b6d8d8b2e9edd/src/grub.cfg

src/grub2/grub-static-efi.cfg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
if [ -e (md/md-boot) ]; then
2+
# The search command might pick a RAID component rather than the RAID,
3+
# since the /boot RAID currently uses superblock 1.0. See the comment in
4+
# the main grub.cfg.
5+
set prefix=md/md-boot
6+
else
7+
if [ -f ${config_directory}/bootuuid.cfg ]; then
8+
source ${config_directory}/bootuuid.cfg
9+
fi
10+
if [ -n "${BOOT_UUID}" ]; then
11+
search --fs-uuid "${BOOT_UUID}" --set prefix --no-floppy
12+
else
13+
search --label boot --set prefix --no-floppy
14+
fi
15+
fi
16+
set prefix=($prefix)/grub2
17+
configfile $prefix/grub.cfg
18+
boot
19+

src/grub2/grub-static.cfg

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# This file is copied from https://github.com/coreos/coreos-assembler/blob/main/src/grub.cfg
2+
# Changes:
3+
# - Dropped Ignition glue, that can be injected into platform.cfg
4+
set pager=1
5+
# petitboot doesn't support -e and doesn't support an empty path part
6+
if [ -d (md/md-boot)/grub2 ]; then
7+
# fcct currently creates /boot RAID with superblock 1.0, which allows
8+
# component partitions to be read directly as filesystems. This is
9+
# necessary because transposefs doesn't yet rerun grub2-install on BIOS,
10+
# so GRUB still expects /boot to be a partition on the first disk.
11+
#
12+
# There are two consequences:
13+
# 1. On BIOS and UEFI, the search command might pick an individual RAID
14+
# component, but we want it to use the full RAID in case there are bad
15+
# sectors etc. The undocumented --hint option is supposed to support
16+
# this sort of override, but it doesn't seem to work, so we set $boot
17+
# directly.
18+
# 2. On BIOS, the "normal" module has already been loaded from an
19+
# individual RAID component, and $prefix still points there. We want
20+
# future module loads to come from the RAID, so we reset $prefix.
21+
# (On UEFI, the stub grub.cfg has already set $prefix properly.)
22+
set boot=md/md-boot
23+
set prefix=($boot)/grub2
24+
else
25+
if [ -f ${config_directory}/bootuuid.cfg ]; then
26+
source ${config_directory}/bootuuid.cfg
27+
fi
28+
if [ -n "${BOOT_UUID}" ]; then
29+
search --fs-uuid "${BOOT_UUID}" --set boot --no-floppy
30+
else
31+
search --label boot --set boot --no-floppy
32+
fi
33+
fi
34+
set root=$boot
35+
36+
if [ -f ${config_directory}/grubenv ]; then
37+
load_env -f ${config_directory}/grubenv
38+
elif [ -s $prefix/grubenv ]; then
39+
load_env
40+
fi
41+
42+
if [ x"${feature_menuentry_id}" = xy ]; then
43+
menuentry_id_option="--id"
44+
else
45+
menuentry_id_option=""
46+
fi
47+
48+
function load_video {
49+
if [ x$feature_all_video_module = xy ]; then
50+
insmod all_video
51+
else
52+
insmod efi_gop
53+
insmod efi_uga
54+
insmod ieee1275_fb
55+
insmod vbe
56+
insmod vga
57+
insmod video_bochs
58+
insmod video_cirrus
59+
fi
60+
}
61+
62+
# tracker: https://github.com/coreos/fedora-coreos-tracker/issues/805
63+
if [ -f $prefix/platform.cfg ]; then
64+
source $prefix/platform.cfg
65+
fi
66+
67+
if [ x$feature_timeout_style = xy ] ; then
68+
set timeout_style=menu
69+
set timeout=1
70+
# Fallback normal timeout code in case the timeout_style feature is
71+
# unavailable.
72+
else
73+
set timeout=1
74+
fi
75+
76+
# Import user defined configuration
77+
# tracker: https://github.com/coreos/fedora-coreos-tracker/issues/805
78+
if [ -f $prefix/user.cfg ]; then
79+
source $prefix/user.cfg
80+
fi
81+
82+
blscfg
83+

0 commit comments

Comments
 (0)