mirror of
https://github.com/dockur/windows-arm.git
synced 2024-11-17 18:51:49 +00:00
fix: Refactor code for legacy machines (#138)
This commit is contained in:
parent
f1ff8cd343
commit
3460fea0f0
2 changed files with 24 additions and 46 deletions
|
@ -687,10 +687,6 @@ migrateFiles() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
skipVersion() {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
detectLegacy() {
|
detectLegacy() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -699,4 +695,12 @@ prepareLegacy() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skipVersion() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setMachine() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -515,7 +515,12 @@ detectImage() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Detecting version from ISO image..."
|
info "Detecting version from ISO image..."
|
||||||
detectLegacy "$dir" && return 0
|
|
||||||
|
if detectLegacy "$dir"; then
|
||||||
|
desc=$(printEdition "$DETECTED" "$DETECTED")
|
||||||
|
info "Detected: $desc"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
local src wim info
|
local src wim info
|
||||||
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1)
|
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1)
|
||||||
|
@ -579,39 +584,8 @@ prepareImage() {
|
||||||
|
|
||||||
desc=$(printVersion "$DETECTED" "$DETECTED")
|
desc=$(printVersion "$DETECTED" "$DETECTED")
|
||||||
|
|
||||||
case "${DETECTED,,}" in
|
! setMachine "$DETECTED" "$iso" "$dir" "$desc" && return 1
|
||||||
"win9"* | "win2k"* )
|
skipVersion "$DETECTED" && return 0
|
||||||
MACHINE="pc-i440fx-2.4" ;;
|
|
||||||
"winvistax86"* | "win7x86"* | "winxp"* | "win2003"* )
|
|
||||||
MACHINE="pc-q35-2.10" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "${DETECTED,,}" in
|
|
||||||
"win9"* | "win2k"* | "winxp"* | "win2003"* )
|
|
||||||
HV="N"
|
|
||||||
BOOT_MODE="windows_legacy" ;;
|
|
||||||
"winvista"* | "win7"* | "win2008"* )
|
|
||||||
BOOT_MODE="windows_legacy" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "${DETECTED,,}" in
|
|
||||||
"win9"* )
|
|
||||||
DISK_TYPE="auto"
|
|
||||||
prepare9x "$iso" "$dir" "$desc" && return 0
|
|
||||||
error "Failed to prepare $desc ISO!" && return 1 ;;
|
|
||||||
"win2k"* )
|
|
||||||
DISK_TYPE="auto"
|
|
||||||
prepare2k "$iso" "$dir" "$desc" && return 0
|
|
||||||
error "Failed to prepare $desc ISO!" && return 1 ;;
|
|
||||||
"winxp"* )
|
|
||||||
DISK_TYPE="blk"
|
|
||||||
prepareXP "$iso" "$dir" "$desc" && return 0
|
|
||||||
error "Failed to prepare $desc ISO!" && return 1 ;;
|
|
||||||
"win2003"* )
|
|
||||||
DISK_TYPE="blk"
|
|
||||||
prepare2k3 "$iso" "$dir" "$desc" && return 0
|
|
||||||
error "Failed to prepare $desc ISO!" && return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
|
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
|
||||||
|
|
||||||
|
@ -620,13 +594,13 @@ prepareImage() {
|
||||||
missing=$(basename "$dir/$EFISYS")
|
missing=$(basename "$dir/$EFISYS")
|
||||||
[ ! -f "$dir/$ETFS" ] && missing=$(basename "$dir/$ETFS")
|
[ ! -f "$dir/$ETFS" ] && missing=$(basename "$dir/$ETFS")
|
||||||
|
|
||||||
error "Failed to locate file \"${missing,,}\" in $desc ISO image!"
|
error "Failed to locate file \"${missing,,}\" in ISO image!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prepareLegacy "$iso" "$dir" "$desc" && return 0
|
prepareLegacy "$iso" "$dir" "$desc" && return 0
|
||||||
|
|
||||||
error "Failed to extract boot image from $desc ISO image!"
|
error "Failed to extract boot image from ISO image!"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,10 +901,6 @@ buildImage() {
|
||||||
error "File $BOOT does already exist?!" && return 1
|
error "File $BOOT does already exist?!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$dir/$ETFS" ]; then
|
|
||||||
error "Failed to locate file \"$ETFS\" in ISO image!" && return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
base=$(basename "$BOOT")
|
base=$(basename "$BOOT")
|
||||||
local out="$TMP/${base%.*}.tmp"
|
local out="$TMP/${base%.*}.tmp"
|
||||||
rm -f "$out"
|
rm -f "$out"
|
||||||
|
@ -940,6 +910,12 @@ buildImage() {
|
||||||
local msg="Building $desc image..."
|
local msg="Building $desc image..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
|
[ -z "$LABEL" ] && LABEL="Windows"
|
||||||
|
|
||||||
|
if [ ! -f "$dir/$ETFS" ]; then
|
||||||
|
error "Failed to locate file \"$ETFS\" in ISO image!" && return 1
|
||||||
|
fi
|
||||||
|
|
||||||
size=$(du -h -b --max-depth=0 "$dir" | cut -f1)
|
size=$(du -h -b --max-depth=0 "$dir" | cut -f1)
|
||||||
size_gb=$(( (size + 1073741823)/1073741824 ))
|
size_gb=$(( (size + 1073741823)/1073741824 ))
|
||||||
space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
|
space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
|
||||||
|
@ -949,8 +925,6 @@ buildImage() {
|
||||||
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
|
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$LABEL" ] && LABEL="Windows"
|
|
||||||
|
|
||||||
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
|
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
|
||||||
|
|
||||||
! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "${LABEL::30}" \
|
! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "${LABEL::30}" \
|
||||||
|
|
Loading…
Reference in a new issue