mirror of
https://github.com/dockur/windows-arm.git
synced 2024-11-17 02:31:48 +00:00
feat: Show download percentage (#98)
This commit is contained in:
parent
fe45fd5f5a
commit
348930051e
3 changed files with 126 additions and 44 deletions
|
@ -1,5 +1,5 @@
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=qemux/qemu-arm:1.18 / /
|
COPY --from=qemux/qemu-arm:1.19 / /
|
||||||
|
|
||||||
ARG DEBCONF_NOWARNINGS "yes"
|
ARG DEBCONF_NOWARNINGS "yes"
|
||||||
ARG DEBIAN_FRONTEND "noninteractive"
|
ARG DEBIAN_FRONTEND "noninteractive"
|
||||||
|
|
|
@ -149,20 +149,28 @@ getLink1() {
|
||||||
local ret="$2"
|
local ret="$2"
|
||||||
local url=""
|
local url=""
|
||||||
local sum=""
|
local sum=""
|
||||||
|
local size=""
|
||||||
local host="https://dl.bobpony.com/windows"
|
local host="https://dl.bobpony.com/windows"
|
||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
"win11${PLATFORM,,}")
|
"win11${PLATFORM,,}")
|
||||||
|
size=5946128384
|
||||||
sum="0c8edeae3202cf6f4bf8bb65c9f6176374c48fdcbcc8d0effa8547be75e9fd20"
|
sum="0c8edeae3202cf6f4bf8bb65c9f6176374c48fdcbcc8d0effa8547be75e9fd20"
|
||||||
url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
|
url="$host/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
|
||||||
;;
|
;;
|
||||||
"win10${PLATFORM,,}")
|
"win10${PLATFORM,,}")
|
||||||
|
size=4957009920
|
||||||
sum="64461471292b79d18cd9cced6cc141d7773b489a9b3e12de7b120312e63bfaf1"
|
sum="64461471292b79d18cd9cced6cc141d7773b489a9b3e12de7b120312e63bfaf1"
|
||||||
url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso"
|
url="$host/10/en-us_windows_10_22h2_${PLATFORM,,}.iso"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -z "$ret" ] && echo "$url" || echo "$sum"
|
case "${ret,,}" in
|
||||||
|
"sum" ) echo "$sum" ;;
|
||||||
|
"size" ) echo "$size" ;;
|
||||||
|
*) echo "$url";;
|
||||||
|
esac
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,32 +182,50 @@ getLink2() {
|
||||||
local ret="$2"
|
local ret="$2"
|
||||||
local url=""
|
local url=""
|
||||||
local sum=""
|
local sum=""
|
||||||
|
local size=""
|
||||||
local host="https://drive.massgrave.dev"
|
local host="https://drive.massgrave.dev"
|
||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
"win11${PLATFORM,,}")
|
"win11${PLATFORM,,}")
|
||||||
|
size=7010680832
|
||||||
sum="3da19e8c8c418091081186e362fb53a1aa68dad255d1d28ace81e2c88c3f99ba"
|
sum="3da19e8c8c418091081186e362fb53a1aa68dad255d1d28ace81e2c88c3f99ba"
|
||||||
url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO"
|
url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO"
|
||||||
;;
|
;;
|
||||||
"win10${PLATFORM,,}")
|
"win10${PLATFORM,,}")
|
||||||
|
size=5190453248
|
||||||
sum="bd96b342193f81c0a2e6595d8d8b8dc01dbf789d19211699f6299fec7b712197"
|
sum="bd96b342193f81c0a2e6595d8d8b8dc01dbf789d19211699f6299fec7b712197"
|
||||||
url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO"
|
url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -z "$ret" ] && echo "$url" || echo "$sum"
|
case "${ret,,}" in
|
||||||
|
"sum" ) echo "$sum" ;;
|
||||||
|
"size" ) echo "$size" ;;
|
||||||
|
*) echo "$url";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getValue() {
|
||||||
|
|
||||||
|
local val=""
|
||||||
|
local id="$3"
|
||||||
|
local type="$2"
|
||||||
|
local func="getLink$1"
|
||||||
|
|
||||||
|
if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
|
||||||
|
val=$($func "$id" "$type")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$val"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getLink() {
|
getLink() {
|
||||||
|
|
||||||
local url=""
|
local url=""
|
||||||
local id="$2"
|
url=$(getValue "$1" "" "$2")
|
||||||
local func="getLink$1"
|
|
||||||
|
|
||||||
if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
|
|
||||||
url=$($func "$id" "")
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$url"
|
echo "$url"
|
||||||
return 0
|
return 0
|
||||||
|
@ -208,24 +234,27 @@ getLink() {
|
||||||
getHash() {
|
getHash() {
|
||||||
|
|
||||||
local sum=""
|
local sum=""
|
||||||
local id="$2"
|
sum=$(getValue "$1" "sum" "$2")
|
||||||
local func="getLink$1"
|
|
||||||
|
|
||||||
if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
|
|
||||||
sum=$($func "$id" "sum")
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$sum"
|
echo "$sum"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSize() {
|
||||||
|
|
||||||
|
local size=""
|
||||||
|
size=$(getValue "$1" "size" "$2")
|
||||||
|
|
||||||
|
echo "$size"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
validVersion() {
|
validVersion() {
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
local url
|
local url
|
||||||
|
|
||||||
isESD "$id" && return 0
|
isESD "$id" && return 0
|
||||||
isMido "$id" && return 0
|
|
||||||
|
|
||||||
for ((i=1;i<=MIRRORS;i++)); do
|
for ((i=1;i<=MIRRORS;i++)); do
|
||||||
|
|
||||||
|
|
105
src/install.sh
105
src/install.sh
|
@ -210,7 +210,7 @@ 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/$wFile" -q; rc=$?; } || :
|
{ wget "$winCatalog" -O "$dir/$wFile" -q --timeout=10; rc=$?; } || :
|
||||||
(( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1
|
(( rc != 0 )) && error "Failed to download $winCatalog , reason: $rc" && return 1
|
||||||
|
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
|
@ -240,34 +240,86 @@ getESD() {
|
||||||
error "Failed to find Windows product in $eFile!" && return 1
|
error "Failed to find Windows product in $eFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ESD=$(xmllint --nonet --xpath '//FilePath' "$dir/$eFile" | sed -E -e 's/<[\/]?FilePath>//g')
|
local tag="FilePath"
|
||||||
|
ESD=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" | sed -E -e "s/<[\/]?$tag>//g")
|
||||||
|
|
||||||
if [ -z "$ESD" ]; then
|
if [ -z "$ESD" ]; then
|
||||||
error "Failed to find ESD URL in $eFile!" && return 1
|
error "Failed to find ESD URL in $eFile!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
tag="Sha1"
|
||||||
|
ESD_SUM=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" | sed -E -e "s/<[\/]?$tag>//g")
|
||||||
|
tag="Size"
|
||||||
|
ESD_SIZE=$(xmllint --nonet --xpath "//$tag" "$dir/$eFile" | sed -E -e "s/<[\/]?$tag>//g")
|
||||||
|
|
||||||
rm -rf "$dir"
|
rm -rf "$dir"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doMido() {
|
||||||
|
|
||||||
|
local iso="$1"
|
||||||
|
local version="$2"
|
||||||
|
local desc="$3"
|
||||||
|
local rc
|
||||||
|
|
||||||
|
rm -f "$iso"
|
||||||
|
rm -f "$iso.PART"
|
||||||
|
|
||||||
|
local msg="Downloading $desc..."
|
||||||
|
info "$msg" && html "$msg"
|
||||||
|
/run/progress.sh "$iso.PART" "" "Downloading $desc ([P])..." &
|
||||||
|
|
||||||
|
cd "$TMP"
|
||||||
|
{ /run/mido.sh "${version,,}"; rc=$?; } || :
|
||||||
|
cd /run
|
||||||
|
|
||||||
|
fKill "progress.sh"
|
||||||
|
|
||||||
|
if (( rc == 0 )) && [ -f "$iso" ]; then
|
||||||
|
if [ "$(stat -c%s "$iso")" -gt 100000000 ]; then
|
||||||
|
html "Download finished successfully..." && return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$iso"
|
||||||
|
rm -f "$iso.PART"
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
verifyFile() {
|
verifyFile() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local check="$2"
|
local size="$2"
|
||||||
|
local total="$3"
|
||||||
|
local check="$4"
|
||||||
|
|
||||||
|
if [ -n "$size" ] && [[ "$total" != "$size" ]]; then
|
||||||
|
[[ "$size" != "0" ]] && warn "The download file has an unexpected size: $total"
|
||||||
|
fi
|
||||||
|
|
||||||
local hash=""
|
local hash=""
|
||||||
|
local algo="SHA256"
|
||||||
|
|
||||||
[ -z "$check" ] && return 0
|
[ -z "$check" ] && return 0
|
||||||
|
[[ "$VERIFY" != [Yy1]* ]] && return 0
|
||||||
|
[[ "${#check}" == "40" ]] && algo="SHA1"
|
||||||
|
|
||||||
html "Verifying downloaded ISO..."
|
local msg="Verifying downloaded ISO..."
|
||||||
info "Calculating SHA256 checksum of the ISO file..."
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
hash=$(sha256sum "$iso" | cut -f1 -d' ')
|
if [[ "${algo,,}" != "sha256" ]]; then
|
||||||
|
hash=$(sha1sum "$iso" | cut -f1 -d' ')
|
||||||
|
else
|
||||||
|
hash=$(sha256sum "$iso" | cut -f1 -d' ')
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$hash" == "$check" ]]; then
|
if [[ "$hash" == "$check" ]]; then
|
||||||
info "Succesfully verified that the checksum was correct!" && return 0
|
info "Succesfully verified that the checksum was correct!" && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
error "Invalid sha256 checksum: $hash , but expected value is: $check ! Please report this at $SUPPORT/issues"
|
error "Invalid $algo checksum: $hash , but expected value is: $check ! Please report this at $SUPPORT/issues"
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
return 1
|
return 1
|
||||||
|
@ -278,8 +330,9 @@ downloadFile() {
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local url="$2"
|
local url="$2"
|
||||||
local sum="$3"
|
local sum="$3"
|
||||||
local desc="$4"
|
local size="$4"
|
||||||
local rc progress domain dots
|
local desc="$5"
|
||||||
|
local rc total progress domain dots
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
|
|
||||||
|
@ -291,6 +344,7 @@ downloadFile() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local msg="Downloading $desc..."
|
local msg="Downloading $desc..."
|
||||||
|
html "$msg"
|
||||||
|
|
||||||
domain=$(echo "$url" | awk -F/ '{print $3}')
|
domain=$(echo "$url" | awk -F/ '{print $3}')
|
||||||
dots=$(echo "$domain" | tr -cd '.' | wc -c)
|
dots=$(echo "$domain" | tr -cd '.' | wc -c)
|
||||||
|
@ -300,18 +354,17 @@ downloadFile() {
|
||||||
msg="Downloading $desc from $domain..."
|
msg="Downloading $desc from $domain..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "$msg" && html "$msg"
|
info "$msg"
|
||||||
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
|
/run/progress.sh "$iso" "$size" "Downloading $desc ([P])..." &
|
||||||
|
|
||||||
{ wget "$url" -O "$iso" -q --show-progress "$progress"; rc=$?; } || :
|
{ wget "$url" -O "$iso" -q --timeout=10 --show-progress "$progress"; rc=$?; } || :
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
|
||||||
if (( rc == 0 )) && [ -f "$iso" ]; then
|
if (( rc == 0 )) && [ -f "$iso" ]; then
|
||||||
if [ "$(stat -c%s "$iso")" -gt 100000000 ]; then
|
total=$(stat -c%s "$iso")
|
||||||
if [[ "$VERIFY" == [Yy1]* ]] && [ -n "$sum" ]; then
|
if [ "$total" -gt 100000000 ]; then
|
||||||
! verifyFile "$iso" "$sum" && return 1
|
! verifyFile "$iso" "$size" "$total" "$sum" && return 1
|
||||||
fi
|
|
||||||
html "Download finished successfully..." && return 0
|
html "Download finished successfully..." && return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -327,11 +380,11 @@ downloadImage() {
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local version="$2"
|
local version="$2"
|
||||||
local tried="n"
|
local tried="n"
|
||||||
local url sum desc
|
local url sum size desc
|
||||||
|
|
||||||
if [[ "${version,,}" == "http"* ]]; then
|
if [[ "${version,,}" == "http"* ]]; then
|
||||||
desc=$(fromFile "$BASE")
|
desc=$(fromFile "$BASE")
|
||||||
downloadFile "$iso" "$version" "" "$desc" && return 0
|
downloadFile "$iso" "$version" "" "" "$desc" && return 0
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -341,14 +394,13 @@ downloadImage() {
|
||||||
|
|
||||||
desc=$(printVersion "$version" "")
|
desc=$(printVersion "$version" "")
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
if isMido "$version"; then
|
||||||
if isMido "$version"; then
|
tried="y"
|
||||||
tried="y"
|
doMido "$iso" "$version" "$desc" && return 0
|
||||||
doMido "$iso" "$version" "$desc" && return 0
|
|
||||||
fi
|
|
||||||
switchEdition "$version"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
switchEdition "$version"
|
||||||
|
|
||||||
if isESD "$version"; then
|
if isESD "$version"; then
|
||||||
|
|
||||||
if [[ "$tried" != "n" ]]; then
|
if [[ "$tried" != "n" ]]; then
|
||||||
|
@ -359,7 +411,7 @@ downloadImage() {
|
||||||
|
|
||||||
if getESD "$TMP/esd" "$version"; then
|
if getESD "$TMP/esd" "$version"; then
|
||||||
ISO="$TMP/$version.esd"
|
ISO="$TMP/$version.esd"
|
||||||
downloadFile "$ISO" "$ESD" "" "$desc" && return 0
|
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$desc" && return 0
|
||||||
ISO="$TMP/$BASE"
|
ISO="$TMP/$BASE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -374,8 +426,9 @@ downloadImage() {
|
||||||
info "Failed to download $desc, will try another mirror now..."
|
info "Failed to download $desc, will try another mirror now..."
|
||||||
fi
|
fi
|
||||||
tried="y"
|
tried="y"
|
||||||
|
size=$(getSize "$i" "$version")
|
||||||
sum=$(getHash "$i" "$version")
|
sum=$(getHash "$i" "$version")
|
||||||
downloadFile "$iso" "$url" "$sum" "$desc" && return 0
|
downloadFile "$iso" "$url" "$sum" "$size" "$desc" && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue