Commit dfa67141 authored by Anton Midyukov's avatar Anton Midyukov

grub: Use common grub.cfg for grub-pc and grub-efi

parent aa12c024
...@@ -4,6 +4,7 @@ insmod minicmd ...@@ -4,6 +4,7 @@ insmod minicmd
insmod normal insmod normal
insmod test insmod test
set timeout=@timeout@ set timeout=@timeout@
if [ "$grub_platform" = "efi" ]; then set EFI_BOOTARGS='@efi_bootargs@'; fi
if [ "$grub_platform" = "efi" -a "$grub_cpu" = "x86_64" ]; then if [ "$grub_platform" = "efi" -a "$grub_cpu" = "x86_64" ]; then
set linux_suffix='efi' set linux_suffix='efi'
fi fi
......
...@@ -3,7 +3,7 @@ default='linux' ...@@ -3,7 +3,7 @@ default='linux'
menuentry $"Install "'@distro@' --hotkey 'i' --id 'linux' { menuentry $"Install "'@distro@' --hotkey 'i' --id 'linux' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..." echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@ @efi_bootargs@ lang=$lang linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"VNC install "'@distro@'$" (edit to set server IP address)" --id 'vncconnect' { menuentry $"VNC install "'@distro@'$" (edit to set server IP address)" --id 'vncconnect' {
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ @efi_bootargs@ headless no_alt_virt_keyboard vncconnect=IP lang=$lang linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ $EFI_BOOTARGS headless no_alt_virt_keyboard vncconnect=IP lang=$lang
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"VNC install "'@distro@'$" (edit to set password and connect here)" --id 'vncpasswd' { menuentry $"VNC install "'@distro@'$" (edit to set password and connect here)" --id 'vncpasswd' {
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ @efi_bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD lang=$lang linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ $EFI_BOOTARGS headless no_alt_virt_keyboard vncpassword=VNCPWD lang=$lang
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"LiveCD (no hard disk needed)" --id 'live' { menuentry $"LiveCD (no hard disk needed)" --id 'live' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..." echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@ @efi_bootargs@ lang=$lang linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
......
menuentry $"LiveCD with sessions support" --id 'session' { menuentry $"LiveCD with sessions support" --id 'session' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..." echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@ @efi_bootargs@ lang=$lang linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@ $EFI_BOOTARGS lang=$lang
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"Rescue LiveCD" --id 'rescue' { menuentry $"Rescue LiveCD" --id 'rescue' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..." echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ @efi_bootargs@ linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ $EFI_BOOTARGS
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"Rescue with sessions support" --id 'rescue_session' { menuentry $"Rescue with sessions support" --id 'rescue_session' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..." echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ @efi_bootargs@ live_rw linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ $EFI_BOOTARGS live_rw
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"Forensic mode (leave disks alone)" --id 'rescue_forensic' { menuentry $"Forensic mode (leave disks alone)" --id 'rescue_forensic' {
echo $"Loading Linux vmlinuz$KFLAVOUR ..." echo $"Loading Linux vmlinuz$KFLAVOUR ..."
linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ @efi_bootargs@ max_loop=16 forensic hash=@rescue_hash@ linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ $EFI_BOOTARGS max_loop=16 forensic hash=@rescue_hash@
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full.cz initrd$linux_suffix @boot_path@/full.cz
} }
menuentry $"Rescue with remote SSH access (DHCP)" --id 'rescue_remote' { menuentry $"Rescue with remote SSH access (DHCP)" --id 'rescue_remote' {
linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ @efi_bootargs@ max_loop=16 ip=dhcp port=22 rootpw=AUTO hash=@rescue_hash@ linux$linux_suffix @boot_path@/vmlinuz$KFLAVOUR changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ $EFI_BOOTARGS max_loop=16 ip=dhcp port=22 rootpw=AUTO hash=@rescue_hash@
echo $"Loading initial ramdisk ..." echo $"Loading initial ramdisk ..."
initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz initrd$linux_suffix @boot_path@/full$KFLAVOUR.cz
} }
menuentry $"Check this media for defects" --id 'mediachk' { menuentry $"Check this media for defects" --id 'mediachk' {
linux$linux_suffix @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@ @efi_bootargs@ linux$linux_suffix @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@ $EFI_BOOTARGS
initrd$linux_suffix @boot_path@/full.cz initrd$linux_suffix @boot_path@/full.cz
} }
if [ "$grub_platform" = "efi" ]; then
menuentry $"Memory Test" --id 'memtest' {
chainloader /EFI/tools/efi-shell.efi
}
fi
...@@ -16,6 +16,7 @@ use/grub/ui/%: use/grub ...@@ -16,6 +16,7 @@ use/grub/ui/%: use/grub
@$(call set,GRUB_UI,$*) @$(call set,GRUB_UI,$*)
@if [ "$*" == gfxboot ]; then \ @if [ "$*" == gfxboot ]; then \
$(call add,STAGE1_BRANDING,bootloader); \ $(call add,STAGE1_BRANDING,bootloader); \
$(call add,STAGE1_PACKAGES,grub-common); \
fi fi
use/grub/%.cfg: use/grub use/grub/%.cfg: use/grub
......
...@@ -73,12 +73,12 @@ distro: bootargs ...@@ -73,12 +73,12 @@ distro: bootargs
# pass over additional parameters, if any # pass over additional parameters, if any
bootargs: clean bootargs: clean
@if [ -n "$(EFI_BOOTARGS)" ]; then \ @if [ -n "$(EFI_BOOTARGS)" ]; then \
echo "$(EFI_BOOTARGS)" > $(DSTDIR)/EFI_BOOTARGS; \ sed -i "s,@efi_bootargs@,$(EFI_BOOTARGS)," $(DSTCFGS); \
fi fi; \
sed -i "s,@efi_bootargs@,," $(DSTCFGS)
@if [ -n "$(STAGE2_BOOTARGS)" ]; then \ @if [ -n "$(STAGE2_BOOTARGS)" ]; then \
sed -i "s,$(STAGE2_BOOTARGS),," $(DSTCFGS); \
sed -i "s,@bootargs@,$(STAGE2_BOOTARGS)," $(DSTCFGS); \ sed -i "s,@bootargs@,$(STAGE2_BOOTARGS)," $(DSTCFGS); \
[ -f $(DSTDIR)/EFI_BOOTARGS ] && \
sed -i "s/$(STAGE2_BOOTARGS)//" $(DSTDIR)/EFI_BOOTARGS; \
fi; \ fi; \
sed -i "s,@bootargs@,," $(DSTCFGS) sed -i "s,@bootargs@,," $(DSTCFGS)
@if [ -n "$(RESCUE_BOOTARGS)" ]; then \ @if [ -n "$(RESCUE_BOOTARGS)" ]; then \
......
#!/bin/sh #!/bin/sh
# postprocess isolinux configuration # postprocess grub configuration
# when the image sizes are finally known # when the image sizes are finally known
# NB: install2_size, live_size, rescue_size get defined here # NB: install2_size, live_size, rescue_size get defined here
cd "$WORKDIR" cd "$WORKDIR"
cfg='boot/grub/grub.cfg'
[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0 [ -f "$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 # apply size census while looking for potential squashfs images
find -maxdepth 1 -type f -size +1M \ find -maxdepth 1 -type f -size +1M \
| sed 's,^\./,,' \ | sed 's,^\./,,' \
| while read image; do | while read image; do
size="$[ $(stat -c%s "$image") / 1024 + 1 ]" size="$[ $(stat -c%s "$image") / 1024 + 1 ]"
sed -i "s,@${image}_size@,$size," $cfgs sed -i "s,@${image}_size@,$size," $cfg
done done
#!/bin/sh #!/bin/sh
# postprocess isolinux configuration # postprocess grub configuration
# to add rescue image hash, if any # to add rescue image hash, if any
# (for propagator in forensic mode) # (for propagator in forensic mode)
cd "$WORKDIR" cd "$WORKDIR"
cfg='boot/grub/grub.cfg'
[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0 [ -f "$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 \ find -maxdepth 1 -type f -name rescue \
| while read image; do | while read image; do
rescue_hash="$(sha256sum -b "$image" | cut -f1 -d' ')" rescue_hash="$(sha256sum -b "$image" | cut -f1 -d' ')"
sed -i "s,@rescue_hash@,$rescue_hash," $cfgs sed -i "s,@rescue_hash@,$rescue_hash," $cfg
done done
...@@ -3,16 +3,8 @@ ...@@ -3,16 +3,8 @@
# copy modules; see also this feature's generate.mk # copy modules; see also this feature's generate.mk
CFG="$WORKDIR/boot/grub/grub.cfg" CFG="$WORKDIR/boot/grub/grub.cfg"
CFG_EFI="$WORKDIR/EFI/BOOT/grub.cfg"
if [ "$GLOBAL_EFI_BOOTLOADER" != 'grub-efi' ]; then
if [ -n "$GLOBAL_EFI_BOOTLOADER" -a ! "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
rm -fr "$WORKDIR/boot"
exit 0
fi
if [ -z "$GLOBAL_EFI_BOOTLOADER" ]; then
case "$GLOBAL_BOOTLOADER" in case "$GLOBAL_BOOTLOADER" in
ieee1275boot|grubpcboot) ;; ieee1275boot|grubpcboot) ;;
*) rm -fr "$WORKDIR/boot" *) rm -fr "$WORKDIR/boot"
...@@ -29,17 +21,7 @@ if [ -n "${GRUB_FILES% }" ]; then ...@@ -29,17 +21,7 @@ if [ -n "${GRUB_FILES% }" ]; then
fi fi
# number ordering sponsored by shell's pathname expansion # number ordering sponsored by shell's pathname expansion
case "$GLOBAL_BOOTLOADER" in grep -hv '^#' $(find .in/*.cfg) > "$CFG"
ieee1275boot)
grep -hv '^#' $(find .in/*.cfg -not -name *_efi.cfg -not -name *_bios.cfg) > "$CFG" ;;
grubpcboot)
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 -not -name *_bios.cfg) > "$CFG_EFI"
fi
# there should be DEFAULT directive there (at least for alterator-netinst) # there should be DEFAULT directive there (at least for alterator-netinst)
default_change() { default_change() {
...@@ -65,30 +47,20 @@ if ! grep -i '^default' "$CFG"; then ...@@ -65,30 +47,20 @@ if ! grep -i '^default' "$CFG"; then
fi fi
} }
if [ -f "$CFG" ]; then default_change "$CFG"
default_change "$CFG"
sed -i 's,@boot_path@,/boot,g' "$CFG"
sed -i 's,@efi_bootargs@,,g' "$CFG"
fi
if [ -f .in/EFI_BOOTARGS ]; then case "$GLOBAL_BOOTLOADER" in
EFI_BOOTARGS=$(cat .in/EFI_BOOTARGS) ieee1275boot|grubpcboot)
fi BOOT_PATH=/boot;;
*)
BOOT_PATH=/EFI/BOOT;;
esac
if [ -f "$CFG_EFI" ]; then sed -i "s,@boot_path@,$BOOT_PATH,g" "$CFG"
default_change "$CFG_EFI"
sed -i 's,@boot_path@,/EFI/BOOT,g' "$CFG_EFI"
[ -n "$EFI_BOOTARGS" ] &&
sed -i "s,@efi_bootargs@,$EFI_BOOTARGS,g" "$CFG_EFI"
sed -i "s, @efi_bootargs@,,g" "$CFG_EFI"
fi
# snippets are not going into the actual image # snippets are not going into the actual image
if [ "$DEBUG" != 2 ]; then if [ "$DEBUG" != 2 ]; then
rm -r .in/ rm -r .in/
cd $WORKDIR
[ -f "$CFG" ] || rm -r boot/grub
[ ! $(ls -A boot/ | wc -l) -eq 0 ] || rm -r boot/
fi fi
# NB: there will be final macro expansion based on actual image sizes # NB: there will be final macro expansion based on actual image sizes
......
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