usbinstall: drop bootusb image installation support and more fixes

- fix check for grub i386-efi installation on x86_64
- do unmount in errorAndExit function
This commit is contained in:
Silvan Calarco 2014-08-21 16:53:45 +02:00
parent af4cfcf672
commit bdc7c39edc
2 changed files with 32 additions and 33 deletions

View File

@ -354,7 +354,7 @@ def step3():
# Show the progressBar
window.p_install.show()
dbus_start()
process_sh = Popen(["pkexec", "/usr/sbin/usbinstall", path_dev, path_cpio, path_iso, "-d"])
process_sh = Popen(["pkexec", "/usr/sbin/usbinstall", path_dev, path_iso, "-d"])
# Show a list of object (step 1)
def list_obj1():

63
src/usbinstall.sh Executable file → Normal file
View File

@ -1,8 +1,8 @@
#!/bin/bash
#usbinstall.sh
# Arg 1: usb device for installation
# Arg 2: boot file
# Arg 3: iso file
# Arg 2: iso file
# Arg 3: option
#~ # openmamba-usbinstall è uno script per la generazione automatica di una chiavetta di boot per openmamba snapshot.
@ -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-2013 Silvan Calarco - silvan.calarco@mambasoft.it
#~ # (c) 2009-2014 Silvan Calarco - silvan.calarco@mambasoft.it
# License: GPL v.3
@ -41,7 +41,7 @@ org.freedesktop.DBus.Properties.Get string:$3 string:"$4"`
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"`
org.freedesktop.DBus.Properties.Get string:$3 string:$4`
[ $? -eq 0 ] || return 1
echo $REPLY | sed "s|.*array.*\[ string \"\(.*\)\" ]|\1|"
return 0
@ -112,6 +112,10 @@ function errorAndExit()
if [ -n "$2" ]; then
usage
fi
if [ "${SELECT_USB}" ]; then
udisks --unmount ${SELECT_USB}1 >/dev/null
udisks --unmount ${SELECT_USB}2 >/dev/null
fi
exit_frontend "$1" # Termina il frontend con codice di errore 1
exit 1
}
@ -121,9 +125,9 @@ function usage()
echo $"usbinstall: install openmamba into your usb key!"
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"$"-y: install without asking confirmation [Be careful!]"
echo -e "\t"$"Arg 2: ISO file (e.g. ~/openmamba-livecd-it-milestone2-2.0pre8.i586.iso)"
echo -e "\t"$"Arg 3: "$"-d: pass message through dbus (when invoked by GUI)"
echo -e "\t "$"-y: install without asking confirmation [Be careful!]"
}
@ -131,9 +135,9 @@ function usage()
#--------------------------------(INITIAL-CHECK)-------------------------------------
#=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
# Confirm
if [ "$4" = "-y" ]; then
if [ "$3" = "-y" ]; then
CONFIRM=0
elif [ "$4" = "-d" ]; then
elif [ "$3" = "-d" ]; then
CONFIRM=0
DBUS_USBINSTALL=1 # First set this
else
@ -173,28 +177,22 @@ else
errorAndExit $"Error(Arg 1): \"$1\" isn't a block device" 1
fi
# Check if Arg 2 is valid (it can be null)
if ["$2" ]; then
if [ -r "$2" ]; then # Chek is is readable
# Check if Arg 2 is a gz file
if [ "${2##*.}" != "gz" ]; then
errorAndExit "Error(Arg 2): you must chose a cpio.gz file" 1
fi
export SELECT_BOOT=$2
else
errorAndExit $"Error(Arg 2): \"$2\" is not readable" 1
# Check if Arg 2 is valid
if [ -r "$2" ]; then # Check it is readable
# Check if Arg 2 is an iso file
if [ "${2##*.}" != "iso" ]; then
errorAndExit "Error(Arg 2): you must chose a ISO (.iso) file" 1
fi
SELECT_ISO=`readlink -f $2`
else
errorAndExit "Error(Arg 2): \"$2\" is not readable" 1
fi
# Check if Arg 3 is valid
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 (.iso) file" 1
if [ "$3" ]; then
if [ "$3" != "-d" -a "$3" != "-t" ]; then # Check it is readable
errorAndExit $"Error(Arg 3): \"$3\" is not -d nor -t" 1
fi
SELECT_ISO=`readlink -f $3`
else
errorAndExit "Error(Arg 3): \"$3\" is not readable" 1
fi
#################################(INITIAL-CHECK)#####################################
@ -297,12 +295,13 @@ grub-mkimage -o $MOUNTDIR_EFI/EFI/BOOT/bootx64.efi -O x86_64-efi -p /efi/boot \
}
# 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"
}
if [ -d /usr/lib/grub/i386-efi ]; then
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"
}
fi
# Riceve la mountdir della chiavetta da dbus
MOUNTDIR=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}2 \