From de819bd5f35d783008834313cc77501b64247193 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 3 Jul 2013 19:54:34 +0200 Subject: [PATCH] usbinstall.sh: finalize EFI partition support by creating a grub.cfg from extlinux.conf - use grub-mkimage instead of precreated EFI images --- po/it.po | 3 +++ src/usbinstall.sh | 53 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/po/it.po b/po/it.po index 9fe82b5..f5a2eec 100644 --- a/po/it.po +++ b/po/it.po @@ -166,6 +166,9 @@ msgstr "Formattazione della chiavetta ($SELECT_USB) in corso..." msgid "Extracting bootusb archive..." msgstr "Estrazione dei file di boot in corso..." +msgid "Extracting bootloader data from ISO image..." +msgstr "Estrazione dei dati del bootloader dall'immagine ISO..." + msgid "Writing bootloader..." msgstr "Scrittura del bootloader in corso..." diff --git a/src/usbinstall.sh b/src/usbinstall.sh index 70681a5..af1e560 100755 --- a/src/usbinstall.sh +++ b/src/usbinstall.sh @@ -10,7 +10,7 @@ #~ # scaricherà direttamente la versione attuale dal sito di openmamba. #~ # se il file iso è presente nella home verrà usato direttamente altrimenti si aprirà un dialogo dove sarà possibile cercarlo. #~ # (c) 2009 ercole 'ercolinux' carpanetto - ercole69@gmail.com -#~ # (c) 2009-2010 Silvan Calarco - silvan.calarco@mambasoft.it +#~ # (c) 2009-2013 Silvan Calarco - silvan.calarco@mambasoft.it # License: GPL v.3 @@ -122,7 +122,7 @@ function usage() echo -e "\t"$"Usage: sudo usbinstall Arg1 Arg2 Arg3 [-y]" echo -e "\t"$"Arg 1: Usb device path (e.g. /dev/sdc)" echo -e "\t"$"Arg 2: Cpio.gz file (e.g. ~/openmamba-bootusb-it-milestone2-2.0pre8.i586.cpio.gz)" - echo -e "\t"$"Arg 3: Iso file (e.g. ~/openmamba-livecd-it-milestone2-2.0pre8.i586.iso)" + echo -e "\t"$"Arg 3: ISO file (e.g. ~/openmamba-livecd-it-milestone2-2.0pre8.i586.iso)" echo -e "\t"$"-y: install without asking confirmation [Be careful!]" } @@ -190,7 +190,7 @@ fi if [ -r "$3" ]; then # Chek is is readable # Check if Arg 3 is an iso file if [ "${3##*.}" != "iso" ]; then - errorAndExit "Error(Arg 3): you must chose a iso file" 1 + errorAndExit "Error(Arg 3): you must chose a ISO (.iso) file" 1 fi SELECT_ISO=`readlink -f $3` else @@ -288,10 +288,21 @@ if [ ! -d "$MOUNTDIR_EFI" ]; then errorAndExit $"Error: unable to found usb mount path" fi +# create EFI grub 32 and 64 bit images mkdir -p $MOUNTDIR_EFI/EFI/BOOT/ -for f in /usr/lib/grub/bootx64.efi /usr/lib/grub/bootia32.efi; do - [ -e $f ] && cp $f $MOUNTDIR_EFI/EFI/BOOT/ -done +grub-mkimage -o $MOUNTDIR_EFI/EFI/BOOT/bootx64.efi -O x86_64-efi -p /efi/boot \ + part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot linux echo \ + help gfxterm gettext png efi_gop efi_uga search search_label search_fs_uuid || { + errorAndExit $"Error: unable to create GRUB x86_64-efi image" +} + +# 32bit EFI optional because untested and curently missing in x86_64 arch +[ -d /usr/lib/grub/i386-efi ] && \ +grub-mkimage -o $MOUNTDIR_EFI/EFI/BOOT/bootia32.efi -O i386-efi -p /efi/boot \ + part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot linux echo \ + help gfxterm gettext png efi_gop efi_uga search search_label search_fs_uuid || { + errorAndExit $"Error: unable to create GRUB i386-efi image" +} # Riceve la mountdir della chiavetta da dbus MOUNTDIR=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}2 \ @@ -323,15 +334,17 @@ while [ $? -eq 0 ]; do done ln -fs `basename $SELECT_ISO` ./openmamba-live.iso -set_status $"Extracting bootusb archive..." -echo $"Extracting bootusb archive..." sudo chmod 777 ./ if [ "$SELECT_BOOT" ]; then + set_status $"Extracting bootusb archive..." + echo $"Extracting bootusb archive..." gunzip -c $SELECT_BOOT | cpio -i if [ ! -d "./boot" ]; then errorAndExit $"Error: Invalid bootusb archive" fi else + set_status $"Extracting bootloader data from ISO image..." + echo $"Extracting bootloader data from ISO image..." ISOMOUNTDIR=`mktemp -d --suffix=.usbinstall` mount -o loop $SELECT_ISO $ISOMOUNTDIR || { errorAndExit $"Error: unable to mount ISO image" @@ -347,6 +360,30 @@ else rm -f boot/isolinux* umount $ISOMOUNTDIR rmdir $ISOMOUNTDIR + + # basic extlinux.conf -> grub.cfg conversion + echo "search --no-floppy --label --set=root openmamba_live" > $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}" + 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 < boot/extlinux.conf + [ "$CURR_BRACKET_OPEN" = "1" ] && echo "}" >> $MOUNTDIR_EFI/EFI/BOOT/grub.cfg fi set_pbar 85