Commit 86f52450 authored by Anton Midyukov's avatar Anton Midyukov

grub: generate grub.cfg for grub-efi and ieee1275boot

These changes allow you to create two independent config at the same time or separately. It will be possible to add support for grub-pc in the future.
parent 80e83624
default='linux'
menuentry 'Install ALT @relname@' --hotkey 'i' --id 'linux' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'Install ALT @relname@ (headless with DHCP+VNC client) (edit to set server IP address)' --id 'vncconnect' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'Install ALT @relname@ (headless with DHCP+VNC) (password VNCPWD)' --id 'vncpasswd' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'LiveCD (no hard disk needed)' --id 'live' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'LiveCD with sessions support' --id 'session' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'Rescue LiveCD' --id 'rescue' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'Rescue with sessions support' --id 'rescue_session' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ live_rw
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ live_rw
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'Forensic mode (leave disks alone)' --id 'rescue_forensic' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ max_loop=16 forensic hash=@rescue_hash@
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ max_loop=16 forensic hash=@rescue_hash@
initrd$linux_suffix @boot_path@/full.cz
}
menuentry 'Check this media for defects' --id 'mediachk' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
linux$linux_suffix @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
initrd$linux_suffix @boot_path@/full.cz
}
......@@ -19,7 +19,7 @@ ifndef GRUB_DIRECT
GRUB_CFG := $(GRUB_CFG) $(SUBPROFILE_DIRS) defaults
endif
DSTDIR := $(BUILDDIR)/stage1/files/EFI/BOOT/.in
DSTDIR := $(BUILDDIR)/stage1/files/boot/grub/.in
DSTCFGS := $(DSTDIR)/*.cfg
# we can do GRUB_{CFG,MODULES,FILES}
......
......@@ -5,11 +5,11 @@
cd "$WORKDIR"
cfgs="$(find EFI/BOOT -name '*.cfg')"
[ -n "$cfgs" ] || {
echo "${0##*/}: did not find any config under EFI/BOOT " >&2
exit 1
}
[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0
cfgs=
[ ! -f boot/grub/grub.cfg ] || cfgs+='boot/grub/grub.cfg '
[ ! -f EFI/BOOT/grub.cfg ] || cfgs+='EFI/BOOT/grub.cfg'
# apply size census while looking for potential squashfs images
find -maxdepth 1 -type f -size +1M \
......
......@@ -5,10 +5,14 @@
cd "$WORKDIR"
grep -qs "@rescue_hash@" EFI/BOOT/*.cfg || exit 0
[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0
cfgs=
[ ! -f boot/grub/grub.cfg ] || cfgs+='boot/grub/grub.cfg '
[ ! -f EFI/BOOT/grub.cfg ] || cfgs+='EFI/BOOT/grub.cfg'
find -maxdepth 1 -type f -name rescue \
| while read image; do
rescue_hash="$(sha256sum -b "$image" | cut -f1 -d' ')"
sed -i "s,@rescue_hash@,$rescue_hash," EFI/BOOT/*.cfg
sed -i "s,@rescue_hash@,$rescue_hash," $cfgs
done
......@@ -2,17 +2,23 @@
# gather grub configuration from snippets;
# copy modules; see also this feature's generate.mk
CFG="grub.cfg"
CFG="$WORKDIR/boot/grub/grub.cfg"
CFG_EFI="$WORKDIR/EFI/BOOT/grub.cfg"
mkdir -p "$WORKDIR/EFI/BOOT"
cd "$WORKDIR/EFI/BOOT"
if [ -n "$GLOBAL_EFI_BOOTLOADER" -a ! "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
rm -fr "$WORKDIR/boot"
exit 0
fi
# validate just in case (see also stage1 Makefile)
case "$GLOBAL_BOOTLOADER" in
isolinux|syslinux|ieee1275boot|grubaa64boot|grubx86boot) ;;
*) echo "error: weird GLOBAL_BOOTLOADER: \`$GLOBAL_BOOTLOADER'" >&2;
exit 1;;
esac
if [ -z "$GLOBAL_EFI_BOOTLOADER" ]; then
case "$GLOBAL_BOOTLOADER" in
ieee1275boot) ;;
*) rm -fr "$WORKDIR/boot"
exit 0;;
esac
fi
cd "$WORKDIR/boot/grub"
# copy extra files, if any
GRUB_FILES="$(cat .in/grub.list)"
......@@ -21,21 +27,47 @@ if [ -n "${GRUB_FILES% }" ]; then
fi
# number ordering sponsored by shell's pathname expansion
grep -hv '^#' .in/[0-9][0-9]*.cfg > "$CFG"
case "$GLOBAL_BOOTLOADER" in
ieee1275boot)
grep -hv '^#' $(find .in/*.cfg -not -name *_efi.cfg) > "$CFG" ;;
esac
if [ "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
mkdir -p "$WORKDIR/EFI/BOOT"
grep -hv '^#' $(find .in/*.cfg) > "$CFG_EFI"
fi
# there should be DEFAULT directive there (at least for alterator-netinst)
if ! grep -i '^default' .in/[0-9][0-9]*.cfg; then
DEFAULT="$(grep -i '\-\-id ' .in/[0-9][0-9]*.cfg | head -1 | rev| cut -f2 -d' ' |rev)"
default_change() {
local CFG=$1
if ! grep -i '^default' "$CFG"; then
DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)"
if [ -n "$DEFAULT" ]; then
echo "default=$DEFAULT" >> "$CFG"
else
echo "error: no DEFAULT or UI directive and cannot guess" >&2
echo "error: no DEFAULT or UI directive and cannot guess for $CFG" >&2
exit 1
fi
fi
}
if [ -f "$CFG" ]; then
default_change "$CFG"
sed -i 's,@boot_path@,/boot,g' "$CFG"
fi
if [ -f "$CFG_EFI" ]; then
default_change "$CFG_EFI"
sed -i 's,@boot_path@,/EFI/BOOT,g' "$CFG_EFI"
fi
# snippets are not going into the actual image
if [ "$DEBUG" != 2 ]; then rm -r .in/; fi
if [ "$DEBUG" != 2 ]; then
rm -r .in/
cd $WORKDIR
[ -f "$CFG" ] || rm -r boot/grub
[ ! $(ls -A boot/ | wc -l) -eq 0 ] || rm -r boot/
fi
# NB: there will be final macro expansion based on actual image sizes
# done by features.in/grub/scripts.d/20-propagator-ramdisk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment