Compare commits

...

4 commits

Author SHA1 Message Date
Kroese
8471d296ea
fix: Formatting issues 2025-09-21 23:22:12 +02:00
Kroese
6470d19bc7
fix: Formatting issues 2025-09-21 23:15:06 +02:00
Kroese
425a661c93
revert: Simplify conditional checks 2025-09-21 23:11:56 +02:00
Kroese
465d0065b9
feat: Read product catalog from WoR project 2025-09-21 15:25:21 +02:00
2 changed files with 58 additions and 17 deletions

View file

@ -371,6 +371,7 @@ getCatalog() {
local url="" local url=""
local name="" local name=""
local edition="" local edition=""
local file="catalog.cab"
case "${id,,}" in case "${id,,}" in
"win11${PLATFORM,,}" ) "win11${PLATFORM,,}" )
@ -393,6 +394,38 @@ getCatalog() {
case "${ret,,}" in case "${ret,,}" in
"url" ) echo "$url" ;; "url" ) echo "$url" ;;
"file" ) echo "$file" ;;
"name" ) echo "$name" ;;
"edition" ) echo "$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" ;; "name" ) echo "$name" ;;
"edition" ) echo "$edition" ;; "edition" ) echo "$edition" ;;
*) echo "";; *) echo "";;
@ -407,32 +440,33 @@ getESD() {
local version="$2" local version="$2"
local lang="$3" local lang="$3"
local desc="$4" local desc="$4"
local file
local result local result
local culture local culture
local language local language
local editionName local editionName
local winCatalog local winCatalog
file=$(getCatalog "$version" "file")
culture=$(getLanguage "$lang" "culture") culture=$(getLanguage "$lang" "culture")
winCatalog=$(getCatalog "$version" "url") winCatalog=$(getCatalog "$version" "url")
editionName=$(getCatalog "$version" "edition") editionName=$(getCatalog "$version" "edition")
if [ -z "$winCatalog" ] || [ -z "$editionName" ]; then if [ -z "$file" ] || [ -z "$winCatalog" ] || [ -z "$editionName" ]; 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
local msg="Downloading product information from Microsoft server..." local msg="Downloading product information..."
info "$msg" && html "$msg" info "$msg" && html "$msg"
rm -rf "$dir" rm -rf "$dir"
mkdir -p "$dir" mkdir -p "$dir"
local wFile="catalog.cab"
local xFile="products.xml" local xFile="products.xml"
local eFile="esd_edition.xml" local eFile="esd_edition.xml"
local fFile="products_filter.xml" local fFile="products_filter.xml"
{ wget "$winCatalog" -O "$dir/$wFile" -q --timeout=30 --no-http-keep-alive; rc=$?; } || : { wget "$winCatalog" -O "$dir/$file" -q --timeout=30 --no-http-keep-alive; rc=$?; } || :
msg="Failed to download $winCatalog" msg="Failed to download $winCatalog"
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1 (( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
@ -440,17 +474,25 @@ getESD() {
(( rc == 8 )) && error "$msg , server issued an error response!" && return 1 (( rc == 8 )) && error "$msg , server issued an error response!" && return 1
(( rc != 0 )) && error "$msg , reason: $rc" && return 1 (( rc != 0 )) && error "$msg , reason: $rc" && return 1
if [[ "$file" == *".xml" ]]; then
mv -f "$dir/$file" "$dir/$xFile"
else
cd "$dir" cd "$dir"
if ! cabextract "$wFile" > /dev/null; then if ! cabextract "$file" > /dev/null; then
cd /run cd /run
error "Failed to extract $wFile!" && return 1 error "Failed to extract $file!" && return 1
fi fi
cd /run cd /run
fi
if [ ! -s "$dir/$xFile" ]; then if [ ! -s "$dir/$xFile" ]; then
error "Failed to find $xFile in $wFile!" && 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="'${editionName}'"]'
@ -462,7 +504,6 @@ getESD() {
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
desc=$(printEdition "$version" "$desc") desc=$(printEdition "$version" "$desc")
language=$(getLanguage "$lang" "desc") language=$(getLanguage "$lang" "desc")
error "No download link available for $desc!" && return 1 error "No download link available for $desc!" && return 1