mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Refactor get_*() functions to use validate_release()
This commit is contained in:
		
							parent
							
								
									1b9eb20ba6
								
							
						
					
					
						commit
						f34434e4ad
					
				
					 1 changed files with 11 additions and 74 deletions
				
			
		
							
								
								
									
										83
									
								
								quickget
									
										
									
									
									
								
							
							
						
						
									
										83
									
								
								quickget
									
										
									
									
									
								
							|  | @ -488,16 +488,9 @@ function start_vm_info() { | |||
| 
 | ||||
| function get_elementary() { | ||||
|     local ISO="" | ||||
|     local RELEASES="" | ||||
|     local URL="" | ||||
| 
 | ||||
|     RELEASES=$(releases_elementary) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! elementary OS ${RELEASE} is not a supported release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     validate_release "releases_elementary" | ||||
|     ISO="elementaryos-${RELEASE}-stable.20211005.iso" | ||||
|     URL="https://ams3.dl.elementary.io/download/MTYzNDU5MDA5NA==/${ISO}" | ||||
|     make_vm_dir | ||||
|  | @ -508,19 +501,11 @@ function get_elementary() { | |||
| 
 | ||||
| function get_freebsd() { | ||||
|     local ISO="" | ||||
|     local RELEASES="" | ||||
|     local URL="" | ||||
| 
 | ||||
|     RELEASES=$(releases_freebsd) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! FreeBSD ${RELEASE} is not a supported release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     validate_release "releases_freebsd" | ||||
|     ISO="FreeBSD-${RELEASE}-RELEASE-amd64-dvd1.iso" | ||||
|     URL="https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/${RELEASE}/${ISO}" | ||||
| 
 | ||||
|     make_vm_dir | ||||
|     web_get "${URL}" "${VM_PATH}" | ||||
|     make_vm_config "${ISO}" | ||||
|  | @ -534,14 +519,8 @@ function get_fedora() { | |||
|     local URL="" | ||||
|     local SHA256SUM="" | ||||
|     local VERSION_NUM="" | ||||
|     local RELEASES="" | ||||
| 
 | ||||
|     RELEASES=$(releases_fedora) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! Fedora ${RELEASE} is not a supported release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
|     validate_release "releases_fedora" | ||||
| 
 | ||||
|     FEDORA_VERSIONS=$(wget -q -O- "https://getfedora.org/releases.json" | jq '.[] | select((.variant=="Workstation" or .variant=="Spins") and .arch=="x86_64")') | ||||
|     if [[ "${RELEASE}" == *"beta"* ]]; then | ||||
|  | @ -576,20 +555,12 @@ function get_fedora() { | |||
| function get_linuxmint() { | ||||
|     local FLAVOR="" | ||||
|     local ISO="" | ||||
|     local RELEASES="" | ||||
|     local URL="" | ||||
| 
 | ||||
|     RELEASES=$(releases_linuxmint) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! Linux Mint ${RELEASE} is not a supported release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     validate_release "releases_linuxmint" | ||||
|     FLAVOR=$(echo "${OS}" | cut -d'-' -f2) | ||||
|     ISO="linuxmint-${RELEASE}-${FLAVOR}-64bit.iso" | ||||
|     URL="https://mirrors.edge.kernel.org/linuxmint/stable/${RELEASE}/${ISO}" | ||||
| 
 | ||||
|     make_vm_dir | ||||
|     web_get "${URL}" "${VM_PATH}" | ||||
|     make_vm_config "${ISO}" | ||||
|  | @ -601,13 +572,7 @@ function get_opensuse() { | |||
|     local RELEASES="" | ||||
|     local URL="" | ||||
| 
 | ||||
|     RELEASES=$(releases_opensuse) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! openSUSE ${RELEASE} is not a supported release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     validate_release "releases_opensuse" | ||||
|     if [ "${RELEASE}" == "tumbleweed" ]; then | ||||
|         ISO="openSUSE-Tumbleweed-DVD-x86_64-Current.iso" | ||||
|         URL="https://download.opensuse.org/tumbleweed/iso/${ISO}" | ||||
|  | @ -693,16 +658,9 @@ function get_macos() { | |||
| 
 | ||||
| function get_popos() { | ||||
|     local ISO="" | ||||
|     local RELEASES="" | ||||
|     local URL="" | ||||
| 
 | ||||
|     RELEASES=$(releases_popos) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! Pop!_OS ${RELEASE} is not a supported release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     validate_release "releases_popos" | ||||
|     ISO="pop-os_${RELEASE}_amd64_intel_9.iso" | ||||
|     URL="https://pop-iso.sfo2.cdn.digitaloceanspaces.com/${RELEASE}/amd64/intel/9/${ISO}" | ||||
|     make_vm_dir | ||||
|  | @ -715,7 +673,6 @@ function get_ubuntu() { | |||
|     local DEVEL="daily-live" | ||||
|     local ISO="" | ||||
|     local PROJECT="" | ||||
|     local RELEASES="" | ||||
|     local URL="" | ||||
| 
 | ||||
|     case ${OS} in | ||||
|  | @ -726,11 +683,11 @@ function get_ubuntu() { | |||
|       ubuntu-studio) | ||||
|         PROJECT="ubuntustudio" | ||||
|         DEVEL="dvd";; | ||||
|       *) | ||||
|         echo "ERROR! ${OS} is not a recognised Ubuntu flavour." | ||||
|       *) echo "ERROR! ${OS} is not a recognised Ubuntu flavour." | ||||
|          exit 1;; | ||||
|     esac | ||||
| 
 | ||||
|     validate_release "releases_ubuntu" | ||||
|     if [ "${RELEASE}" == "devel" ]; then | ||||
|         URL="http://cdimage.ubuntu.com/${PROJECT}/${DEVEL}/current" | ||||
|     elif [ "${PROJECT}" == "ubuntu" ]; then | ||||
|  | @ -739,21 +696,10 @@ function get_ubuntu() { | |||
|         URL="http://cdimage.ubuntu.com/${PROJECT}/releases/${RELEASE}/release" | ||||
|     fi | ||||
| 
 | ||||
|     RELEASES=$(releases_ubuntu) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! ${RELEASE} is not a supported Ubuntu release." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
| 
 | ||||
|     make_vm_dir | ||||
| 
 | ||||
|     echo "Downloading SHA256SUMS..." | ||||
|     web_get "${URL}/SHA256SUMS" "${VM_PATH}" | ||||
| 
 | ||||
|     ISO=$(grep 'desktop\|dvd' "${VM_PATH}/SHA256SUMS" | grep amd64 | cut -d' ' -f2 | sed 's|*||g') | ||||
| 
 | ||||
|     echo "Downloading "${URL}/${ISO}"..." | ||||
|     if [ "${RELEASE}" == "devel" ]; then | ||||
|         zsync_get "${URL}/${ISO}" "${VM_PATH}" "${OS}-${RELEASE}.iso" | ||||
|         make_vm_config "${OS}-${RELEASE}.iso" | ||||
|  | @ -770,7 +716,6 @@ function get_ubuntu() { | |||
|         cd .. | ||||
|         make_vm_config "${ISO}" | ||||
|     fi | ||||
| 
 | ||||
|     start_vm_info | ||||
| } | ||||
| 
 | ||||
|  | @ -788,14 +733,8 @@ function get_windows() { | |||
|     local DOWNLOAD_INFO="" | ||||
|     local DOWNLOAD_ID="" | ||||
|     local DOWNLOAD_URL="" | ||||
|     local RELEASES="" | ||||
| 
 | ||||
|     RELEASES=$(releases_windows) | ||||
|     if [[ "${RELEASES}" != *"${RELEASE}"* ]]; then | ||||
|         echo "ERROR! Windows ${RELEASE} is not supported." | ||||
|         echo "${RELEASES}" | ||||
|         exit 1 | ||||
|     fi | ||||
|     validate_release "releases_windows" | ||||
| 
 | ||||
|     echo "Getting Windows ${RELEASE} URL..." | ||||
|     WINDOWS_VERSIONS=$(wget -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))') | ||||
|  | @ -827,7 +766,7 @@ function get_windows() { | |||
|     # Only check the integrity is SHA1 is available. | ||||
|     if [ -n "${DOWNLOAD_SHA1}" ]; then | ||||
|       echo "${DOWNLOAD_SHA1}  ${FILE_NAME}" > "${VM_PATH}/SHA1SUMS" | ||||
|       echo "Checking SHA1SUMS..." | ||||
| 
 | ||||
|       cd "${VM_PATH}" | ||||
|       if ! sha1sum --check SHA1SUMS --ignore-missing --status; then | ||||
|           echo "ERROR! ${ISO} doesn't match ${VM_PATH}/SHA1SUMS. Try running 'quickget' again." | ||||
|  | @ -838,7 +777,6 @@ function get_windows() { | |||
|       cd .. | ||||
|     fi | ||||
| 
 | ||||
|     echo "Downloading virtio-win.iso..." | ||||
|     web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}" | ||||
| 
 | ||||
|     if [ ! -e "${VM_PATH}/unattended.iso" ]; then | ||||
|  | @ -855,7 +793,6 @@ function get_windows() { | |||
|         esac | ||||
|     fi | ||||
|     make_vm_config "${FILE_NAME}" "virtio-win.iso" | ||||
| 
 | ||||
|     start_vm_info | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue