mirror of
https://github.com/dockur/windows.git
synced 2024-09-29 22:13:47 +00:00
feat: Refactor download code
This commit is contained in:
parent
558ab47cea
commit
fca9072898
1 changed files with 33 additions and 33 deletions
|
@ -342,19 +342,6 @@ extractImage() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
setXML() {
|
|
||||||
|
|
||||||
local file="/custom.xml"
|
|
||||||
[ ! -f "$file" ] || [ ! -s "$file" ] && file="$STORAGE/custom.xml"
|
|
||||||
[ ! -f "$file" ] || [ ! -s "$file" ] && file="/run/assets/custom.xml"
|
|
||||||
[ ! -f "$file" ] || [ ! -s "$file" ] && file="$1"
|
|
||||||
[ ! -f "$file" ] || [ ! -s "$file" ] && file="/run/assets/$DETECTED.xml"
|
|
||||||
[ ! -f "$file" ] || [ ! -s "$file" ] && return 1
|
|
||||||
|
|
||||||
XML="$file"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlatform() {
|
getPlatform() {
|
||||||
|
|
||||||
local xml="$1"
|
local xml="$1"
|
||||||
|
@ -374,6 +361,26 @@ getPlatform() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkPlatform() {
|
||||||
|
|
||||||
|
local xml="$1"
|
||||||
|
local platform compat
|
||||||
|
|
||||||
|
platform=$(getPlatform "$xml")
|
||||||
|
|
||||||
|
case "${platform,,}" in
|
||||||
|
"x86" ) compat="x64" ;;
|
||||||
|
"x64" ) compat="$platform" ;;
|
||||||
|
"arm64" ) compat="$platform" ;;
|
||||||
|
* ) compat="${PLATFORM,,}" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ "${compat,,}" == "${PLATFORM,,}" ]] && return 0
|
||||||
|
|
||||||
|
error "You cannot boot ${platform^^} images on a $PLATFORM CPU!"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
hasVersion() {
|
hasVersion() {
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
|
@ -419,26 +426,6 @@ selectVersion() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPlatform() {
|
|
||||||
|
|
||||||
local xml="$1"
|
|
||||||
local platform compat
|
|
||||||
|
|
||||||
platform=$(getPlatform "$xml")
|
|
||||||
|
|
||||||
case "${platform,,}" in
|
|
||||||
"x86" ) compat="x64" ;;
|
|
||||||
"x64" ) compat="$platform" ;;
|
|
||||||
"arm64" ) compat="$platform" ;;
|
|
||||||
* ) compat="${PLATFORM,,}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
[[ "${compat,,}" == "${PLATFORM,,}" ]] && return 0
|
|
||||||
|
|
||||||
error "You cannot boot ${platform^^} images on a $PLATFORM CPU!"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
detectVersion() {
|
detectVersion() {
|
||||||
|
|
||||||
local xml="$1"
|
local xml="$1"
|
||||||
|
@ -453,6 +440,19 @@ detectVersion() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setXML() {
|
||||||
|
|
||||||
|
local file="/custom.xml"
|
||||||
|
[ ! -f "$file" ] || [ ! -s "$file" ] && file="$STORAGE/custom.xml"
|
||||||
|
[ ! -f "$file" ] || [ ! -s "$file" ] && file="/run/assets/custom.xml"
|
||||||
|
[ ! -f "$file" ] || [ ! -s "$file" ] && file="$1"
|
||||||
|
[ ! -f "$file" ] || [ ! -s "$file" ] && file="/run/assets/$DETECTED.xml"
|
||||||
|
[ ! -f "$file" ] || [ ! -s "$file" ] && return 1
|
||||||
|
|
||||||
|
XML="$file"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
detectImage() {
|
detectImage() {
|
||||||
|
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
|
|
Loading…
Reference in a new issue