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:
parent
8e5a834c1e
commit
cd535584f3
@ -3,25 +3,9 @@
|
|||||||
# Arg 1: usb device for installation
|
# Arg 1: usb device for installation
|
||||||
# Arg 2: iso file
|
# Arg 2: iso file
|
||||||
# Arg 3: option
|
# 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 ercole 'ercolinux' carpanetto - ercole69@gmail.com
|
||||||
#~ # (c) 2009-2019 Silvan Calarco - silvan.calarco@mambasoft.it
|
#~ # (c) 2009-2022 Silvan Calarco - silvan.calarco@mambasoft.it
|
||||||
# License: GPL v.3
|
# Released under the terms of the GPL v3 license
|
||||||
|
|
||||||
|
|
||||||
#%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
|
|
||||||
|
|
||||||
TEXTDOMAINDIR=/usr/share/locale/
|
TEXTDOMAINDIR=/usr/share/locale/
|
||||||
TEXTDOMAIN=usbinstall
|
TEXTDOMAIN=usbinstall
|
||||||
@ -81,9 +65,6 @@ function errorAndExit()
|
|||||||
if [ "${SELECT_USB2}" ]; then
|
if [ "${SELECT_USB2}" ]; then
|
||||||
udisksctl unmount -b ${SELECT_USB2} >/dev/null
|
udisksctl unmount -b ${SELECT_USB2} >/dev/null
|
||||||
fi
|
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_frontend "$1" # Termina il frontend con codice di errore 1
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -147,11 +128,9 @@ fi
|
|||||||
if [ "${SELECT_USB:0:9}" = "/dev/loop" ]; then
|
if [ "${SELECT_USB:0:9}" = "/dev/loop" ]; then
|
||||||
SELECT_USB1=${SELECT_USB}p1
|
SELECT_USB1=${SELECT_USB}p1
|
||||||
SELECT_USB2=${SELECT_USB}p2
|
SELECT_USB2=${SELECT_USB}p2
|
||||||
SELECT_USB3=${SELECT_USB}p3
|
|
||||||
else
|
else
|
||||||
SELECT_USB1=${SELECT_USB}1
|
SELECT_USB1=${SELECT_USB}1
|
||||||
SELECT_USB2=${SELECT_USB}2
|
SELECT_USB2=${SELECT_USB}2
|
||||||
SELECT_USB3=${SELECT_USB}3
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if Arg 2 is valid
|
# Check if Arg 2 is valid
|
||||||
@ -209,7 +188,7 @@ fi
|
|||||||
|
|
||||||
set_status $"Partitioning $SELECT_USB..."
|
set_status $"Partitioning $SELECT_USB..."
|
||||||
echo $"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
|
sudo dd if=/dev/zero of=$SELECT_USB bs=512 count=2047 skip=1
|
||||||
# Start from a new partition table
|
# Start from a new partition table
|
||||||
sudo parted -s $SELECT_USB mktable msdos &>>$LOGFILE
|
sudo parted -s $SELECT_USB mktable msdos &>>$LOGFILE
|
||||||
@ -217,22 +196,17 @@ if [ "$?" != "0" ]; then
|
|||||||
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
fi
|
||||||
# EFI partition
|
# EFI partition
|
||||||
sudo parted -s -a optimal -- $SELECT_USB mkpart primary hfs+ 1M 20M &>>$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
|
|
||||||
# EFI partition
|
|
||||||
sudo parted -s -a optimal -- $SELECT_USB mkpart primary fat32 20M 40M &>>$LOGFILE
|
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
fi
|
||||||
# openmamba partition
|
# 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
|
if [ "$?" != "0" ]; then
|
||||||
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
fi
|
||||||
# boot flag on openmamba partition
|
# 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
|
if [ "$?" != "0" ]; then
|
||||||
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"parted\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
fi
|
||||||
@ -241,15 +215,11 @@ set_pbar 5
|
|||||||
|
|
||||||
set_status $"Formatting $SELECT_USB..."
|
set_status $"Formatting $SELECT_USB..."
|
||||||
echo $"Formatting $SELECT_USB..."
|
echo $"Formatting $SELECT_USB..."
|
||||||
sudo mkfs.hfsplus ${SELECT_USB1} -v EFI_MAC &>>$LOGFILE
|
sudo mkfs.vfat ${SELECT_USB1} -n EFI &>>$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
|
if [ "$?" != "0" ]; then
|
||||||
errorAndExit $"Error:"" \"mkfs.vfat\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"mkfs.vfat\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
fi
|
||||||
sudo mkfs.ext4 ${SELECT_USB3} -L openmamba_live &>>$LOGFILE
|
sudo mkfs.ext4 ${SELECT_USB2} -L openmamba_live &>>$LOGFILE
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
errorAndExit $"Error:"" \"mkfs.ext4\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"mkfs.ext4\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
fi
|
||||||
@ -263,18 +233,9 @@ LANG=C udisksctl mount -b ${SELECT_USB2} &>>$LOGFILE
|
|||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
|
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
|
||||||
fi
|
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
|
set_pbar 30
|
||||||
|
|
||||||
MOUNTDIR_EFI_MAC=`udisksctl info -b ${SELECT_USB1} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
|
MOUNTDIR_EFI=`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
|
if [ ! -d "$MOUNTDIR_EFI" ]; then
|
||||||
errorAndExit $"Error: unable to found usb mount path"
|
errorAndExit $"Error: unable to found usb mount path"
|
||||||
fi
|
fi
|
||||||
@ -296,7 +257,7 @@ if [ -d /usr/lib/grub/i386-efi ]; then
|
|||||||
}
|
}
|
||||||
fi
|
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
|
if [ ! -d "$MOUNTDIR" ]; then
|
||||||
errorAndExit $"Error: unable to found usb mount path"
|
errorAndExit $"Error: unable to found usb mount path"
|
||||||
fi
|
fi
|
||||||
@ -396,17 +357,10 @@ search --no-floppy --label --set=root openmamba_live
|
|||||||
fi
|
fi
|
||||||
set_pbar 85
|
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..."
|
set_status $"Writing bootloader..."
|
||||||
echo $"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})"
|
errorAndExit $"Error: failed to install bootloader into device (${SELECT_USB})"
|
||||||
}
|
}
|
||||||
set_pbar 90
|
set_pbar 90
|
||||||
@ -423,12 +377,9 @@ LANG=C udisksctl unmount -b ${SELECT_USB1} &>>$LOGFILE || {
|
|||||||
LANG=C udisksctl unmount -b ${SELECT_USB2} &>>$LOGFILE || {
|
LANG=C udisksctl unmount -b ${SELECT_USB2} &>>$LOGFILE || {
|
||||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB2})"
|
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
|
## 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
|
set_pbar 100
|
||||||
exit_frontend ""
|
exit_frontend ""
|
||||||
|
Loading…
Reference in New Issue
Block a user