mirror of
				https://github.com/dockur/windows.git
				synced 2025-10-30 20:45:50 +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 | ||||
| } | ||||
| 
 | ||||
| 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() { | ||||
| 
 | ||||
|   local xml="$1" | ||||
|  | @ -374,6 +361,26 @@ getPlatform() { | |||
|   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() { | ||||
| 
 | ||||
|   local id="$1" | ||||
|  | @ -419,26 +426,6 @@ selectVersion() { | |||
|   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() { | ||||
| 
 | ||||
|   local xml="$1" | ||||
|  | @ -453,6 +440,19 @@ detectVersion() { | |||
|   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() { | ||||
| 
 | ||||
|   local dir="$1" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kroese
						Kroese