usbinstall: support for EFI on Macs

This commit is contained in:
Silvan Calarco 2014-12-13 16:06:12 +01:00
parent c9b58a8108
commit 6200e195e6

View File

@ -26,43 +26,6 @@
TEXTDOMAINDIR=/usr/share/locale/
TEXTDOMAIN=usbinstall
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
#-------------------------------------(DBUS)-----------------------------------------
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
function dbus_properties_get_string() {
REPLY=`dbus-send --system --print-reply --dest=$1 $2 \
org.freedesktop.DBus.Properties.Get string:$3 string:"$4"`
[ $? -eq 0 ] || return 1
echo $REPLY | sed "s|.*string.*\"\(.*\)\"|\1|"
return 0
}
function dbus_properties_get_stringlist() {
# FIXME: only returns first element
REPLY=`dbus-send --system --print-reply --dest=$1 $2 \
org.freedesktop.DBus.Properties.Get string:$3 string:$4`
[ $? -eq 0 ] || return 1
echo $REPLY | sed "s|.*array.*\[ string \"\(.*\)\" ]|\1|"
return 0
}
function dbus_properties_get_uint64() {
REPLY=`dbus-send --system --print-reply --dest=$1 $2 \
org.freedesktop.DBus.Properties.Get string:$3 string:$4`
[ $? -eq 0 ] || return 1
echo $REPLY | sed "s|.*uint64 \(.*\)|\1|"
return 0
}
function dbus_properties_get_bool() {
REPLY=`dbus-send --system --print-reply --dest=$1 $2 org.freedesktop.DBus.Properties.Get string:$3 string:"$4"`
[ $? -eq 0 ] || return 1
echo $REPLY | sed "s|.*boolean \(.*\)|\1|"
return 0
}
# Set progressbar (only if $DBUS_USBINSTALL = 1)
# Arg 1: value%
set_pbar()
@ -118,6 +81,9 @@ function errorAndExit()
if [ "${SELECT_USB2}" ]; then
udisksctl unmount -b ${SELECT_USB2} >/dev/null
fi
if [ "${SELECT_USB3}" ]; then
udisksctl unmount -b ${SELECT_USB3} >/dev/null
fi
exit_frontend "$1" # Termina il frontend con codice di errore 1
exit 1
}
@ -181,9 +147,11 @@ fi
if [ "${SELECT_USB:0:9}" = "/dev/loop" ]; then
SELECT_USB1=${SELECT_USB}p1
SELECT_USB2=${SELECT_USB}p2
SELECT_USB3=${SELECT_USB}p3
else
SELECT_USB1=${SELECT_USB}1
SELECT_USB2=${SELECT_USB}2
SELECT_USB3=${SELECT_USB}3
fi
# Check if Arg 2 is valid
@ -217,11 +185,11 @@ trap "[ \"$CPPID\" ] && kill -9 $CPPID" HUP INT QUIT ABRT KILL TERM
set_status $"Unmount usb device"
echo $"Unmount usb device"
DEVICEMOUNTPOINTS=`udisksctl info -b ${SELECT_USB1} | grep MountPoints: | sed "s|.*[[:space:]]||"`
DEVICEMOUNTPOINTS=`udisksctl info -b ${SELECT_USB2} | grep MountPoints: | sed "s|.*[[:space:]]||"`
if [ "$DEVICEMOUNTPOINTS" ]; then
LANG=C udiskctl unmount -b ${SELECT_USB1} || {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB1})"
LANG=C udiskctl unmount -b ${SELECT_USB2} || {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB2})"
}
fi
set_pbar 2
@ -247,17 +215,22 @@ if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# EFI partition
sudo parted -s -a optimal -- $SELECT_USB mkpart primary fat32 0 20M &>>$LOGFILE
sudo parted -s -a optimal -- $SELECT_USB mkpart primary hfs+ 0 20M &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# EFI partition
sudo parted -s -a optimal -- $SELECT_USB mkpart primary fat32 20M 40M &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# openmamba partition
sudo parted -s -a optimal -- $SELECT_USB mkpart primary ext4 20M -1 &>>$LOGFILE
sudo parted -s -a optimal -- $SELECT_USB mkpart primary ext4 40M -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 3 boot on &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
@ -266,11 +239,15 @@ set_pbar 5
set_status $"Formatting $SELECT_USB..."
echo $"Formatting $SELECT_USB..."
sudo mkfs.vfat ${SELECT_USB1} -n EFI &>>$LOGFILE
sudo mkfs.hfsplus ${SELECT_USB1} -v EFI_MAC &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"mkfs.hfsplus\" "$"exit with error (see $LOGFILE)"
fi
sudo mkfs.vfat ${SELECT_USB2} -n EFI &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"mkfs.vfat\" "$"exit with error (see $LOGFILE)"
fi
sudo mkfs.ext4 ${SELECT_USB2} -L openmamba_live &>>$LOGFILE
sudo mkfs.ext4 ${SELECT_USB3} -L openmamba_live &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"mkfs.ext4\" "$"exit with error (see $LOGFILE)"
fi
@ -284,11 +261,18 @@ LANG=C udisksctl mount -b ${SELECT_USB2} &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
fi
LANG=C udisksctl mount -b ${SELECT_USB3} &>>$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=`udisksctl info -b ${SELECT_USB1} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
MOUNTDIR_EFI_MAC=`udisksctl info -b ${SELECT_USB1} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
if [ ! -d "$MOUNTDIR_EFI_MAC" ]; then
errorAndExit $"Error: unable to found usb mount path"
fi
MOUNTDIR_EFI=`udisksctl info -b ${SELECT_USB2} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
if [ ! -d "$MOUNTDIR_EFI" ]; then
errorAndExit $"Error: unable to found usb mount path"
fi
@ -310,9 +294,7 @@ if [ -d /usr/lib/grub/i386-efi ]; then
}
fi
# Riceve la mountdir della chiavetta da dbus
MOUNTDIR=`udisksctl info -b ${SELECT_USB2} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
MOUNTDIR=`udisksctl info -b ${SELECT_USB3} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
if [ ! -d "$MOUNTDIR" ]; then
errorAndExit $"Error: unable to found usb mount path"
fi
@ -394,6 +376,9 @@ else
fi
set_pbar 85
cp -a $MOUNTDIR_EFI/EFI $MOUNTDIR_EFI_MAC
hfs-bless $MOUNTDIR_EFI_MAC/EFI/BOOT/bootia32.efi
set_status $"Writing bootloader..."
echo $"Writing bootloader..."
sudo extlinux --install boot
@ -411,6 +396,9 @@ LANG=C udisksctl unmount -b ${SELECT_USB1} || {
LANG=C udisksctl unmount -b ${SELECT_USB2} || {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB2})"
}
LANG=C udisksctl unmount -b ${SELECT_USB3} || {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB3})"
}
# WARNING: calling install-mbr after unmounting to prevent problems of FAT since EFI partition introduction
sudo install-mbr $SELECT_USB