From 21394ebd6bec29dfda0931e7cc72ba1bfb9e1558 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Thu, 24 Dec 2015 18:04:59 +0100 Subject: Add themed GRUB2 configuration for UEFI boot. The GRUB2 theme is similar to the Syslinux theme used for BIOS boot. However, the GRUB menu also allows the user to select a timezone, whereas due to the limitations of syslinux, you'll have to edit the syslinux commandline to change your timezone there. --- make_slackware_live.sh | 119 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 99 insertions(+), 20 deletions(-) (limited to 'make_slackware_live.sh') diff --git a/make_slackware_live.sh b/make_slackware_live.sh index cd308fb..aaeec27 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -366,6 +366,11 @@ EOL cat <> ${MENUROOTDIR}/lang_${LANCOD}.cfg label $(cat ${LIVE_TOOLDIR}/languages |grep ",$SUBKBD," |cut -d, -f1) menu label $(cat ${LIVE_TOOLDIR}/languages |grep ",$SUBKBD," |cut -d, -f2) +EOL + if [ "$SUBKBD" = "$KBD" ]; then + echo " menu default" >> ${MENUROOTDIR}/lang_${LANCOD}.cfg + fi + cat <> ${MENUROOTDIR}/lang_${LANCOD}.cfg kernel /boot/generic append initrd=/boot/initrd.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 kbd=$KBD tz=$(cat ${LIVE_TOOLDIR}/languages |grep ",$SUBKBD," |cut -d, -f4) locale=$(cat ${LIVE_TOOLDIR}/languages |grep ",$SUBKBD," |cut -d, -f5) @@ -373,7 +378,6 @@ EOL done done - } # @@ -383,35 +387,109 @@ function gen_uefimenu() { GRUBDIR="$1" + # Generate the grub menu structure - many files because of the selection tree. # I expect the directory to exist... but you never know. mkdir -p ${GRUBDIR} - # Generate grub.cfg header: - cat < ${GRUBDIR}/grub.cfg -set default="0" -set timeout="30" -set hidden_timeout_quiet=false + # Initialize an empty keyboard, language and timezone selection menu: + rm -f ${GRUBDIR}/kbd.cfg + rm -f ${GRUBDIR}/lang.cfg + rm -f ${GRUBDIR}/tz.cfg + + # Generate main grub.cfg: + cat ${LIVE_TOOLDIR}/grub.tpl | sed \ + -e "s/@KBD@/us/g" \ + -e "s/@LANG@/us/g" \ + -e "s/@CONSFONT@/$CONSFONT/g" \ + -e "s/@DIRSUFFIX@/$DIRSUFFIX/g" \ + -e "s/@KVER@/$KVER/g" \ + -e "s/@LIVEMAIN@/$LIVEMAIN/g" \ + -e "s/@MEDIALABEL@/$MEDIALABEL/g" \ + -e "s/@LIVEDE@/$(echo $LIVEDE |sed 's/BASE//')/g" \ + -e "s/@SL_VERSION@/$SL_VERSION/g" \ + > ${GRUBDIR}/grub.cfg + + # Set a default keyboard selection: + cat < ${GRUBDIR}/kbd.cfg +# Keyboard selection: +set default = $sl_lang + +EOL + + # Set a default language selection: + cat < ${GRUBDIR}/lang.cfg +# Language selection: +set default = $sl_lang + +EOL -menuentry "Detect/boot any installed operating system" { - configfile "/EFI/BOOT/osdetect.cfg" + # Create the remainder of the selection menus: + for KBD in $(cat languages |grep -Ev "(^ *#|^$)" |cut -d, -f3) ; do + LANCOD=$(cat languages |grep ",$KBD," |cut -d, -f1) + LANDSC=$(cat languages |grep ",$KBD," |cut -d, -f2) + LANLOC=$(cat languages |grep ",$KBD," |cut -d, -f5) + # Add this entry to the keyboard selection menu: + cat <> ${GRUBDIR}/kbd.cfg +menuentry "${LANDSC}" { + set sl_kbd="$KBD" + set sl_lang="$LANDSC" + export sl_kbd + export sl_lang + configfile \$grubdir/grub.cfg } -EOT +EOL - for KBD in $(cat ${LIVE_TOOLDIR}/languages |grep -Ev "(^ *#|^$)" |cut -d, -f3) - do - LANDSC=$(cat ${LIVE_TOOLDIR}/languages |grep ",$KBD," |cut -d, -f2) - LANTZ=$(cat ${LIVE_TOOLDIR}/languages |grep ",$KBD," |cut -d, -f4) - LANLOC=$(cat ${LIVE_TOOLDIR}/languages |grep ",$KBD," |cut -d, -f5) - cat <> ${GRUBDIR}/grub.cfg -menuentry "Slackware${DIRSUFFIX} ${SL_VERSION} Live ($LANDSC)" { - linux /boot/generic load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 tz=${LANTZ} locale=${LANLOC} kbd=${KBD} - initrd /boot/initrd.img + # Add this entry to the language selection menu: + cat <> ${GRUBDIR}/lang.cfg +menuentry "${LANDSC}" { + set sl_locale="$LANLOC" + set sl_lang="$LANDSC" + export sl_locale + export sl_lang + configfile \$grubdir/grub.cfg } -EOT +EOL + done + # Create the timezone selection menu: + TZDIR="/usr/share/zoneinfo" + TZLIST=$(mktemp -t alientz.XXXXXX) + if [ ! -f $TZLIST ]; then + echo "*** Failed to create a temporary file!" + exit 1 + fi + # First, create a list of timezones: + # This code taken from Slackware script: + # source/a/glibc-zoneinfo/timezone-scripts/output-updated-timeconfig.sh + # Author: Patrick Volkerding + # US/ first: + ( cd $TZDIR + find . -type f | xargs file | grep "timezone data" | cut -f 1 -d : | cut -f 2- -d / | sort | grep "^US/" | while read zone ; do + echo "${zone}" >> $TZLIST + done + ) + # Don't list right/ and posix/ zones: + ( cd $TZDIR + find . -type f | xargs file | grep "timezone data" | cut -f 1 -d : | cut -f 2- -d / | sort | grep -v "^US/" | grep -v "^posix/" | grep -v "^right/" | while read zone ; do + echo "${zone}" >> $TZLIST + done + ) + for TZ in $(cat $TZLIST); do + # Add this entry to the keyboard selection menu: + cat <> ${GRUBDIR}/tz.cfg +menuentry "${TZ}" { + set sl_tz="$TZ" + export sl_tz + configfile \$grubdir/grub.cfg +} + +EOL + rm -f $TZLIST + + done } # --------------------------------------------------------------------------- @@ -1234,7 +1312,8 @@ elif [ ! -f ${LIVE_STAGING}/boot/syslinux/${CONSFONT} ]; then fi # Copy the UEFI boot directory structure: -cp -a ${LIVE_TOOLDIR}/EFI ${LIVE_STAGING}/ +mkdir -p ${LIVE_STAGING}/EFI/BOOT +cp -a ${LIVE_TOOLDIR}/EFI/BOOT/{grub-embedded.cfg,make-grub.sh,osdetect.cfg,theme} ${LIVE_STAGING}/EFI/BOOT/ # The grub-embedded.cfg in the bootx64.efi looks for this file: touch ${LIVE_STAGING}/EFI/BOOT/${MARKER} -- cgit v1.2.3