From da032a401eaa1f6bc2bdfd92b9d0a6988851bf6a Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 6 Jul 2026 07:46:01 +0200 Subject: [PATCH] feat: Improve installation robustness (#1807) --- src/install.sh | 30 ++++++++++++++++++++++-------- src/mido.sh | 5 ++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/install.sh b/src/install.sh index aea9ad3..f579833 100644 --- a/src/install.sh +++ b/src/install.sh @@ -598,7 +598,7 @@ extractImage() { if ! enabled "${UNPACK:-}"; then - LABEL=$(isoinfo -d -i "$iso" | sed -n 's/Volume id: //p') + LABEL=$(isoinfo -d -i "$iso" | sed -n 's/Volume id: //p') || LABEL="" else @@ -612,8 +612,8 @@ extractImage() { error "Failed to extract archive!" && return 1 fi - LABEL=$(isoinfo -d -i "$file" | sed -n 's/Volume id: //p') - rm -f "$file" + LABEL=$(isoinfo -d -i "$file" | sed -n 's/Volume id: //p') || LABEL="" + rm -f "$file" || warn "Failed to remove temporary ISO file: $file" fi @@ -1126,11 +1126,19 @@ updateImage() { if ! enabled "$MANUAL"; then xml=$(basename "$asset") + local answer="$tmp/$xml" + info "Adding $xml for automatic installation..." - local answer="$tmp/$xml" - cp "$asset" "$answer" - updateXML "$answer" "$language" + if ! cp "$asset" "$answer"; then + error "Failed to copy answer file to $answer." + return 1 + fi + + if ! updateXML "$answer" "$language"; then + error "Failed to update answer file: $answer" + return 1 + fi if ! wimlib-imagex update "$wim" "$index" --command "add $answer /$file" > /dev/null; then MANUAL="Y" @@ -1159,9 +1167,15 @@ updateImage() { if [ -f "$path" ]; then if ! enabled "$MANUAL"; then - mv -f "$path" "${path%.*}.org" + if ! mv -f "$path" "${path%.*}.org"; then + error "Failed to rename answer file: $path" + return 1 + fi else - mv -f "$path" "${path%.*}.xml" + if ! mv -f "$path" "${path%.*}.xml"; then + error "Failed to rename answer file: $path" + return 1 + fi fi fi diff --git a/src/mido.sh b/src/mido.sh index 651e83d..4b418c8 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -539,7 +539,10 @@ getESD() { if [[ "$file" == *".xml" ]]; then - mv -f "$dir/$file" "$dir/$xFile" + if ! mv -f "$dir/$file" "$dir/$xFile"; then + error "Failed to rename $file to $xFile." + return 1 + fi else