diff --git a/src/install.sh b/src/install.sh index 74a416e1..32139d7a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -71,7 +71,7 @@ selectWindowsImage() { fi # Inspect unknown bootable media directly before falling back to extraction. - if [[ "${iso,,}" != *.esd ]]; then + if isDirectImage "$iso"; then detectIsoImage "$iso" && return 0 @@ -331,7 +331,7 @@ skipUnattended() { # Standalone ESD files and nested archives are not directly bootable media, # so they cannot use the manual-install fallback. - if enabled "${UNPACK:-}" || [[ "${iso,,}" == *".esd" ]]; then + if ! isDirectImage "$iso"; then error "Failed to boot \"$iso\" because it is not a directly bootable ISO image!" exit 60 fi @@ -361,25 +361,6 @@ skipUnattended() { return 1 } -useOriginalImage() { - - local iso="$1" - - if [ -n "$CUSTOM" ]; then - BOOT="$iso" - return 0 - fi - - if [[ "$iso" != "$BOOT" ]]; then - if ! mv -f -- "$iso" "$BOOT"; then - error "Failed to move ISO file: $iso" - return 1 - fi - fi - - return 0 -} - skipInstall() { local iso="$1" @@ -619,9 +600,35 @@ detectCustom() { hasImage() { - local file="$1" + local iso="$1" - [ -f "$file" ] && [ -s "$file" ] + [ -f "$iso" ] && [ -s "$iso" ] +} + +isDirectImage() { + + local iso="$1" + + ! enabled "${UNPACK:-}" && [[ "${iso,,}" != *.esd ]] +} + +useOriginalImage() { + + local iso="$1" + + if [ -n "$CUSTOM" ]; then + BOOT="$iso" + return 0 + fi + + if [[ "$iso" != "$BOOT" ]]; then + if ! mv -f -- "$iso" "$BOOT"; then + error "Failed to move ISO file: $iso" + return 1 + fi + fi + + return 0 } removeImage() { @@ -669,8 +676,8 @@ needsExtraction() { local id="$1" local iso="$2" - # Nested archives must be extracted to expose their contained ISO. - if enabled "${UNPACK:-}"; then + # Nested archives must be extracted before they can be prepared. + if ! isDirectImage "$iso"; then return 0 fi @@ -684,11 +691,6 @@ needsExtraction() { return 0 fi - # Standalone ESD downloads must be extracted before they can be prepared. - if [[ "${iso,,}" == *".esd" ]]; then - return 0 - fi - # Modern bootable ISOs can use the original media with a setup overlay. return 1 }