feat: Added alternative download method for Win 10 & 11

This commit is contained in:
Kroese 2024-02-04 18:34:03 +01:00 committed by GitHub
parent 367f70bd28
commit b012f212dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -364,7 +364,7 @@ getESD() {
local dir="$1" local dir="$1"
local file="$2" local file="$2"
local architecture="x64" local architecture="x64"
local winCatalog space space_gb size local winCatalog size
case "${VERSION,,}" in case "${VERSION,,}" in
win11x64) win11x64)
@ -385,18 +385,8 @@ getESD() {
rm -rf "$dir" rm -rf "$dir"
mkdir -p "$dir" mkdir -p "$dir"
space=$(df --output=avail -B 1 "$dir" | tail -n 1)
space_gb=$(( (space + 1073741823)/1073741824 ))
if (( 12884901888 > space )); then
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least 12 GB."
return 1
fi
local wFile="catalog.cab" local wFile="catalog.cab"
mkdir -p "$dir"
{ wget "$winCatalog" -O "$dir/$wFile" -q --no-check-certificate; rc=$?; } || : { wget "$winCatalog" -O "$dir/$wFile" -q --no-check-certificate; rc=$?; } || :
(( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1 (( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1
@ -461,46 +451,44 @@ downloadImage() {
local msg="Downloading $desc..." local msg="Downloading $desc..."
info "$msg" && html "$msg" info "$msg" && html "$msg"
/run/progress.sh "$file" "Downloading $desc ([P])..." & /run/progress.sh "$file" "Downloading $desc ([P])..." &
if [[ "$EXTERNAL" != [Yy1]* ]]; then if [[ "$EXTERNAL" != [Yy1]* ]]; then
#cd "$TMP" cd "$TMP"
#{ /run/mido.sh "$url"; rc=$?; } || : { /run/mido.sh "$url"; rc=$?; } || :
#cd /run cd /run
rc=5
fKill "progress.sh" fKill "progress.sh"
if (( rc == 0 )); then if (( rc == 0 )); then
[ ! -f "$iso" ] && return 1 [ ! -f "$iso" ] && return 1
html "Download finished successfully..." html "Download finished successfully..."
return 0 return 0
fi fi
if [[ "$VERSION" != "win10x64"* ]] && [[ "$VERSION" != "win11x64" ]]; then if [[ "$VERSION" != "win10x64"* ]] && [[ "$VERSION" != "win11x64" ]]; then
return 1 return 1
fi fi
info "Failed to download $desc via Mido, will try a different method now..." info "Failed to download $desc using Mido, will try a different method now..."
ISO="$TMP/$VERSION.esd" ISO="$TMP/$VERSION.esd"
iso="$ISO"
file="$ISO" file="$ISO"
rm -f "$file" rm -f "$iso"
/run/progress.sh "$file" "Downloading $desc ([P])..." & if ! getESD "$TMP/esd" "$iso"; then
if ! getESD "$TMP/esd" "$file"; then
return 1 return 1
fi fi
url="$ESD_URL" url="$ESD_URL"
info "$url" msg="Downloading $desc..."
exit 44 info "$msg" && html "$msg"
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
fi fi
# Check if running with interactive TTY or redirected to docker log # Check if running with interactive TTY or redirected to docker log
@ -531,7 +519,7 @@ extractESD() {
local msg="Extracting $desc bootdisk..." local msg="Extracting $desc bootdisk..."
info "$msg" && html "$msg" info "$msg" && html "$msg"
size=$(stat -c%s "$iso") size=16106127360
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)
space_gb=$(( (space + 1073741823)/1073741824 )) space_gb=$(( (space + 1073741823)/1073741824 ))
@ -550,9 +538,9 @@ extractESD() {
local esdImageCount local esdImageCount
esdImageCount=$(wimlib-imagex info "${iso}" | awk '/Image Count:/ {print $3}') esdImageCount=$(wimlib-imagex info "${iso}" | awk '/Image Count:/ {print $3}')
wimlib-imagex apply "$iso" 1 "${dir}" --nocheck --compress=none --quiet 2>/dev/null || { wimlib-imagex apply "$iso" 1 "${dir}" --quiet 2>/dev/null || {
retVal=$? retVal=$?
error "Extract of boot files failed" && return $retVal error "Extracting bootdisk failed" && return $retVal
} }
local bootWimFile="${dir}/sources/boot.wim" local bootWimFile="${dir}/sources/boot.wim"
@ -561,7 +549,7 @@ extractESD() {
local msg="Extracting $desc environment..." local msg="Extracting $desc environment..."
info "$msg" && html "$msg" info "$msg" && html "$msg"
wimlib-imagex export "${iso}" 2 "${bootWimFile}" --nocheck --compress=none --quiet || { wimlib-imagex export "${iso}" 2 "${bootWimFile}" --compress=LZX --chunk-size 32K --quiet || {
retVal=$? retVal=$?
error "Adding WinPE failed" && return ${retVal} error "Adding WinPE failed" && return ${retVal}
} }
@ -569,7 +557,7 @@ extractESD() {
local msg="Extracting $desc setup..." local msg="Extracting $desc setup..."
info "$msg" && html "$msg" info "$msg" && html "$msg"
wimlib-imagex export "${iso}" 3 "$bootWimFile" --nocheck --compress=none --boot --quiet || { wimlib-imagex export "${iso}" 3 "$bootWimFile" --compress=LZX --chunk-size 32K --boot --quiet || {
retVal=$? retVal=$?
error "Adding Windows Setup failed" && return ${retVal} error "Adding Windows Setup failed" && return ${retVal}
} }
@ -580,10 +568,10 @@ extractESD() {
local edition imageIndex imageEdition local edition imageIndex imageEdition
case "${VERSION,,}" in case "${VERSION,,}" in
win11arm) win11x64)
edition="11 pro" edition="11 pro"
;; ;;
win10arm) win10x64)
edition="10 pro" edition="10 pro"
;; ;;
*) *)
@ -594,16 +582,16 @@ extractESD() {
for (( imageIndex=4; imageIndex<=esdImageCount; imageIndex++ )); do for (( imageIndex=4; imageIndex<=esdImageCount; imageIndex++ )); do
imageEdition=$(wimlib-imagex info "${iso}" ${imageIndex} | grep '^Description:' | sed 's/Description:[ \t]*//') imageEdition=$(wimlib-imagex info "${iso}" ${imageIndex} | grep '^Description:' | sed 's/Description:[ \t]*//')
error "$imageEdition"
[[ "${imageEdition,,}" != *"$edition"* ]] && continue [[ "${imageEdition,,}" != *"$edition"* ]] && continue
wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --nocheck --compress=none --quiet || { wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --compress=LZMS --chunk-size 128K --quiet || {
retVal=$? retVal=$?
error "Addition of ${imageIndex} to the image failed" && return $retVal error "Addition of ${imageIndex} to the image failed" && return $retVal
} }
break return 0
done done
return 0 error "Failed to find product in install.wim!"
return 1
} }
extractImage() { extractImage() {