fix: Check for empty files
This commit is contained in:
parent
e6c0a59588
commit
77fb4b24e8
1 changed files with 16 additions and 15 deletions
|
|
@ -95,6 +95,7 @@ skipInstall() {
|
||||||
finishInstall() {
|
finishInstall() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
|
local aborted="$2"
|
||||||
|
|
||||||
# Mark ISO as prepared via magic byte
|
# Mark ISO as prepared via magic byte
|
||||||
printf '\x16' | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none
|
printf '\x16' | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none
|
||||||
|
|
@ -115,7 +116,7 @@ abortInstall() {
|
||||||
mv -f "$iso" "$STORAGE/$BASE"
|
mv -f "$iso" "$STORAGE/$BASE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
finishInstall "$STORAGE/$BASE"
|
finishInstall "$STORAGE/$BASE" "Y"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,7 +167,7 @@ startInstall() {
|
||||||
|
|
||||||
if [[ "$magic" == "16" ]]; then
|
if [[ "$magic" == "16" ]]; then
|
||||||
|
|
||||||
if hasDisk || [[ "$MANUAL" = [Yy1]* ]]; then
|
if hasDisk || [[ "$MANUAL" == [Yy1]* ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -319,7 +320,7 @@ downloadImage() {
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
(( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60
|
(( rc != 0 )) && error "Failed to download $url , reason: $rc" && exit 60
|
||||||
|
|
||||||
[ ! -s "$iso" ] && return 1
|
[ ! -s "$iso" ] || [ ! -f "$iso" ] && return 1
|
||||||
|
|
||||||
html "Download finished successfully..."
|
html "Download finished successfully..."
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -419,8 +420,8 @@ extractImage() {
|
||||||
|
|
||||||
if [[ "${iso,,}" == *".esd" ]]; then
|
if [[ "${iso,,}" == *".esd" ]]; then
|
||||||
if ! extractESD "$iso" "$dir"; then
|
if ! extractESD "$iso" "$dir"; then
|
||||||
error "Failed to extract ESD file!"
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
error "Failed to extract ESD file!"
|
||||||
exit 67
|
exit 67
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -451,8 +452,8 @@ extractImage() {
|
||||||
rm -rf "$dir"
|
rm -rf "$dir"
|
||||||
|
|
||||||
if ! 7z x "$iso" -o"$dir" > /dev/null; then
|
if ! 7z x "$iso" -o"$dir" > /dev/null; then
|
||||||
error "Failed to extract ISO file!"
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
error "Failed to extract ISO file!"
|
||||||
exit 66
|
exit 66
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -474,7 +475,7 @@ detectImage() {
|
||||||
|
|
||||||
if [ -n "$DETECTED" ]; then
|
if [ -n "$DETECTED" ]; then
|
||||||
|
|
||||||
if [ -s "/run/assets/$DETECTED.xml" ]; then
|
if [ -f "/run/assets/$DETECTED.xml" ]; then
|
||||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -502,9 +503,9 @@ detectImage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
loc=$(find "$src" -maxdepth 1 -type f -iname install.wim | head -n 1)
|
loc=$(find "$src" -maxdepth 1 -type f -iname install.wim | head -n 1)
|
||||||
[ ! -s "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1)
|
[ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1)
|
||||||
|
|
||||||
if [ ! -s "$loc" ]; then
|
if [ ! -f "$loc" ]; then
|
||||||
warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB"
|
warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -531,7 +532,7 @@ detectImage() {
|
||||||
desc=$(printVersion "$DETECTED")
|
desc=$(printVersion "$DETECTED")
|
||||||
[ -z "$desc" ] && desc="$DETECTED"
|
[ -z "$desc" ] && desc="$DETECTED"
|
||||||
|
|
||||||
if [ -s "/run/assets/$DETECTED.xml" ]; then
|
if [ -f "/run/assets/$DETECTED.xml" ]; then
|
||||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||||
info "Detected: $desc"
|
info "Detected: $desc"
|
||||||
else
|
else
|
||||||
|
|
@ -546,7 +547,7 @@ prepareImage() {
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local dir="$2"
|
local dir="$2"
|
||||||
|
|
||||||
if [ -s "$dir/$ETFS" ] && [ -s "$dir/$EFISYS" ]; then
|
if [ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -566,7 +567,7 @@ updateImage() {
|
||||||
local asset="/run/assets/$3"
|
local asset="/run/assets/$3"
|
||||||
local path src loc index result
|
local path src loc index result
|
||||||
|
|
||||||
[ ! -s "$asset" ] && return 0
|
[ ! -s "$asset" ] || [ ! -f "$asset" ] && return 0
|
||||||
|
|
||||||
path=$(find "$dir" -maxdepth 1 -type f -iname autounattend.xml | head -n 1)
|
path=$(find "$dir" -maxdepth 1 -type f -iname autounattend.xml | head -n 1)
|
||||||
[ -n "$path" ] && cp "$asset" "$path"
|
[ -n "$path" ] && cp "$asset" "$path"
|
||||||
|
|
@ -579,9 +580,9 @@ updateImage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
loc=$(find "$src" -maxdepth 1 -type f -iname boot.wim | head -n 1)
|
loc=$(find "$src" -maxdepth 1 -type f -iname boot.wim | head -n 1)
|
||||||
[ ! -s "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1)
|
[ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1)
|
||||||
|
|
||||||
if [ ! -s "$loc" ]; then
|
if [ ! -f "$loc" ]; then
|
||||||
warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB"
|
warn "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
@ -659,7 +660,7 @@ if ! startInstall; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s "$ISO" ]; then
|
if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then
|
||||||
rm -f "$ISO"
|
rm -f "$ISO"
|
||||||
if ! downloadImage "$ISO" "$VERSION"; then
|
if ! downloadImage "$ISO" "$VERSION"; then
|
||||||
error "Failed to download $VERSION"
|
error "Failed to download $VERSION"
|
||||||
|
|
@ -694,7 +695,7 @@ if ! buildImage "$DIR"; then
|
||||||
exit 65
|
exit 65
|
||||||
fi
|
fi
|
||||||
|
|
||||||
finishInstall "$STORAGE/$BASE"
|
finishInstall "$STORAGE/$BASE" "N"
|
||||||
|
|
||||||
html "Successfully prepared image for installation..."
|
html "Successfully prepared image for installation..."
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue