libreboot

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 8e6582b18989d7749158b6bad4b79e4245af09de
parent 818db48b4fa355255a87f76ae27f65b8fe1a7160
Author: Francis Rowe <info@gluglug.org.uk>
Date:   Sat,  2 Jan 2016 17:29:53 +0000

grub.cfg: simplify isolinux parsing to a single function

Diffstat:
resources/grub/config/menuentries/common.cfg | 61+++++++++++++++----------------------------------------------
1 file changed, 15 insertions(+), 46 deletions(-)

diff --git a/resources/grub/config/menuentries/common.cfg b/resources/grub/config/menuentries/common.cfg @@ -9,6 +9,16 @@ function switch_to_grub_config { fi done } +function parse_isolinux_config { + set root=${1} + for p in /isolinux /syslinux; do + if [ -f "${p}${p}.cfg" ]; then + syslinux_configfile -i ${p}${p}.cfg + elif [ -f "/boot${p}${p}.cfg" ]; then + syslinux_configfile -i /boot${p}${p}.cfg + fi + done +} menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { # GRUB handles (almost) every possible disk setup, but only the location of /boot is actually important, @@ -67,65 +77,24 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o menuentry 'Parse ISOLINUX menu (AHCI) [a]' --hotkey='a' { for i in 0 1; do # Check for filesystem on raw device without partition table (MBR/GPT), e.g. BTRFS or ZFS - set root=ahci${i} - for p in /isolinux /syslinux; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done + parse_isolinux_config ahci${i} # Look for partitions # GPT allows more than 4 partitions, /boot on /dev/sda7 is quite unlikely but still possible - for j in 0 1 2 3 4 5 6 7 8 9; do - set root="ahci${i},${j}" - for p in /isolinux /syslinux; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done - done + for j in 0 1 2 3 4 5 6 7 8 9; do parse_isolinux_config "ahci${i},${j}"; done done } menuentry 'Parse ISOLINUX menu (USB) [u]' --hotkey='u' { for i in 0 1; do # Check for filesystem on raw device without partition table (MBR/GPT), e.g. BTRFS or ZFS - set root=usb${i} - for p in /isolinux /syslinux; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done + parse_isolinux_config usb${i} # Look for partitions # GPT allows more than 4 partitions, /boot on /dev/sda7 is quite unlikely but still possible - for j in 0 1 2 3 4 5 6 7 8 9; do - set root=usb${i},${j} - for p in "/isolinux" "/syslinux"; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done - done + for j in 0 1 2 3 4 5 6 7 8 9; do parse_isolinux_config "usb${i},${j}"; done done } menuentry 'Parse ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { insmod ata - for x in ata0 ahci1; do - set root=${x} - for p in "/isolinux" "/syslinux"; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done - done + for x in ata0 ahci1; do parse_isolinux_config ${x}; done } menuentry 'Switch to grubtest.cfg [t]' --hotkey='t' { set root=cbfsdisk