usbinstall.sh: remove obsolete hfs+ EFI boot partition; fix error on final grub-install due to defaulting to x86_64-EFI target

This commit is contained in:
Silvan Calarco 2022-05-18 19:30:29 +02:00
parent 8e5a834c1e
commit cd535584f3

View File

@ -3,25 +3,9 @@
# Arg 1: usb device for installation
# Arg 2: iso file
# Arg 3: option
#~ # openmamba-usbinstall è uno script per la generazione automatica di una chiavetta di boot per openmamba snapshot.
#~ # Se i file necessari sono presenti sul disco fisso verranno utilizzati quelli altrimenti
#~ # 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-2019 Silvan Calarco - silvan.calarco@mambasoft.it
# License: GPL v.3
#%Changelog:
# 17/10/11 (michiamophil)
# * Script modificato organizzando il codice in funzioni, chiamate dal modulo installazione.py
# 06/01/12 (michiamophil)
# * "sudo u/mount -> udisks"
# * export $1, $2, $3 -> OPENMAMBA_*
# 08/01/12 (michiamophil)
# * INITIAL-CHECK
#~ # (c) 2009-2022 Silvan Calarco - silvan.calarco@mambasoft.it
# Released under the terms of the GPL v3 license
TEXTDOMAINDIR=/usr/share/locale/
TEXTDOMAIN=usbinstall
@ -81,9 +65,6 @@ 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
}
@ -147,11 +128,9 @@ 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
@ -209,7 +188,7 @@ fi
set_status $"Partitioning $SELECT_USB..."
echo $"Partitioning $SELECT_USB..."
# Wipe any old GPT table or grub-install may fail due to mmultiple partition labels
# Wipe any old GPT table or grub-install may fail due to multiple partition labels
sudo dd if=/dev/zero of=$SELECT_USB bs=512 count=2047 skip=1
# Start from a new partition table
sudo parted -s $SELECT_USB mktable msdos &>>$LOGFILE
@ -217,22 +196,17 @@ if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
fi
# EFI partition
sudo parted -s -a optimal -- $SELECT_USB mkpart primary hfs+ 1M 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
sudo parted -s -a optimal -- $SELECT_USB mkpart primary fat32 1M 20M &>>$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 40M -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 3 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
@ -241,15 +215,11 @@ set_pbar 5
set_status $"Formatting $SELECT_USB..."
echo $"Formatting $SELECT_USB..."
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
sudo mkfs.vfat ${SELECT_USB1} -n EFI &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"mkfs.vfat\" "$"exit with error (see $LOGFILE)"
fi
sudo mkfs.ext4 ${SELECT_USB3} -L openmamba_live &>>$LOGFILE
sudo mkfs.ext4 ${SELECT_USB2} -L openmamba_live &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit $"Error:"" \"mkfs.ext4\" "$"exit with error (see $LOGFILE)"
fi
@ -263,18 +233,9 @@ 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
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:]]||"`
MOUNTDIR_EFI=`udisksctl info -b ${SELECT_USB1} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
if [ ! -d "$MOUNTDIR_EFI" ]; then
errorAndExit $"Error: unable to found usb mount path"
fi
@ -296,7 +257,7 @@ if [ -d /usr/lib/grub/i386-efi ]; then
}
fi
MOUNTDIR=`udisksctl info -b ${SELECT_USB3} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
MOUNTDIR=`udisksctl info -b ${SELECT_USB2} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
if [ ! -d "$MOUNTDIR" ]; then
errorAndExit $"Error: unable to found usb mount path"
fi
@ -396,17 +357,10 @@ search --no-floppy --label --set=root openmamba_live
fi
set_pbar 85
cp -a $MOUNTDIR_EFI/EFI $MOUNTDIR_EFI_MAC
if [ "$TARGET_ARCH" = "x86_64" ]; then
hfs-bless $MOUNTDIR_EFI_MAC/EFI/BOOT/bootx64.efi &>>$LOGFILE
else
hfs-bless $MOUNTDIR_EFI_MAC/EFI/BOOT/bootia32.efi &>>$LOGFILE
fi
set_status $"Writing bootloader..."
echo $"Writing bootloader..."
sudo grub-install --modules="part_msdos part_gpt ext2" --removable --boot-directory=boot/ $SELECT_USB &>>$LOGFILE || {
# Install mbr bootloder (i386-pc)
grub-install --modules="part_msdos part_gpt ext2" --removable --target=i386-pc --boot-directory=boot/ $SELECT_USB &>>$LOGFILE || {
errorAndExit $"Error: failed to install bootloader into device (${SELECT_USB})"
}
set_pbar 90
@ -423,12 +377,9 @@ LANG=C udisksctl unmount -b ${SELECT_USB1} &>>$LOGFILE || {
LANG=C udisksctl unmount -b ${SELECT_USB2} &>>$LOGFILE || {
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB2})"
}
LANG=C udisksctl unmount -b ${SELECT_USB3} &>>$LOGFILE || {
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 &>>$LOGFILE
#install-mbr $SELECT_USB &>>$LOGFILE
set_pbar 100
exit_frontend ""