mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 19:35:49 +00:00
feat: Support downloading older builds
This commit is contained in:
parent
8471d296ea
commit
b21265ebf0
1 changed files with 73 additions and 49 deletions
122
src/mido.sh
122
src/mido.sh
|
|
@ -364,6 +364,36 @@ getWindows() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBuild() {
|
||||||
|
|
||||||
|
local id="$1"
|
||||||
|
local ret="$2"
|
||||||
|
local url=""
|
||||||
|
local name=""
|
||||||
|
local build="$3"
|
||||||
|
local edition=""
|
||||||
|
local file="catalog.xml"
|
||||||
|
|
||||||
|
case "${id,,}" in
|
||||||
|
"win11${PLATFORM,,}" )
|
||||||
|
name="Windows 11 Pro"
|
||||||
|
url="https://worproject.com/dldserv/esd/getcatalog.php?build=${build}&arch=${PLATFORM^^}&edition=Professional" ;;
|
||||||
|
"win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval")
|
||||||
|
name="Windows 11 Enterprise"
|
||||||
|
url="https://worproject.com/dldserv/esd/getcatalog.php?build=${build}&arch=${PLATFORM^^}&edition=Enterprise" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${ret,,}" in
|
||||||
|
"url" ) echo "$url" ;;
|
||||||
|
"file" ) echo "$file" ;;
|
||||||
|
"name" ) echo "$name" ;;
|
||||||
|
"edition" ) echo "$edition" ;;
|
||||||
|
*) echo "";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
getCatalog() {
|
getCatalog() {
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
|
|
@ -373,6 +403,15 @@ getCatalog() {
|
||||||
local edition=""
|
local edition=""
|
||||||
local file="catalog.cab"
|
local file="catalog.cab"
|
||||||
|
|
||||||
|
if [[ "${PLATFORM,,}" == "arm64" && "${ARCH,,}" == "arm64" ]];
|
||||||
|
|
||||||
|
# ARMv8.0 and lower cannot run Windows 11 builds higher than 22631
|
||||||
|
if ! grep -qw 'Features.*atomics' /proc/cpuinfo; then
|
||||||
|
echo $(getBuild "$1" "$2" "22631.2861") && return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
"win11${PLATFORM,,}" )
|
"win11${PLATFORM,,}" )
|
||||||
edition="Professional"
|
edition="Professional"
|
||||||
|
|
@ -396,38 +435,7 @@ getCatalog() {
|
||||||
"url" ) echo "$url" ;;
|
"url" ) echo "$url" ;;
|
||||||
"file" ) echo "$file" ;;
|
"file" ) echo "$file" ;;
|
||||||
"name" ) echo "$name" ;;
|
"name" ) echo "$name" ;;
|
||||||
"edition" ) echo "$edition" ;;
|
"edition" ) echo '[Edition="'"${edition}"'"]' ;;
|
||||||
*) echo "";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
getOldCatalog() {
|
|
||||||
|
|
||||||
local id="$1"
|
|
||||||
local ret="$2"
|
|
||||||
local url=""
|
|
||||||
local name=""
|
|
||||||
local edition=""
|
|
||||||
local file="catalog.xml"
|
|
||||||
|
|
||||||
case "${id,,}" in
|
|
||||||
"win11${PLATFORM,,}" )
|
|
||||||
edition="Professional"
|
|
||||||
name="Windows 11 Pro"
|
|
||||||
url="https://worproject.com/dldserv/esd/getcatalog.php?build=22631.2861&arch=ARM64&edition=Professional" ;;
|
|
||||||
"win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval")
|
|
||||||
edition="Enterprise"
|
|
||||||
name="Windows 11 Enterprise"
|
|
||||||
url="https://worproject.com/dldserv/esd/getcatalog.php?build=22631.2861&arch=ARM64&edition=Enterprise" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "${ret,,}" in
|
|
||||||
"url" ) echo "$url" ;;
|
|
||||||
"file" ) echo "$file" ;;
|
|
||||||
"name" ) echo "$name" ;;
|
|
||||||
"edition" ) echo "$edition" ;;
|
|
||||||
*) echo "";;
|
*) echo "";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -444,15 +452,15 @@ getESD() {
|
||||||
local result
|
local result
|
||||||
local culture
|
local culture
|
||||||
local language
|
local language
|
||||||
local editionName
|
local edition
|
||||||
local winCatalog
|
local catalog
|
||||||
|
|
||||||
file=$(getCatalog "$version" "file")
|
file=$(getCatalog "$version" "file")
|
||||||
|
catalog=$(getCatalog "$version" "url")
|
||||||
culture=$(getLanguage "$lang" "culture")
|
culture=$(getLanguage "$lang" "culture")
|
||||||
winCatalog=$(getCatalog "$version" "url")
|
edition=$(getCatalog "$version" "edition")
|
||||||
editionName=$(getCatalog "$version" "edition")
|
|
||||||
|
|
||||||
if [ -z "$file" ] || [ -z "$winCatalog" ] || [ -z "$editionName" ]; then
|
if [ -z "$file" ] || [ -z "$catalog" ]; then
|
||||||
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -466,9 +474,9 @@ getESD() {
|
||||||
local eFile="esd_edition.xml"
|
local eFile="esd_edition.xml"
|
||||||
local fFile="products_filter.xml"
|
local fFile="products_filter.xml"
|
||||||
|
|
||||||
{ wget "$winCatalog" -O "$dir/$file" -q --timeout=30 --no-http-keep-alive; rc=$?; } || :
|
{ wget "$catalog" -O "$dir/$file" -q --timeout=30 --no-http-keep-alive; rc=$?; } || :
|
||||||
|
|
||||||
msg="Failed to download $winCatalog"
|
msg="Failed to download $catalog"
|
||||||
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
|
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
|
||||||
(( rc == 4 )) && error "$msg , network failure!" && return 1
|
(( rc == 4 )) && error "$msg , network failure!" && return 1
|
||||||
(( rc == 8 )) && error "$msg , server issued an error response!" && return 1
|
(( rc == 8 )) && error "$msg , server issued an error response!" && return 1
|
||||||
|
|
@ -495,12 +503,13 @@ getESD() {
|
||||||
error "Failed to find $xFile in $file!" && return 1
|
error "Failed to find $xFile in $file!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local edQuery='//File[Architecture="'${PLATFORM,,}'"][Edition="'${editionName}'"]'
|
local edQuery='//File[Architecture="'${PLATFORM,,}'"]'"${edition}"''
|
||||||
result=$(xmllint --nonet --xpath "${edQuery}" "$dir/$xFile" 2>/dev/null)
|
result=$(xmllint --nonet --xpath "${edQuery}" "$dir/$xFile" 2>/dev/null)
|
||||||
|
|
||||||
if [ -z "$result" ]; then
|
if [ -z "$result" ]; then
|
||||||
|
|
||||||
edQuery='//File[Architecture="'${PLATFORM^^}'"][Edition="'${editionName}'"]'
|
edQuery='//File[Architecture="'${PLATFORM^^}'"]'"${edition}"''
|
||||||
|
|
||||||
result=$(xmllint --nonet --xpath "${edQuery}" "$dir/$xFile" 2>/dev/null)
|
result=$(xmllint --nonet --xpath "${edQuery}" "$dir/$xFile" 2>/dev/null)
|
||||||
|
|
||||||
if [ -z "$result" ]; then
|
if [ -z "$result" ]; then
|
||||||
|
|
@ -664,16 +673,31 @@ downloadFile() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay() {
|
||||||
|
|
||||||
|
local i
|
||||||
|
local delay="$1"
|
||||||
|
local msg="Will retry in X seconds..."
|
||||||
|
|
||||||
|
info "${msg/X/$delay}"
|
||||||
|
|
||||||
|
for i in $(seq $delay -1 1); do
|
||||||
|
html "${msg/X/$i}"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
downloadImage() {
|
downloadImage() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local version="$2"
|
local version="$2"
|
||||||
local lang="$3"
|
local lang="$3"
|
||||||
local delay=5
|
|
||||||
local tried="n"
|
local tried="n"
|
||||||
local success="n"
|
local success="n"
|
||||||
|
local seconds="5"
|
||||||
local url sum size base desc language
|
local url sum size base desc language
|
||||||
local msg="Will retry after $delay seconds..."
|
|
||||||
|
|
||||||
if [[ "${version,,}" == "http"* ]]; then
|
if [[ "${version,,}" == "http"* ]]; then
|
||||||
|
|
||||||
|
|
@ -682,7 +706,7 @@ downloadImage() {
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
||||||
info "$msg" && html "$msg" && sleep "$delay"
|
delay "$seconds"
|
||||||
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
|
||||||
|
|
@ -712,7 +736,7 @@ downloadImage() {
|
||||||
if getWindows "$version" "$lang" "$desc"; then
|
if getWindows "$version" "$lang" "$desc"; then
|
||||||
success="y"
|
success="y"
|
||||||
else
|
else
|
||||||
info "$msg" && html "$msg" && sleep "$delay"
|
delay "$seconds"
|
||||||
getWindows "$version" "$lang" "$desc" && success="y"
|
getWindows "$version" "$lang" "$desc" && success="y"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -722,7 +746,7 @@ downloadImage() {
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
info "$msg" && html "$msg" && sleep "$delay"
|
delay "$seconds"
|
||||||
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
fi
|
fi
|
||||||
|
|
@ -742,7 +766,7 @@ downloadImage() {
|
||||||
if getESD "$TMP/esd" "$version" "$lang" "$desc"; then
|
if getESD "$TMP/esd" "$version" "$lang" "$desc"; then
|
||||||
success="y"
|
success="y"
|
||||||
else
|
else
|
||||||
info "$msg" && html "$msg" && sleep "$delay"
|
delay "$seconds"
|
||||||
getESD "$TMP/esd" "$version" "$lang" "$desc" && success="y"
|
getESD "$TMP/esd" "$version" "$lang" "$desc" && success="y"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -751,7 +775,7 @@ downloadImage() {
|
||||||
|
|
||||||
rm -f "$ISO"
|
rm -f "$ISO"
|
||||||
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
||||||
info "$msg" && html "$msg" && sleep "$delay"
|
delay "$seconds"
|
||||||
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
||||||
rm -f "$ISO"
|
rm -f "$ISO"
|
||||||
ISO="$iso"
|
ISO="$iso"
|
||||||
|
|
@ -775,7 +799,7 @@ downloadImage() {
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
info "$msg" && html "$msg" && sleep "$delay"
|
delay "$seconds"
|
||||||
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue