From 279bd343864979218fe661eec1369449556ee64a Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 5 Oct 2022 16:21:53 +0200 Subject: [PATCH] usbinstall.sh: support for recent ISO images with GRUB bootloader replacing Isolinux --- src/usbinstall.sh | 67 +++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/usbinstall.sh b/src/usbinstall.sh index cba99f1..1f69d04 100644 --- a/src/usbinstall.sh +++ b/src/usbinstall.sh @@ -282,8 +282,6 @@ else mkdir LiveOS boot rwroot ovlwork cp $ISOMOUNTDIR/boot/{initrd*,vmlinuz*} boot/ - TARGET_ARCH=`cat $ISOMOUNTDIR/etc/openmamba-release | sed "s|.*for \(.*\) .*|\1|"` - [ "$TARGET_ARCH" ] || TARGET_ARCH=x86_64 set_status $"Copying SquashFS image from ISO image..." echo $"Copying SquashFS image..." @@ -304,8 +302,10 @@ else ps $CPPID >/dev/null done - # basic extlinux.conf -> grub.cfg conversion - echo "\ + if [ -e $ISOMOUNTDIR/boot/isolinux/isolinux.cfg ]; then + # basic extlinux.conf -> grub.cfg conversion + # Legacy for old openmamba iso images with isolinux bootloader + echo "\ # # GRUB configuration generated by openmamba usbinstall tool # @@ -326,34 +326,39 @@ search --no-floppy --label --set=root openmamba_live # Boot entries taken from ISO bootloader # " > $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - while read line; do - case $line in - "MENU LABEL "*) [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - echo "menuentry \"${line/MENU LABEL }\" {" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - CURR_BRACKET_OPEN=1 - ;; - "kernel "*) CURR_KERNEL="${line/kernel }" - echo "echo \"Loading ${CURR_KERNEL}\"" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - ;; - "append "*) set -- ${line/append initrd=} - CURR_INITRD="$1" - CURR_CMDLINE="${line/append initrd=$CURR_INITRD}" - CURR_CMDLINE="${CURR_CMDLINE/vga=792}" - echo "linux ${CURR_KERNEL} ${CURR_CMDLINE}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - echo "echo \"Loading ${CURR_INITRD}\"" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - echo "initrd ${CURR_INITRD}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - CURR_BRACKET_OPEN=0 - ;; - esac - done < $ISOMOUNTDIR/boot/isolinux/isolinux.cfg - [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - sed -i "s|root=live:LABEL=.*splash|root=live:LABEL=openmamba_live rd.live.overlay=/dev/disk/by-label/openmamba_live:/rwroot selinux=0 quiet splash rw|" $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + while read line; do + case $line in + "MENU LABEL "*) [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + echo "menuentry \"${line/MENU LABEL }\" {" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + CURR_BRACKET_OPEN=1 + ;; + "kernel "*) CURR_KERNEL="${line/kernel }" + echo "echo \"Loading ${CURR_KERNEL}\"" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + ;; + "append "*) set -- ${line/append initrd=} + CURR_INITRD="$1" + CURR_CMDLINE="${line/append initrd=$CURR_INITRD}" + CURR_CMDLINE="${CURR_CMDLINE/vga=792}" + echo "linux ${CURR_KERNEL} ${CURR_CMDLINE}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + echo "echo \"Loading ${CURR_INITRD}\"" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + echo "initrd ${CURR_INITRD}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + CURR_BRACKET_OPEN=0 + ;; + esac + done < $ISOMOUNTDIR/boot/isolinux/isolinux.cfg + [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + sed -i "s|root=live:LABEL=.*splash|root=live:LABEL=openmamba_live rd.live.overlay=/dev/disk/by-label/openmamba_live:/rwroot selinux=0 quiet splash rw|" $MOUNTDIR_EFI/EFI/BOOT/grub.cfg - mkdir boot/grub - cp $MOUNTDIR_EFI/EFI/BOOT/grub.cfg boot/grub/grub.cfg - umount $ISOMOUNTDIR - rmdir $ISOMOUNTDIR + mkdir boot/grub + cp $MOUNTDIR_EFI/EFI/BOOT/grub.cfg boot/grub/grub.cfg + umount $ISOMOUNTDIR + rmdir $ISOMOUNTDIR + else + cp -a $ISOMOUNTDIR/boot/grub boot/ + sed -i "s|root=live:LABEL=[^[:space:]]*|root=live:LABEL=openmamba_live rd.live.overlay=/dev/disk/by-label/openmamba_live:/rwroot|" boot/grub/grub.cfg + cp boot/grub/grub.cfg $MOUNTDIR_EFI/EFI/BOOT/grub.cfg + fi fi set_pbar 85