usbinstall.sh: support for recent ISO images with GRUB bootloader replacing Isolinux

This commit is contained in:
Silvan Calarco 2022-10-05 16:21:53 +02:00
parent 122509b6a5
commit 279bd34386

View File

@ -282,8 +282,6 @@ else
mkdir LiveOS boot rwroot ovlwork mkdir LiveOS boot rwroot ovlwork
cp $ISOMOUNTDIR/boot/{initrd*,vmlinuz*} boot/ 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..." set_status $"Copying SquashFS image from ISO image..."
echo $"Copying SquashFS image..." echo $"Copying SquashFS image..."
@ -304,8 +302,10 @@ else
ps $CPPID >/dev/null ps $CPPID >/dev/null
done done
# basic extlinux.conf -> grub.cfg conversion if [ -e $ISOMOUNTDIR/boot/isolinux/isolinux.cfg ]; then
echo "\ # basic extlinux.conf -> grub.cfg conversion
# Legacy for old openmamba iso images with isolinux bootloader
echo "\
# #
# GRUB configuration generated by openmamba usbinstall tool # 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 # Boot entries taken from ISO bootloader
# #
" > $MOUNTDIR_EFI/EFI/BOOT/grub.cfg " > $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
while read line; do while read line; do
case $line in case $line in
"MENU LABEL "*) [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg "MENU LABEL "*) [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
echo "menuentry \"${line/MENU LABEL }\" {" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg echo "menuentry \"${line/MENU LABEL }\" {" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
CURR_BRACKET_OPEN=1 CURR_BRACKET_OPEN=1
;; ;;
"kernel "*) CURR_KERNEL="${line/kernel }" "kernel "*) CURR_KERNEL="${line/kernel }"
echo "echo \"Loading ${CURR_KERNEL}\"" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg echo "echo \"Loading ${CURR_KERNEL}\"" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
;; ;;
"append "*) set -- ${line/append initrd=} "append "*) set -- ${line/append initrd=}
CURR_INITRD="$1" CURR_INITRD="$1"
CURR_CMDLINE="${line/append initrd=$CURR_INITRD}" CURR_CMDLINE="${line/append initrd=$CURR_INITRD}"
CURR_CMDLINE="${CURR_CMDLINE/vga=792}" CURR_CMDLINE="${CURR_CMDLINE/vga=792}"
echo "linux ${CURR_KERNEL} ${CURR_CMDLINE}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg echo "linux ${CURR_KERNEL} ${CURR_CMDLINE}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
echo "echo \"Loading ${CURR_INITRD}\"" >> $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 "initrd ${CURR_INITRD}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg
CURR_BRACKET_OPEN=0 CURR_BRACKET_OPEN=0
;; ;;
esac esac
done < $ISOMOUNTDIR/boot/isolinux/isolinux.cfg done < $ISOMOUNTDIR/boot/isolinux/isolinux.cfg
[ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.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 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 mkdir boot/grub
cp $MOUNTDIR_EFI/EFI/BOOT/grub.cfg boot/grub/grub.cfg cp $MOUNTDIR_EFI/EFI/BOOT/grub.cfg boot/grub/grub.cfg
umount $ISOMOUNTDIR umount $ISOMOUNTDIR
rmdir $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 fi
set_pbar 85 set_pbar 85