mirror of
https://github.com/dockur/windows.git
synced 2026-08-05 05:27:23 +01:00
Update install.sh
This commit is contained in:
+65
-11
@@ -1,6 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
getTimeMillis() {
|
||||||
|
|
||||||
|
date +%s%3N
|
||||||
|
}
|
||||||
|
|
||||||
|
logTiming() {
|
||||||
|
|
||||||
|
local label="$1"
|
||||||
|
local started="$2"
|
||||||
|
|
||||||
|
local elapsed finished millis seconds
|
||||||
|
|
||||||
|
finished=$(getTimeMillis) || return 1
|
||||||
|
elapsed=$(( finished - started ))
|
||||||
|
seconds=$(( elapsed / 1000 ))
|
||||||
|
millis=$(( elapsed % 1000 ))
|
||||||
|
|
||||||
|
printf -v millis '%03d' "$millis"
|
||||||
|
info "Timing: $label took ${seconds}.${millis} seconds."
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
startWindows() {
|
startWindows() {
|
||||||
|
|
||||||
parseVersion || exit 58
|
parseVersion || exit 58
|
||||||
@@ -139,6 +162,8 @@ prepareWindowsImage() {
|
|||||||
local dir="$2"
|
local dir="$2"
|
||||||
local boot="$3"
|
local boot="$3"
|
||||||
|
|
||||||
|
local started
|
||||||
|
|
||||||
# Prefer the original ISO with a small setup image whenever possible.
|
# Prefer the original ISO with a small setup image whenever possible.
|
||||||
if canUseSetupImage "$DETECTED" "$iso"; then
|
if canUseSetupImage "$DETECTED" "$iso"; then
|
||||||
|
|
||||||
@@ -165,20 +190,31 @@ prepareWindowsImage() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
if ! prepareImage "$iso" "$dir"; then
|
if ! prepareImage "$iso" "$dir"; then
|
||||||
skipUnattended "$dir" "$iso" "$boot" || return 92
|
skipUnattended "$dir" "$iso" "$boot" || return 92
|
||||||
handled=1
|
handled=1
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
logTiming "preparing the extracted image" "$started" || return 1
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
if ! updateImage "$dir" "$XML" "$LANGUAGE"; then
|
if ! updateImage "$dir" "$XML" "$LANGUAGE"; then
|
||||||
skipUnattended "$dir" "$iso" "$boot" || return 94
|
skipUnattended "$dir" "$iso" "$boot" || return 94
|
||||||
handled=1
|
handled=1
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
logTiming "updating the extracted image" "$started" || return 1
|
||||||
|
|
||||||
removeImage "$iso" || return 96
|
removeImage "$iso" || return 96
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
buildImage "$dir" || return 98
|
buildImage "$dir" || return 98
|
||||||
|
logTiming "building the ISO image" "$started" || return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -640,6 +676,7 @@ extractESD() {
|
|||||||
local installSize size edition imgEdition
|
local installSize size edition imgEdition
|
||||||
local bootWim installWim bootSize wimSize
|
local bootWim installWim bootSize wimSize
|
||||||
local index line ret xml metadata count
|
local index line ret xml metadata count
|
||||||
|
local started totalStarted
|
||||||
local -a fields
|
local -a fields
|
||||||
|
|
||||||
local minSize=100000000
|
local minSize=100000000
|
||||||
@@ -647,16 +684,18 @@ extractESD() {
|
|||||||
local bootPad=60000000
|
local bootPad=60000000
|
||||||
local installPad=3000000
|
local installPad=3000000
|
||||||
|
|
||||||
local msg="Extracting $desc bootdisk"
|
totalStarted=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
|
local msg="Extracting $desc bootdisk from ESD file"
|
||||||
info "$msg..." && html "$msg..."
|
info "$msg..." && html "$msg..."
|
||||||
|
|
||||||
if ! size=$(stat -c%s -- "$iso"); then
|
if ! size=$(stat -c%s -- "$iso"); then
|
||||||
error "Failed to determine size of ISO file \"$iso\" !"
|
error "Failed to determine size of ESD file \"$iso\" !"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( size < minSize )); then
|
if (( size < minSize )); then
|
||||||
error "The downloaded ISO file is too small!"
|
error "The downloaded ESD file is too small!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -672,6 +711,8 @@ extractESD() {
|
|||||||
|
|
||||||
checkFreeSpace "$dir" "$freeSpace" || return 1
|
checkFreeSpace "$dir" "$freeSpace" || return 1
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
if ! xml=$(wimlib-imagex info "$iso" --xml 2>/dev/null |
|
if ! xml=$(wimlib-imagex info "$iso" --xml 2>/dev/null |
|
||||||
iconv -f UTF-16LE -t UTF-8 2>/dev/null); then
|
iconv -f UTF-16LE -t UTF-8 2>/dev/null); then
|
||||||
error "Cannot read ESD file information!"
|
error "Cannot read ESD file information!"
|
||||||
@@ -693,6 +734,8 @@ extractESD() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
logTiming "reading ESD metadata" "$started" || return 1
|
||||||
|
|
||||||
mapfile -t fields <<< "$metadata"
|
mapfile -t fields <<< "$metadata"
|
||||||
|
|
||||||
count="${fields[0]:-}"
|
count="${fields[0]:-}"
|
||||||
@@ -731,14 +774,17 @@ extractESD() {
|
|||||||
/run/progress.sh "$dir" "$bootSize" "$msg ([P])..." &
|
/run/progress.sh "$dir" "$bootSize" "$msg ([P])..." &
|
||||||
|
|
||||||
index="1"
|
index="1"
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
wimlib-imagex apply "$iso" "$index" "$dir" --quiet 2>/dev/null || {
|
wimlib-imagex apply "$iso" "$index" "$dir" --quiet 2>/dev/null || {
|
||||||
ret=$?
|
ret=$?
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
error "Extracting $desc bootdisk failed ($ret)"
|
error "$msg failed ($ret)"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
logTiming "applying ESD image 1 (bootdisk)" "$started" || return 1
|
||||||
|
|
||||||
bootWim="$dir/sources/boot.wim"
|
bootWim="$dir/sources/boot.wim"
|
||||||
installWim="$dir/sources/install.wim"
|
installWim="$dir/sources/install.wim"
|
||||||
@@ -749,6 +795,8 @@ extractESD() {
|
|||||||
index="2"
|
index="2"
|
||||||
/run/progress.sh "$bootWim" "$wimSize" "$msg ([P])..." &
|
/run/progress.sh "$bootWim" "$wimSize" "$msg ([P])..." &
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
wimlib-imagex export "$iso" "$index" "$bootWim" \
|
wimlib-imagex export "$iso" "$index" "$bootWim" \
|
||||||
--compress=none --quiet || {
|
--compress=none --quiet || {
|
||||||
ret=$?
|
ret=$?
|
||||||
@@ -758,6 +806,7 @@ extractESD() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
logTiming "exporting ESD image 2 (WinPE)" "$started" || return 1
|
||||||
|
|
||||||
msg="Extracting $desc setup"
|
msg="Extracting $desc setup"
|
||||||
info "$msg..."
|
info "$msg..."
|
||||||
@@ -765,6 +814,8 @@ extractESD() {
|
|||||||
index="3"
|
index="3"
|
||||||
/run/progress.sh "$bootWim" "$wimSize" "$msg ([P])..." &
|
/run/progress.sh "$bootWim" "$wimSize" "$msg ([P])..." &
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
wimlib-imagex export "$iso" "$index" "$bootWim" \
|
wimlib-imagex export "$iso" "$index" "$bootWim" \
|
||||||
--compress=none --boot --quiet || {
|
--compress=none --boot --quiet || {
|
||||||
ret=$?
|
ret=$?
|
||||||
@@ -774,6 +825,7 @@ extractESD() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
logTiming "exporting ESD image 3 (Windows Setup)" "$started" || return 1
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
||||||
LABEL="CCCOMA_X64FRE_EN-US_DV9"
|
LABEL="CCCOMA_X64FRE_EN-US_DV9"
|
||||||
@@ -801,6 +853,8 @@ extractESD() {
|
|||||||
|
|
||||||
/run/progress.sh "$installWim" "$installSize" "$msg ([P])..." &
|
/run/progress.sh "$installWim" "$installSize" "$msg ([P])..." &
|
||||||
|
|
||||||
|
started=$(getTimeMillis) || return 1
|
||||||
|
|
||||||
wimlib-imagex export "$iso" "$index" "$installWim" --quiet || {
|
wimlib-imagex export "$iso" "$index" "$installWim" --quiet || {
|
||||||
ret=$?
|
ret=$?
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
@@ -809,6 +863,8 @@ extractESD() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
logTiming "exporting ESD image $index ($edition)" "$started" || return 1
|
||||||
|
logTiming "total ESD extraction" "$totalStarted" || return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
done
|
done
|
||||||
@@ -923,10 +979,8 @@ prepareImage() {
|
|||||||
desc=$(printVariant "$DETECTED" "$DETECTED")
|
desc=$(printVariant "$DETECTED" "$DETECTED")
|
||||||
|
|
||||||
# Legacy rebuilt media must retain the source ISO's El Torito boot-load size.
|
# Legacy rebuilt media must retain the source ISO's El Torito boot-load size.
|
||||||
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
if [[ "${BOOT_MODE,,}" == "windows_legacy" && "${DETECTED,,}" != "win9"* ]]; then
|
||||||
if [[ "${DETECTED,,}" != "win9"* && "${DETECTED,,}" != "winnt4" ]]; then
|
getBootLoadSize "$iso" "$dir" "$desc" || return 1
|
||||||
getBootLoadSize "$iso" "$dir" "$desc" || return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
supportsXML "$DETECTED" || return 0
|
supportsXML "$DETECTED" || return 0
|
||||||
@@ -1588,7 +1642,7 @@ setMachine() {
|
|||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
|
|
||||||
"win9"* | "winnt4" )
|
"win9"* )
|
||||||
|
|
||||||
writeState "usb" "N" || return 1
|
writeState "usb" "N" || return 1
|
||||||
writeState "net" "pcnet" || return 1
|
writeState "net" "pcnet" || return 1
|
||||||
@@ -1628,7 +1682,7 @@ setMachine() {
|
|||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
|
|
||||||
"win9"* | "winnt4" | "win2k"* | *"x86"* | "reactos" )
|
"win9"* | "win2k"* | *"x86"* | "reactos" )
|
||||||
|
|
||||||
# Legacy 32-bit Windows may enter an incompatible PAE/DEP path when the
|
# Legacy 32-bit Windows may enter an incompatible PAE/DEP path when the
|
||||||
# NX flag is exposed, causing installation failures or repeated resets.
|
# NX flag is exposed, causing installation failures or repeated resets.
|
||||||
@@ -1639,7 +1693,7 @@ setMachine() {
|
|||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
|
|
||||||
"win9"* | "winnt4" | "win2k"* | "winxp"* | "win2003"* | \
|
"win9"* | "win2k"* | "winxp"* | "win2003"* | \
|
||||||
"winvistax86"* | "win7x86"* | "reactos" )
|
"winvistax86"* | "win7x86"* | "reactos" )
|
||||||
|
|
||||||
if isQ35 "$MACHINE"; then
|
if isQ35 "$MACHINE"; then
|
||||||
|
|||||||
Reference in New Issue
Block a user