diff --git a/src/usbinstall.py b/src/usbinstall.py index 9744d61..c657222 100755 --- a/src/usbinstall.py +++ b/src/usbinstall.py @@ -159,12 +159,8 @@ def go_on(): cloud_hide() # Step n°1 to n°2 if step == 1: - if path_cpio == "": - msg_warn(_("A file .cpio is required")) - return - else: - step += 1 - step2() + step += 1 + step2() # Step n°2 to n°3 elif step == 2: if path_iso == "": diff --git a/src/usbinstall.sh b/src/usbinstall.sh index f93039e..70681a5 100755 --- a/src/usbinstall.sh +++ b/src/usbinstall.sh @@ -173,35 +173,30 @@ else errorAndExit $"Error(Arg 1): \"$1\" isn't a block device" 1 fi -# Check if Arg 2 is valid -if [ -f "$2" ]; then # Check if is a file - if [ -r "$2" ]; then # Chek is is readable - export SELECT_BOOT=$2 - else - errorAndExit $"Error(Arg 2): \"$2\" is not readable" 1 - fi -else - errorAndExit $"Error(Arg 2): \"$2\" isn't a regular file" 1 -fi -# Check if Arg 2 is a gz file -if [ "${2##*.}" != "gz" ]; then - errorAndExit "Error(Arg 2): you must chose a cpio.gz file" 1 +# 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 + fi fi # Check if Arg 3 is valid -if [ -f "$3" ]; then # Check if is a file - if [ -r "$3" ]; then # Chek is is readable - SELECT_ISO=`readlink -f $3` - else - errorAndExit "Error(Arg 3): \"$3\" is not readable" 1 - fi +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 file" 1 + fi + SELECT_ISO=`readlink -f $3` else - errorAndExit "Error(Arg 3): \"$3\" isn't a regular file" 1 -fi -# Check if Arg 3 is an iso file -if [ "${3##*.}" != "iso" ]; then - errorAndExit "Error(Arg 3): you must chose a iso file" 1 + errorAndExit "Error(Arg 3): \"$3\" is not readable" 1 fi + #################################(INITIAL-CHECK)##################################### @@ -306,20 +301,7 @@ if [ ! -d "$MOUNTDIR" ]; then errorAndExit $"Error: unable to found usb mount path" fi -set_status $"Extracting bootusb archive..." -echo $"Extracting bootusb archive..." pushd $MOUNTDIR >/dev/null -sudo chmod 777 ./ -gunzip -c $SELECT_BOOT | cpio -i -if [ ! -d "./boot" ]; then - errorAndExit $"Error: Invalid bootusb archive" -fi -set_pbar 38 - -set_status $"Writing bootloader..." -echo $"Writing bootloader..." -sudo extlinux --install boot -set_pbar 45 set_status $"Copying ISO..." echo $"Copying ISO..." @@ -333,13 +315,46 @@ ps $CPPID >/dev/null while [ $? -eq 0 ]; do if [ -e $DEST_FILE ]; then DEST_SIZE=$(stat -c %s $DEST_FILE) - percentuale=$((45 + ( 50 * $DEST_SIZE ) / $ORIG_SIZE )) + percentuale=$((30 + ( 50 * $DEST_SIZE ) / $ORIG_SIZE )) set_pbar $percentuale fi sleep 2 ps $CPPID >/dev/null done ln -fs `basename $SELECT_ISO` ./openmamba-live.iso + +set_status $"Extracting bootusb archive..." +echo $"Extracting bootusb archive..." +sudo chmod 777 ./ +if [ "$SELECT_BOOT" ]; then + gunzip -c $SELECT_BOOT | cpio -i + if [ ! -d "./boot" ]; then + errorAndExit $"Error: Invalid bootusb archive" + fi +else + ISOMOUNTDIR=`mktemp -d --suffix=.usbinstall` + mount -o loop $SELECT_ISO $ISOMOUNTDIR || { + errorAndExit $"Error: unable to mount ISO image" + } + mkdir boot + cp $ISOMOUNTDIR/boot/{initrd*,vmlinuz*} boot/ + cp $ISOMOUNTDIR/boot/isolinux/* boot/ + mv boot/isolinux.cfg boot/extlinux.conf + sed -i "s|root=[^[:space:]]*|root=live:/openmamba_live/openmamba-live.iso|" boot/extlinux.conf + cp /usr/share/syslinux/{libcom32,libutil,vesamenu}.c32 boot/ || { + errorAndExit $"Error: can't copy some files to /boot directory" + } + rm -f boot/isolinux* + umount $ISOMOUNTDIR + rmdir $ISOMOUNTDIR +fi +set_pbar 85 + +set_status $"Writing bootloader..." +echo $"Writing bootloader..." +sudo extlinux --install boot +set_pbar 90 + popd >/dev/null sync set_pbar 95