fix: Verify files are not empty
This commit is contained in:
parent
334d2752c5
commit
2554395bf6
1 changed files with 17 additions and 14 deletions
|
|
@ -71,7 +71,7 @@ hasDisk() {
|
||||||
|
|
||||||
[ -b "${DEVICE:-}" ] && return 0
|
[ -b "${DEVICE:-}" ] && return 0
|
||||||
|
|
||||||
if [ -f "$STORAGE/data.img" ] || [ -f "$STORAGE/data.qcow2" ]; then
|
if [ -s "$STORAGE/data.img" ] || [ -s "$STORAGE/data.qcow2" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -172,6 +172,8 @@ startInstall() {
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
rm -f "$STORAGE/$BASE"
|
||||||
|
|
||||||
if skipInstall; then
|
if skipInstall; then
|
||||||
BASE=""
|
BASE=""
|
||||||
VGA="virtio-gpu"
|
VGA="virtio-gpu"
|
||||||
|
|
@ -237,7 +239,7 @@ getESD() {
|
||||||
|
|
||||||
cd /run
|
cd /run
|
||||||
|
|
||||||
if [ ! -f "$dir/products.xml" ]; then
|
if [ ! -s "$dir/products.xml" ]; then
|
||||||
error "Failed to find products.xml!" && return 1
|
error "Failed to find products.xml!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -312,7 +314,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
|
||||||
|
|
||||||
[ ! -f "$iso" ] && return 1
|
[ ! -s "$iso" ] && return 1
|
||||||
|
|
||||||
html "Download finished successfully..."
|
html "Download finished successfully..."
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -467,7 +469,7 @@ detectImage() {
|
||||||
|
|
||||||
if [ -n "$DETECTED" ]; then
|
if [ -n "$DETECTED" ]; then
|
||||||
|
|
||||||
if [ -f "/run/assets/$DETECTED.xml" ]; then
|
if [ -s "/run/assets/$DETECTED.xml" ]; then
|
||||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -495,9 +497,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)
|
||||||
[ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1)
|
[ ! -s "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname install.esd | head -n 1)
|
||||||
|
|
||||||
if [ ! -f "$loc" ]; then
|
if [ ! -s "$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
|
||||||
|
|
@ -524,7 +526,7 @@ detectImage() {
|
||||||
desc=$(printVersion "$DETECTED")
|
desc=$(printVersion "$DETECTED")
|
||||||
[ -z "$desc" ] && desc="$DETECTED"
|
[ -z "$desc" ] && desc="$DETECTED"
|
||||||
|
|
||||||
if [ -f "/run/assets/$DETECTED.xml" ]; then
|
if [ -s "/run/assets/$DETECTED.xml" ]; then
|
||||||
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
|
||||||
info "Detected: $desc"
|
info "Detected: $desc"
|
||||||
else
|
else
|
||||||
|
|
@ -539,7 +541,7 @@ prepareImage() {
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local dir="$2"
|
local dir="$2"
|
||||||
|
|
||||||
if [ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ]; then
|
if [ -s "$dir/$ETFS" ] && [ -s "$dir/$EFISYS" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -559,7 +561,7 @@ updateImage() {
|
||||||
local asset="/run/assets/$3"
|
local asset="/run/assets/$3"
|
||||||
local path src loc index result
|
local path src loc index result
|
||||||
|
|
||||||
[ ! -f "$asset" ] && return 0
|
[ ! -s "$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"
|
||||||
|
|
@ -572,9 +574,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)
|
||||||
[ ! -f "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1)
|
[ ! -s "$loc" ] && loc=$(find "$src" -maxdepth 1 -type f -iname boot.esd | head -n 1)
|
||||||
|
|
||||||
if [ ! -f "$loc" ]; then
|
if [ ! -s "$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
|
||||||
|
|
@ -626,14 +628,14 @@ buildImage() {
|
||||||
|
|
||||||
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \
|
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \
|
||||||
-udf -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -allow-limited-size -quiet "$dir" 2> "$log"; then
|
-udf -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -allow-limited-size -quiet "$dir" 2> "$log"; then
|
||||||
[ -f "$log" ] && echo "$(<"$log")"
|
[ -s "$log" ] && echo "$(<"$log")"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local error=""
|
local error=""
|
||||||
local hide="Warning: creating filesystem that does not conform to ISO-9660."
|
local hide="Warning: creating filesystem that does not conform to ISO-9660."
|
||||||
|
|
||||||
[ -f "$log" ] && error="$(<"$log")"
|
[ -s "$log" ] && error="$(<"$log")"
|
||||||
[[ "$error" != "$hide" ]] && echo "$error"
|
[[ "$error" != "$hide" ]] && echo "$error"
|
||||||
|
|
||||||
if [ -f "$STORAGE/$BASE" ]; then
|
if [ -f "$STORAGE/$BASE" ]; then
|
||||||
|
|
@ -652,7 +654,8 @@ if ! startInstall; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$ISO" ]; then
|
if [ ! -s "$ISO" ]; then
|
||||||
|
rm -f "$ISO"
|
||||||
if ! downloadImage "$ISO" "$VERSION"; then
|
if ! downloadImage "$ISO" "$VERSION"; then
|
||||||
error "Failed to download $VERSION"
|
error "Failed to download $VERSION"
|
||||||
exit 61
|
exit 61
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue