From 24a9b1b2ba67563bbc8de65373ce0ad6e9738849 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 15 Nov 2024 05:06:47 +0100 Subject: [PATCH] feat: Improved download method (#228) --- Dockerfile | 7 +++-- readme.md | 4 +-- src/define.sh | 16 ++++++---- src/install.sh | 19 ++++++++--- src/mido.sh | 85 +++++++++++++++++++++++++------------------------- 5 files changed, 74 insertions(+), 57 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37478f6..77b51ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM scratch -COPY --from=qemux/qemu-arm:2.20 / / +COPY --from=qemux/qemu-arm:2.21 / / -ARG VERSION_ARG="4.00" +ARG VERSION_ARG="0.00" ARG DEBCONF_NOWARNINGS="yes" ARG DEBIAN_FRONTEND="noninteractive" ARG DEBCONF_NONINTERACTIVE_SEEN="true" @@ -10,6 +10,7 @@ RUN set -eu && \ apt-get update && \ apt-get --no-install-recommends -y install \ bc \ + jq \ curl \ 7zip \ wsdd \ @@ -31,8 +32,8 @@ COPY --chmod=755 ./assets /run/assets ADD --chmod=755 https://raw.githubusercontent.com/christgau/wsdd/v0.8/src/wsdd.py /usr/sbin/wsdd ADD --chmod=664 https://github.com/qemus/virtiso-arm/releases/download/v0.1.262-2/virtio-win-0.1.262.tar.xz /drivers.txz -EXPOSE 8006 3389 VOLUME /storage +EXPOSE 8006 3389 ENV VERSION="11" ENV RAM_SIZE="4G" diff --git a/readme.md b/readme.md index 3068d12..056c1aa 100644 --- a/readme.md +++ b/readme.md @@ -93,8 +93,8 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/windows-arm/refs/heads | **Value** | **Version** | **Platform** | **Size** | |---|---|---|---| - | `11` | Windows 11 Pro | ARM64 | 4.9 GB | - | `11l` | Windows 11 LTSC | ARM64 | 4.8 GB | + | `11` | Windows 11 Pro | ARM64 | 5.0 GB | + | `11l` | Windows 11 LTSC | ARM64 | 3.9 GB | | `11e` | Windows 11 Enterprise | ARM64 | 4.8 GB | ||||| | `10` | Windows 10 Pro | ARM64 | 3.5 GB | diff --git a/src/define.sh b/src/define.sh index 291e44d..23229e5 100644 --- a/src/define.sh +++ b/src/define.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -Eeuo pipefail -: "${XRES:=""}" -: "${YRES:=""}" +: "${WIDTH:=""}" +: "${HEIGHT:=""}" : "${VERIFY:=""}" : "${REGION:=""}" : "${MANUAL:=""}" @@ -147,7 +147,7 @@ getLanguage() { desc="English" culture="en-GB" ;; "en" | "en-"* ) - lang="English (United States)" + lang="English" desc="English" culture="en-US" ;; "mx" | "es-mx" ) @@ -263,15 +263,15 @@ getLanguage() { desc="$lang" culture="uk-UA" ;; "hk" | "zh-hk" | "cn-hk" ) - lang="Chinese Traditional" + lang="Chinese (Traditional)" desc="Chinese HK" culture="zh-TW" ;; "tw" | "zh-tw" | "cn-tw" ) - lang="Chinese Traditional" + lang="Chinese (Traditional)" desc="Chinese TW" culture="zh-TW" ;; "zh" | "zh-"* | "cn" | "cn-"* ) - lang="Chinese Simplified" + lang="Chinese (Simplified)" desc="Chinese" culture="zh-CN" ;; esac @@ -493,6 +493,10 @@ getMido() { [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-us" ]] && return 0 case "${id,,}" in + "win11arm64" ) + size=5460387840 + sum="57d1dfb2c6690a99fe99226540333c6c97d3fd2b557a50dfe3d68c3f675ef2b0" + ;; "win11arm64-enterprise-ltsc-eval" ) size=4252764160 sum="ccec358a760c3c581249f091ed42d04f37b2b99c347b7a58257c3cc272d7982c" diff --git a/src/install.sh b/src/install.sh index 4d7fd1f..7f73c81 100644 --- a/src/install.sh +++ b/src/install.sh @@ -120,6 +120,7 @@ finishInstall() { rm -f "$STORAGE/windows.old" rm -f "$STORAGE/windows.vga" + rm -f "$STORAGE/windows.args" rm -f "$STORAGE/windows.base" rm -f "$STORAGE/windows.boot" rm -f "$STORAGE/windows.mode" @@ -156,6 +157,11 @@ finishInstall() { fi fi + if [ -n "${ARGS:-}" ]; then + ARGUMENTS="$ARGS ${ARGUMENTS:-}" + echo "$ARGS" > "$STORAGE/windows.args" + fi + if [ -n "${DISK_TYPE:-}" ] && [[ "${DISK_TYPE:-}" != "scsi" ]]; then echo "$DISK_TYPE" > "$STORAGE/windows.type" fi @@ -614,11 +620,11 @@ updateXML() { local language="$2" local culture region user admin pass keyboard - [ -z "$YRES" ] && YRES="720" - [ -z "$XRES" ] && XRES="1280" + [ -z "$HEIGHT" ] && HEIGHT="720" + [ -z "$WIDTH" ] && WIDTH="1280" - sed -i "s/1080<\/VerticalResolution>/$YRES<\/VerticalResolution>/g" "$asset" - sed -i "s/1920<\/HorizontalResolution>/$XRES<\/HorizontalResolution>/g" "$asset" + sed -i "s/1080<\/VerticalResolution>/$HEIGHT<\/VerticalResolution>/g" "$asset" + sed -i "s/1920<\/HorizontalResolution>/$WIDTH<\/HorizontalResolution>/g" "$asset" culture=$(getLanguage "$language" "culture") @@ -965,6 +971,11 @@ bootWindows() { rm -rf "$TMP" + if [ -f "$STORAGE/windows.args" ]; then + ARGS=$(<"$STORAGE/windows.args") + ARGUMENTS="$ARGS ${ARGUMENTS:-}" + fi + if [ -s "$STORAGE/windows.type" ] && [ -f "$STORAGE/windows.type" ]; then [ -z "${DISK_TYPE:-}" ] && DISK_TYPE=$(<"$STORAGE/windows.type") fi diff --git a/src/mido.sh b/src/mido.sh index d739553..776f716 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -63,30 +63,32 @@ download_windows() { local lang="$2" local desc="$3" local sku_id="" + local sku_url="" + local iso_url="" + local iso_json="" local language="" local session_id="" local user_agent="" + local download_type="" local windows_version="" local iso_download_link="" + local download_page_html="" local product_edition_id="" - local iso_download_link_html="" - local iso_download_page_html="" - local language_skuid_table_html="" + local language_skuid_json="" + local profile="606624d44113" + + user_agent=$(get_agent) + language=$(getLanguage "$lang" "name") case "${id,,}" in - "win11x64" ) windows_version="11" ;; - "win10x64" ) windows_version="10" ;; - "win81x64" ) windows_version="8" ;; + "win11x64" ) windows_version="11" && download_type="1" ;; + "win10x64" ) windows_version="10" && download_type="1" ;; + "win11arm64" ) windows_version="11arm64" && download_type="2" ;; * ) error "Invalid VERSION specified, value \"$id\" is not recognized!" && return 1 ;; esac - user_agent=$(get_agent) - language=$(getLanguage "$lang" "name") - local url="https://www.microsoft.com/en-us/software-download/windows$windows_version" - case "$windows_version" in - 8 | 10) url+="ISO";; - esac + [[ "${id,,}" == "win10"* ]] && url+="ISO" # uuidgen: For MacOS (installed by default) and other systems (e.g. with no /proc) that don't have a kernel interface for generating random UUIDs session_id=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random) @@ -96,44 +98,39 @@ download_windows() { # This is the *only* request we make that Fido doesn't. Fido manually maintains a list of all the Windows release/edition product edition IDs in its script (see: $WindowsVersions array). This is helpful for downloading older releases (e.g. Windows 10 1909, 21H1, etc.) but we always want to get the newest release which is why we get this value dynamically # Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden # Remove "Accept" header that curl sends by default - [[ "$DEBUG" == [Yy1]* ]] && echo " - Parsing download page: ${url}" - iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || { + [[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}" + download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || { handle_curl_error $? return $? } [[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting Product edition ID: " - # tr: Filter for only numerics to prevent HTTP parameter injection - # head -c was recently added to POSIX: https://austingroupbugs.net/view.php?id=407 - product_edition_id=$(echo "$iso_download_page_html" | grep -Eo '