usbinstall.sh: install bootx86.efi and bootia32.efi if found in EFI partition

This commit is contained in:
Silvan Calarco 2013-06-09 23:14:08 +02:00
parent 9a46459efc
commit 2139bc2ac6

View File

@ -246,17 +246,17 @@ if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# EFI partition
sudo parted -s -- $SELECT_USB mkpart primary fat32 0 20M &>>$LOGFILE
sudo parted -s -a optimal -- $SELECT_USB mkpart primary fat32 0 20M &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# openmamba partition
sudo parted -s -- $SELECT_USB mkpart primary ext4 20M -1 &>>$LOGFILE
sudo parted -s -a optimal -- $SELECT_USB mkpart primary ext4 20M -1 &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# boot flag on openmamba partition
sudo parted -s -- $SELECT_USB set 2 boot on &>>$LOGFILE
sudo parted -s $SELECT_USB set 2 boot on &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
@ -275,12 +275,29 @@ if [ "$?" != "0" ]; then
fi
sleep 1
LANG=C udisks --mount ${SELECT_USB}1 &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
fi
LANG=C udisks --mount ${SELECT_USB}2 &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
fi
set_pbar 30
# Riceve la mountdir della chiavetta da dbus
MOUNTDIR_EFI=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}1 \
org.freedesktop.UDisks.Device DeviceMountPaths`
if [ ! -d "$MOUNTDIR_EFI" ]; then
errorAndExit $"Error: unable to found usb mount path"
fi
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
# Riceve la mountdir della chiavetta da dbus
MOUNTDIR=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}2 \
org.freedesktop.UDisks.Device DeviceMountPaths`
@ -302,10 +319,8 @@ set_pbar 38
set_status $"Writing bootloader..."
echo $"Writing bootloader..."
sudo extlinux --install boot
sudo install-mbr -e 1 $SELECT_USB
set_pbar 45
set_status $"Copying ISO..."
echo $"Copying ISO..."
# Copy code
@ -327,13 +342,20 @@ done
ln -fs `basename $SELECT_ISO` ./openmamba-live.iso
popd >/dev/null
sync
set_pbar 98
set_pbar 95
set_status $"Unmount usb device"
echo $"Unmount usb device"
LANG=C udisks --unmount ${SELECT_USB}2 | grep failed && {
LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB}1)"
}
LANG=C udisks --unmount ${SELECT_USB}2 | grep failed && {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB}2)"
}
# WARNING: calling install-mbr after unmounting to prevent problems of FAT since EFI partition introduction
sudo install-mbr $SELECT_USB
set_pbar 100
exit_frontend ""
echo $"Done!"