Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit f288817

Browse files
committed
v3.1.2, fix #21
1 parent ef0929c commit f288817

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

bootiso

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
#
44
# Author: jules randolph <jules.sam.randolph@gmail.com> https://github.com/jsamr
55
# License: MIT
6-
# Version 3.1.1
6+
# Version 3.1.2
77

88
set -o pipefail
99
set -E
1010

11+
version="3.1.2"
1112
scriptName=$(basename "$0")
1213
bashVersion=$(echo "$BASH_VERSION" | cut -d. -f1)
1314

@@ -17,7 +18,7 @@ if [ -z "$BASH_VERSION" ] || [ "$bashVersion" -lt 4 ]; then
1718
fi
1819

1920
# program constrains definitions
20-
typeset -ar commandDependencies=('lsblk' 'sfdisk' 'mkfs' 'blkid' 'wipefs' 'grep' 'file' 'awk' 'mlabel' 'partprobe')
21+
typeset -ar commandDependencies=('lsblk' 'sfdisk' 'mkfs' 'blkid' 'wipefs' 'grep' 'file' 'awk' 'mlabel' 'partprobe' 'tar')
2122
typeset -Ar commandPackages=(
2223
['lsblk']='util-linux'
2324
['sfdisk']='util-linux'
@@ -32,6 +33,7 @@ typeset -Ar commandPackages=(
3233
['rsync']='rsync'
3334
['partprobe']='parted'
3435
['curl']='curl'
36+
['tar']='tar'
3537
)
3638
typeset shortOptions='bydJahlMftLp'
3739
typeset -ar supportedFS=('vfat' 'exfat' 'ntfs' 'ext2' 'ext3' 'ext4' 'f2fs')
@@ -52,7 +54,6 @@ typeset -Ar userFlagsCompatibilityMatrix=(
5254
)
5355

5456
# internal variables
55-
typeset version="3.1.1"
5657
typeset ticketsurl="https://github.com/jsamr/bootiso/issues"
5758
typeset mountRoot=/mnt
5859
typeset tempRoot=/var/tmp/bootiso
@@ -67,6 +68,8 @@ typeset syslinuxVersion
6768
typeset -a devicesList
6869
typeset operationSuccess
6970
typeset expectingISOFile
71+
typeset foundSyslinuxMbrBinary
72+
typeset foundSyslinuxBiosFolder
7073
typeset -A syslinuxInstall
7174
typeset -a temporaryAssets=()
7275
typeset -A isoInspection=(
@@ -381,7 +384,7 @@ assertISOIsOK() {
381384
}
382385

383386
firstMatchInFolder() {
384-
find "$1" -type f -iname "$2" | head -n1 | awk '{print $1;}'
387+
find "$1" -type f -iname "$2" -print -quit
385388
}
386389

387390
matchFirstExpression() {
@@ -411,7 +414,7 @@ findFileFromPatterns() {
411414
done
412415
if [ -z "$found" ]; then
413416
for loc in "$@"; do
414-
typeset candidate=$(find "$root" -type f -wholename "*/$loc")
417+
typeset candidate=$(find "$root" -type f -path "*/$loc" -print -quit)
415418
if [ ! -z "$candidate" ]; then
416419
found="$candidate"
417420
break
@@ -466,7 +469,13 @@ checkpkg() {
466469
echo
467470
case $answer in
468471
y | Y)
469-
$pkgmgr "${commandPackages["$1"]}"
472+
if ! $pkgmgr "${commandPackages["$1"]}"; then
473+
failAndExit "Installation of dependency \`$1' failed.\\nPerhaps this dependency has a slightly different name in your distribution.\\nFind it and install manually."
474+
else
475+
if ! hasPackage "$1"; then
476+
failAndExit "Program \`$1' is not accessible in the \$PATH environment even though the package ${commandPackages["$1"]} has just been installed."
477+
fi
478+
fi
470479
;;
471480
*)
472481
failAndExit "Missing dependency \`$1'."
@@ -508,7 +517,7 @@ initDevicesList() {
508517
}
509518

510519
listDevicesTable() {
511-
typeset lsblkCmd='lsblk -o NAME,MODEL,VENDOR,SIZE,TRAN,HOTPLUG'
520+
typeset lsblkCmd='lsblk -o NAME,MODEL,VENDOR,SIZE,TRAN,HOTPLUG,SERIAL'
512521
initDevicesList
513522
if [ "$disableUSBCheck" == 'false' ]; then
514523
echoinfo "Listing drives available in your system:"
@@ -1081,6 +1090,7 @@ installSyslinuxVersion() {
10811090
fi
10821091
syslinuxInstall['mbrBin']="$mbrBin"
10831092
syslinuxInstall['extBin']="$extlinuxBin"
1093+
ls -l "$extlinuxBin" # TODO DELETE
10841094
return 0
10851095
}
10861096
checkpkg 'curl'
@@ -1161,17 +1171,18 @@ installBootloader() {
11611171
syslinuxFolder=$(dirname "$syslinuxConfig")
11621172
}
11631173
installWtLocalExtlinux() {
1164-
syslinuxInstall=(['mbrBin']=/usr/lib/syslinux/bios/mbr.bin ['extBin']='extlinux')
1174+
syslinuxInstall=(['mbrBin']="$foundSyslinuxMbrBinary" ['extBin']='extlinux')
11651175
syslinuxVersion="$localSyslinuxVersion"
11661176
echoinfo "Installing SYSLINUX bootloader in \`$syslinuxFolder' with local version \`$syslinuxVersion'..."
1167-
rsync --no-links --no-perms --no-owner --no-group -I /usr/lib/syslinux/bios/*.c32 "$syslinuxFolder" |& indentAll || echowarn "SYSLINUX could not install C32 BIOS modules."
1177+
rsync --no-links --no-perms --no-owner --no-group -I "$foundSyslinuxBiosFolder"/*.c32 "$syslinuxFolder" |& indentAll || echowarn "SYSLINUX could not install C32 BIOS modules."
11681178
sync
11691179
echogood "C32 BIOS modules successfully installed."
11701180
${syslinuxInstall['extBin']} --stupid --install "$syslinuxFolder" |& indentAll || failAndExit "SYSLINUX bootloader could not be installed."
11711181
sync
11721182
}
11731183
installWtKernelOrgExtlinux() {
11741184
echoinfo "Installing SYSLINUX bootloader in \`$syslinuxFolder' with kernel.org version \`$syslinuxVersion'..."
1185+
ls -l "${syslinuxInstall['extBin']}" # TODO DELETE
11751186
if ! ${syslinuxInstall['extBin']} --stupid --install "$syslinuxFolder" |& indentAll; then
11761187
echowarn "kernel.org version \`$syslinuxVersion' could not be run.\\nAttempting with local SYSLINUX install..."
11771188
installWtLocalExtlinux >/dev/null
@@ -1418,8 +1429,8 @@ inspectISO() {
14181429
fi
14191430
}
14201431
inspectEFICapabilities() {
1421-
typeset hasEfiRoot=$(find "$isoMountPoint" -type d -iname 'efi')
1422-
typeset hasEfiFile=$(find "$isoMountPoint" -type f -ipath '*/efi/*.efi' -prune)
1432+
typeset hasEfiRoot=$(find "$isoMountPoint" -type d -iname 'efi' -print -quit)
1433+
typeset hasEfiFile=$(find "$isoMountPoint" -type f -ipath '*/efi/*.efi' -prune -print -quit)
14231434
supportsEFIBoot=false
14241435
if [ ! -z "$hasEfiFile" ] && [ ! -z "$hasEfiRoot" ]; then
14251436
supportsEFIBoot=true
@@ -1466,6 +1477,21 @@ inspectISOBootCapabilities() {
14661477
fi
14671478
}
14681479

1480+
checkSyslinuxInstall() {
1481+
checkpkg 'syslinux'
1482+
if ! command -v extlinux > /dev/null; then
1483+
failAndExit "Your distribution doesn't ship \`extlinux' binary with \`syslinux' package.\\nPlease install \`extlinux' and try again."
1484+
fi
1485+
foundSyslinuxBiosFolder=$(find /usr/lib/syslinux/ -type d -path '*/bios' -print -quit)
1486+
foundSyslinuxMbrBinary=$(findFileFromPatterns /usr/lib/syslinux 'bios/mbr.bin' 'mbr.bin')
1487+
if [ -z "$foundSyslinuxBiosFolder" ]; then
1488+
failAndExit "Could not find a SYSLINUX bios folder containing c32 bios module files on this system."
1489+
fi
1490+
if [ -z "$foundSyslinuxMbrBinary" ]; then
1491+
failAndExit "Could not find a SYSLINUX MBR binary file on this system."
1492+
fi
1493+
}
1494+
14691495
printISOBootCapabilities() {
14701496
typeset uefiCompatible=${isoInspection['supportsEFIBoot']}
14711497
typeset syslinuxCompatible=false
@@ -1514,14 +1540,14 @@ execProbe() {
15141540

15151541
execWithRsync() {
15161542
shouldMakePartition=true
1543+
checkSyslinuxInstall
15171544
inspectISOBootCapabilities
15181545
runSecurityAssessments
15191546
mountISOFile
15201547
partitionUSB false
15211548
mountUSB
15221549
copyWithRsync
15231550
if [ "$addSyslinuxBootloader" == 'true' ]; then
1524-
checkpkg 'syslinux'
15251551
installBootloader
15261552
fi
15271553
}

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v3.1.2
2+
3+
- improved robustness of `checkpkg` function
4+
- fix issue with SYSLINUX and EXTLINUX on Ubuntu and debian-based distros #21
5+
- replaced `find` arguments `-wholename` with `-path` which is more portable
6+
- systematic usage the `-print -quit` pattern with `find` command when possible
7+
- add explicit dependency to `tar`
8+
19
# v3.1.1
210

311
- add compatibility code for `sfdisk` versions older then 2.28 which don't support `-W` option

0 commit comments

Comments
 (0)