mirror of
https://github.com/dockur/windows.git
synced 2024-11-25 16:15:42 +00:00
fix: Verify files are not empty (#383)
This commit is contained in:
parent
2a98081549
commit
8a5f233e34
@ -1,5 +1,5 @@
|
|||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=qemux/qemu-docker:4.21 / /
|
COPY --from=qemux/qemu-docker:4.22 / /
|
||||||
|
|
||||||
ARG DEBCONF_NOWARNINGS "yes"
|
ARG DEBCONF_NOWARNINGS "yes"
|
||||||
ARG DEBIAN_FRONTEND "noninteractive"
|
ARG DEBIAN_FRONTEND "noninteractive"
|
||||||
|
@ -204,7 +204,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
|
||||||
|
|
||||||
@ -310,6 +310,8 @@ startInstall() {
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
rm -f "$STORAGE/$BASE"
|
||||||
|
|
||||||
if skipInstall; then
|
if skipInstall; then
|
||||||
BASE=""
|
BASE=""
|
||||||
return 1
|
return 1
|
||||||
@ -370,7 +372,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
|
||||||
|
|
||||||
@ -434,7 +436,7 @@ downloadImage() {
|
|||||||
|
|
||||||
if (( rc == 0 )); then
|
if (( rc == 0 )); then
|
||||||
|
|
||||||
[ ! -f "$iso" ] && return 1
|
[ ! -s "$iso" ] && return 1
|
||||||
|
|
||||||
html "Download finished successfully..."
|
html "Download finished successfully..."
|
||||||
return 0
|
return 0
|
||||||
@ -477,7 +479,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
|
||||||
@ -632,7 +634,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
|
||||||
@ -651,7 +653,7 @@ detectImage() {
|
|||||||
|
|
||||||
info "Detecting Windows version from ISO image..."
|
info "Detecting Windows version from ISO image..."
|
||||||
|
|
||||||
if [ -f "$dir/WIN51" ] || [ -f "$dir/SETUPXP.HTM" ]; then
|
if [ -s "$dir/WIN51" ] || [ -s "$dir/SETUPXP.HTM" ]; then
|
||||||
DETECTED="winxpx86"
|
DETECTED="winxpx86"
|
||||||
info "Detected: Windows XP"
|
info "Detected: Windows XP"
|
||||||
return 0
|
return 0
|
||||||
@ -667,9 +669,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"
|
||||||
BOOT_MODE="windows_legacy"
|
BOOT_MODE="windows_legacy"
|
||||||
return 1
|
return 1
|
||||||
@ -697,7 +699,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
|
||||||
@ -917,7 +919,7 @@ prepareImage() {
|
|||||||
if [[ "${DETECTED,,}" != "winxp"* ]] && [[ "${DETECTED,,}" != "win2008"* ]]; then
|
if [[ "${DETECTED,,}" != "winxp"* ]] && [[ "${DETECTED,,}" != "win2008"* ]]; then
|
||||||
if [[ "${DETECTED,,}" != "winvista"* ]] && [[ "${DETECTED,,}" != "win7"* ]]; then
|
if [[ "${DETECTED,,}" != "winvista"* ]] && [[ "${DETECTED,,}" != "win7"* ]]; then
|
||||||
|
|
||||||
if [ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ]; then
|
if [ -s "$dir/$ETFS" ] && [ -s "$dir/$EFISYS" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -953,7 +955,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"
|
||||||
@ -967,9 +969,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"
|
||||||
BOOT_MODE="windows_legacy"
|
BOOT_MODE="windows_legacy"
|
||||||
return 1
|
return 1
|
||||||
@ -1024,7 +1026,7 @@ 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
|
||||||
|
|
||||||
@ -1034,7 +1036,7 @@ buildImage() {
|
|||||||
|
|
||||||
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \
|
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \
|
||||||
-udf -allow-limited-size -quiet "$dir" 2> "$log"; then
|
-udf -allow-limited-size -quiet "$dir" 2> "$log"; then
|
||||||
[ -f "$log" ] && echo "$(<"$log")"
|
[ -s "$log" ] && echo "$(<"$log")"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1042,7 +1044,7 @@ buildImage() {
|
|||||||
|
|
||||||
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -c "$cat" -iso-level 2 -J -l -D -N -joliet-long \
|
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -c "$cat" -iso-level 2 -J -l -D -N -joliet-long \
|
||||||
-relaxed-filenames -V "$label" -quiet "$dir" 2> "$log"; then
|
-relaxed-filenames -V "$label" -quiet "$dir" 2> "$log"; then
|
||||||
[ -f "$log" ] && echo "$(<"$log")"
|
[ -s "$log" ] && echo "$(<"$log")"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1052,7 +1054,7 @@ buildImage() {
|
|||||||
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
|
||||||
@ -1078,7 +1080,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
|
||||||
|
14
src/power.sh
14
src/power.sh
@ -25,7 +25,7 @@ _trap() {
|
|||||||
ready() {
|
ready() {
|
||||||
|
|
||||||
[ -f "$STORAGE/windows.boot" ] && return 0
|
[ -f "$STORAGE/windows.boot" ] && return 0
|
||||||
[ ! -f "$QEMU_PTY" ] && return 1
|
[ ! -s "$QEMU_PTY" ] && return 1
|
||||||
|
|
||||||
if [ -f "$STORAGE/windows.old" ]; then
|
if [ -f "$STORAGE/windows.old" ]; then
|
||||||
local last
|
local last
|
||||||
@ -52,7 +52,7 @@ finish() {
|
|||||||
|
|
||||||
touch "$QEMU_END"
|
touch "$QEMU_END"
|
||||||
|
|
||||||
if [ -f "$QEMU_PID" ]; then
|
if [ -s "$QEMU_PID" ]; then
|
||||||
|
|
||||||
pid=$(<"$QEMU_PID")
|
pid=$(<"$QEMU_PID")
|
||||||
error "Forcefully terminating Windows, reason: $reason..."
|
error "Forcefully terminating Windows, reason: $reason..."
|
||||||
@ -61,7 +61,7 @@ finish() {
|
|||||||
while isAlive "$pid"; do
|
while isAlive "$pid"; do
|
||||||
sleep 1
|
sleep 1
|
||||||
# Workaround for zombie pid
|
# Workaround for zombie pid
|
||||||
[ ! -f "$QEMU_PID" ] && break
|
[ ! -s "$QEMU_PID" ] && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ finish() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
pid="/var/run/tpm.pid"
|
pid="/var/run/tpm.pid"
|
||||||
[ -f "$pid" ] && pKill "$(<"$pid")"
|
[ -s "$pid" ] && pKill "$(<"$pid")"
|
||||||
|
|
||||||
fKill "wsdd"
|
fKill "wsdd"
|
||||||
fKill "smbd"
|
fKill "smbd"
|
||||||
@ -91,7 +91,7 @@ terminal() {
|
|||||||
|
|
||||||
local dev=""
|
local dev=""
|
||||||
|
|
||||||
if [ -f "$QEMU_OUT" ]; then
|
if [ -s "$QEMU_OUT" ]; then
|
||||||
|
|
||||||
local msg
|
local msg
|
||||||
msg=$(<"$QEMU_OUT")
|
msg=$(<"$QEMU_OUT")
|
||||||
@ -139,7 +139,7 @@ _graceful_shutdown() {
|
|||||||
touch "$QEMU_END"
|
touch "$QEMU_END"
|
||||||
info "Received $1, sending ACPI shutdown signal..."
|
info "Received $1, sending ACPI shutdown signal..."
|
||||||
|
|
||||||
if [ ! -f "$QEMU_PID" ]; then
|
if [ ! -s "$QEMU_PID" ]; then
|
||||||
error "QEMU PID file does not exist?"
|
error "QEMU PID file does not exist?"
|
||||||
finish "$code" && return "$code"
|
finish "$code" && return "$code"
|
||||||
fi
|
fi
|
||||||
@ -168,7 +168,7 @@ _graceful_shutdown() {
|
|||||||
|
|
||||||
! isAlive "$pid" && break
|
! isAlive "$pid" && break
|
||||||
# Workaround for zombie pid
|
# Workaround for zombie pid
|
||||||
[ ! -f "$QEMU_PID" ] && break
|
[ ! -s "$QEMU_PID" ] && break
|
||||||
|
|
||||||
info "Waiting for Windows to shutdown... ($cnt/$QEMU_TIMEOUT)"
|
info "Waiting for Windows to shutdown... ($cnt/$QEMU_TIMEOUT)"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user