From 0fe5232a019480e0e46573f3a9144f2d284c6ee0 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 15:02:54 +0000 Subject: [PATCH 1/9] Refactor Android support and add editions --- quickget | 64 +++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/quickget b/quickget index 7e9a18b..95295fd 100755 --- a/quickget +++ b/quickget @@ -230,12 +230,12 @@ function releases_alpine() { function releases_android() { echo 9.0 \ 8.1 \ - 7.1 \ - 6.0 \ - 5.1 \ - 4.4 \ - 4.0 \ - 2.2 + 7.1 +} + +function editions_android() { + echo x86 \ + x86_64 } function releases_archlinux() { @@ -769,33 +769,6 @@ EOF exit 0 } -function get_android() { - local HASH="" - local ISO="" - local URL="" - - fosshubVersionInfo=$(wget -O - -q "https://www.fosshub.com/Android-x86-old.html" | grep "var settings =") - version="android-x86-${RELEASE}" - releaseJson=$(echo "${fosshubVersionInfo:16}" | jq --arg ver "${version}" 'first(.pool.f[] | select((.n | startswith($ver)) and (.n | endswith(".iso"))))') - - HASH=$(echo "${releaseJson}" | jq -r .hash.sha256) - ISO=$(echo "${releaseJson}" | jq -r .n) - - baseurl="https://mirrors.gigenet.com/OSDN/android-x86/" - - releaseFolders=$(wget -q -O - ${baseurl} | grep -o -E '[0-9]{5}' | uniq) - for item in $releaseFolders; do - file=$(wget -O - -q "${baseurl}${item}" | grep "${ISO}") - if [[ $file != "" ]]; then - URL="${baseurl}${item}/${ISO}" - break - fi - done - web_get "${URL}" "${VM_PATH}" - check_hash "${ISO}" "${HASH}" - make_vm_config "${ISO}" -} - function get_alma() { local EDITION="" local HASH="" @@ -835,6 +808,31 @@ function get_alpine() { make_vm_config "${ISO}" } +function get_android() { + local EDITION="${1:-}" + local HASH="" + local ISO="" + local JSON_ALL="" + local JSON_REL="" + local URL="https://mirrors.gigenet.com/OSDN/android-x86" + + JSON_ALL=$(wget -q -O- "https://www.fosshub.com/Android-x86-old.html" | grep "var settings =" | cut -d'=' -f2-) + JSON_REL=$(echo "${JSON_ALL}" | jq --arg ver "${OS}-${EDITION}-${RELEASE}" 'first(.pool.f[] | select((.n | startswith($ver)) and (.n | endswith(".iso"))))') + ISO=$(echo "${JSON_REL}" | jq -r .n) + HASH=$(echo "${JSON_REL}" | jq -r .hash.sha256) + + # Traverse the directories to find the .iso location + for DIR in $(wget -q -O- ${URL} | grep -o -E '[0-9]{5}' | sort -ur); do + if wget -q -O- "${URL}/${DIR}" | grep "${ISO}" &>/dev/null; then + URL="${URL}/${DIR}" + break + fi + done + web_get "${URL}/${ISO}" "${VM_PATH}" + check_hash "${ISO}" "${HASH}" + make_vm_config "${ISO}" +} + function get_archlinux() { local HASH="" local ISO="" From 8050abc6f05a9c2dc9237314e508fcf7b12e109f Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 15:03:20 +0000 Subject: [PATCH 2/9] Refactor get_elementary() --- quickget | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/quickget b/quickget index 95295fd..0d9307a 100755 --- a/quickget +++ b/quickget @@ -921,12 +921,9 @@ function get_elementary() { local ISO="" local ISOTAG="20211218-rc" local URL="" - local B66tim="" - B66tim=$(date +%s | base64) ISO="elementaryos-${RELEASE}-stable.${ISOTAG}.iso" - # TODO: derive region from geoIP - URL="https://ams3.dl.elementary.io/download/${B66tim}=/${ISO}" + URL="https://ams3.dl.elementary.io/download/$(date +%s | base64)=/${ISO}" web_get "${URL}" "${VM_PATH}" make_vm_config "${ISO}" } From 1dc780b9e27b779f15bce6ee7911a91d55dea479 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 15:15:56 +0000 Subject: [PATCH 3/9] Remove EDITION boiler plate from all get_() functions --- quickget | 103 ++++++++++--------------------------------------------- 1 file changed, 18 insertions(+), 85 deletions(-) diff --git a/quickget b/quickget index 0d9307a..cbe6b70 100755 --- a/quickget +++ b/quickget @@ -9,15 +9,11 @@ # 5. Update make_vm_config() - add any *required* new OS tweaks # 6. Create a get_newos() function - that does something like this: # function get_newos() { -# local EDITION="" +# local EDITION="${1:-}" # local HASH="" # local ISO="" # local URL="" # -# if [ -n "${1}" ]; then -# EDITION="${1}" -# fi -# # URL="https://www.newos.org/download/${RELEASE}/${EDITION}" # ISO="newos-${RELEASE}-${EDITION}-amd64.iso" # web_get "${URL}/${ISO}" "${VM_PATH}" @@ -770,15 +766,11 @@ EOF } function get_alma() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - URL="http://lon.mirror.rackspace.com/almalinux/${RELEASE}/isos/x86_64/" ISO="AlmaLinux-${RELEASE}-x86_64-${EDITION}.iso" HASH="$(wget -q -O- "${URL}/CHECKSUM" | grep \("${ISO}" | cut -d'\' -f4)" @@ -849,17 +841,13 @@ function get_archlinux() { } function get_arcolinux() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1:0:1}" - fi - URL="https://ant.seedhost.eu/arcolinux/iso/${RELEASE}" - ISO="arcolinux${EDITION}-${RELEASE}-x86_64.iso" + ISO="arcolinux${EDITION:0:1}-${RELEASE}-x86_64.iso" HASH=$(wget -q -O- "${URL}/${ISO}.sha1" | cut -d' ' -f 1) web_get "${URL}/${ISO}" "${VM_PATH}" check_hash "${ISO}" "${HASH}" @@ -877,15 +865,11 @@ function get_cachyos() { } function get_debian() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${RELEASE} in 11.2.0) URL="https://cdimage.debian.org/debian-cd/${RELEASE}-live/amd64/iso-hybrid";; *) URL="https://cdimage.debian.org/cdimage/archive/${RELEASE}-live/amd64/iso-hybrid/" @@ -929,17 +913,13 @@ function get_elementary() { } function get_fedora() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local JSON="" local URL="" local VARIANT="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${EDITION} in Server|Silverblue|Workstation) VARIANT="${EDITION}";; *) VARIANT="Spins";; @@ -969,15 +949,11 @@ function get_freebsd() { function get_garuda() { local BRANCH="" - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${EDITION} in cinnamon|mate) BRANCH="community";; *) BRANCH="garuda";; @@ -1004,15 +980,11 @@ function get_gentoo() { } function get_ghostbsd() { - local EDITION="" + local EDITION="${1:-}" local ISO="" local URL="" local HASH="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${EDITION} in mate) ISO="GhostBSD-${RELEASE}.iso";; xfce) ISO="GhostBSD-${RELEASE}-XFCE.iso";; @@ -1026,15 +998,11 @@ function get_ghostbsd() { } function get_haiku() { - local EDITION="" + local EDITION="${1:-}" local ISO="" local URL="" local HASH="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - URL="https://cdn.haiku-os.org/haiku-release/${RELEASE}" ISO="haiku-${RELEASE}-${EDITION}-anyboot.iso" HASH=$(wget -q -O- "${URL}/${ISO}.sha256" | grep "${ISO}" | cut -d' ' -f4) @@ -1085,15 +1053,11 @@ function get_kolibrios() { } function get_linuxmint() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - URL="https://mirror.bytemark.co.uk/linuxmint/stable/${RELEASE}" ISO="linuxmint-${RELEASE}-${EDITION}-64bit.iso" HASH=$(wget -q -O- "${URL}/${RELEASE}/sha256sum.txt" | grep "${ISO}" | cut -d' ' -f1) @@ -1194,15 +1158,11 @@ function get_manjaro() { } function get_mxlinux() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${EDITION} in xfce) URL="https://sourceforge.net/projects/mx-linux/files/Final/Xfce" @@ -1248,15 +1208,11 @@ function get_netbsd() { } function get_nixos() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - URL="https://channels.nixos.org/nixos-${RELEASE}" ISO="latest-nixos-${EDITION}-x86_64-linux.iso" HASH=$(wget -q -O- "${URL}/${ISO}.sha256" | cut -d' ' -f1) @@ -1327,15 +1283,11 @@ function get_oraclelinux() { } function get_popos() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - URL=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${EDITION}" | jq ".url") URL="${URL//\"/}" ISO=$(echo "${URL}" | sed -e "s/.*\/\([^\/]*\)$/\1/") @@ -1347,16 +1299,12 @@ function get_popos() { } function get_regolith() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local SUBDIR="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${EDITION} in 1.6.0) SUBDIR="release-release-${RELEASE}-${RELEASE}_standard-${EDITION}";; 2.0.0) SUBDIR="regolith-linux-2.0-${RELEASE}-latest";; @@ -1373,15 +1321,11 @@ function get_regolith() { } function get_rockylinux() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - URL="https://download.rockylinux.org/pub/rocky/${RELEASE}/isos/x86_64" ISO="Rocky-${RELEASE}-x86_64-${EDITION}.iso" HASH=$(wget -q -O- "${URL}/CHECKSUM" | grep "SHA256" | grep "${ISO}" | cut -d' ' -f4) @@ -1413,15 +1357,11 @@ function get_slackware() { } function get_solus() { - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - case ${EDITION} in mate|gnome) EDITION=${EDITION^^};; @@ -1503,15 +1443,12 @@ function get_ubuntu() { function get_void() { local DATE="" - local EDITION="" + local EDITION="${1:-}" local HASH="" local ISO="" local URL="https://alpha.de.repo.voidlinux.org/live/current" DATE=$(wget -q -O- "${URL}/sha256sum.txt" | head -n1 | cut -d'.' -f1 | cut -d'-' -f4) - if [ -n "${1}" ]; then - EDITION="${1}" - fi case ${EDITION} in glibc) ISO="void-live-x86_64-${DATE}.iso";; musl) ISO="void-live-x86_64-musl-${DATE}.iso";; @@ -1525,14 +1462,10 @@ function get_void() { } function get_zorin() { - local EDITION="" + local EDITION="${1:-}" local ISO="" local URL="" - if [ -n "${1}" ]; then - EDITION="${1}" - fi - # Parse out the iso URL from the redirector URL=$(wget -q -S -O- --max-redirect=0 "https://zrn.co/${RELEASE}${EDITION}" 2>&1 | grep Location | cut -d' ' -f4) ISO="${URL##*/}" From ee0a25472f9d3330b96dc9e828d857dc14d91c14 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 15:19:34 +0000 Subject: [PATCH 4/9] Drop 21.04 (Hirsute) based releases. They are EOL. --- quickget | 3 --- 1 file changed, 3 deletions(-) diff --git a/quickget b/quickget index cbe6b70..422f635 100755 --- a/quickget +++ b/quickget @@ -454,7 +454,6 @@ function releases_oraclelinux() { function releases_popos() { echo 20.04 \ - 21.04 \ 21.10 } @@ -465,7 +464,6 @@ function editions_popos() { function releases_regolith() { echo focal \ - hirsute \ impish } @@ -512,7 +510,6 @@ function releases_tails() { function releases_ubuntu() { echo 18.04 \ 20.04 \ - 21.04 \ 21.10 \ devel \ canary From 45cdc5e217e1393f7b95a13f14fa9d3655e282aa Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 15:29:46 +0000 Subject: [PATCH 5/9] Refactor get_popos() --- quickget | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/quickget b/quickget index 422f635..4de5c6d 100755 --- a/quickget +++ b/quickget @@ -1285,11 +1285,9 @@ function get_popos() { local ISO="" local URL="" - URL=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${EDITION}" | jq ".url") - URL="${URL//\"/}" - ISO=$(echo "${URL}" | sed -e "s/.*\/\([^\/]*\)$/\1/") - HASH=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${EDITION}" | jq ".sha_sum") - HASH="${HASH//\"/}" + URL=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${EDITION}" | jq -r .url) + ISO="${URL##*/}" + HASH=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${EDITION}" | jq -r .sha_sum) web_get "${URL}" "${VM_PATH}" check_hash "${ISO}" "${HASH}" make_vm_config "${ISO}" From 15ff54d2089dc444933c7ca4bc2afb567a020fa8 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 18:40:42 +0000 Subject: [PATCH 6/9] releases_() generators are always ascending order --- quickget | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/quickget b/quickget index 4de5c6d..740a28e 100755 --- a/quickget +++ b/quickget @@ -216,17 +216,17 @@ function editions_alma() { } function releases_alpine() { - echo latest \ - 3.12 \ + echo 3.12 \ 3.13 \ 3.14 \ - 3.15 + 3.15 \ + latest } function releases_android() { - echo 9.0 \ + echo 7.1 \ 8.1 \ - 7.1 + 9.0 } function editions_android() { @@ -305,8 +305,7 @@ function releases_freebsd(){ } function releases_garuda() { - echo 220131 \ - 220220 + echo 220131 } function editions_garuda() { @@ -351,8 +350,8 @@ function editions_haiku() { } function releases_kali() { - echo latest \ - weekly + echo current \ + kali-weekly } function releases_kdeneon() { @@ -410,9 +409,9 @@ function releases_netboot() { } function releases_netbsd() { - echo 9.2 \ + echo 9.0 \ 9.1 \ - 9.0 + 9.2 } function releases_nixos(){ @@ -443,13 +442,13 @@ function releases_opensuse(){ } function releases_oraclelinux() { - echo 8.5 \ - 8.4 \ - 8.3 \ - 8.2 \ - 7.9 \ + echo 7.7 \ 7.8 \ - 7.7 + 7.9 \ + 8.2 \ + 8.3 \ + 8.4 \ + 8.5 } function releases_popos() { @@ -473,12 +472,9 @@ function editions_regolith() { } function releases_rockylinux() { - echo 8.5 \ + echo 8.3 \ 8.4 \ - 8.3 \ - 8.2 \ - 8.1 \ - 8.0 + 8.5 } function editions_rockylinux() { @@ -488,8 +484,7 @@ function editions_rockylinux() { function releases_slackware() { echo 14.2 \ - 15.0 \ - current + 15.0 } function releases_solus() { From 29c282953486d71f14158e879719dd4837063844 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 18:42:12 +0000 Subject: [PATCH 7/9] Clean up variable assignment in get_windows() --- quickget | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/quickget b/quickget index 740a28e..33ba775 100755 --- a/quickget +++ b/quickget @@ -1768,7 +1768,7 @@ function get_windows() { local ARCH="x64" local INDEX=0 local LANG_CODE="en" - local LANG_EDITION="" + local LANG_EDITION="${1}" local LATEST_WINDOWS_VERSION="" local WINDOWS_NAME="" local VERSION_ID="" @@ -1780,8 +1780,6 @@ function get_windows() { local DOWNLOAD_ID="" local DOWNLOAD_URL="" - LANG_EDITION="${1}" - # Ignore the most recent Windows 10 release for now. case ${RELEASE} in 10) INDEX=0;; From d20ad7aa1c17bf37047e35da340bef246b83deab Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 18:44:02 +0000 Subject: [PATCH 8/9] Add create_vm() create_vm() is a helper function that will make it possible to remove boiler plate from (most) get_() functions. --- quickget | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/quickget b/quickget index 33ba775..b651b56 100755 --- a/quickget +++ b/quickget @@ -1845,6 +1845,22 @@ function get_windows() { make_vm_config "${FILE_NAME}" "virtio-win.iso" } +create_vm() { + # shellcheck disable=SC2206 + local URL_HASH=(${1// / }) + local URL="${URL_HASH[0]}" + local HASH="${URL_HASH[1]}" + local ISO="${URL##*/}" + #echo "${URL}" + #echo "${ISO}" + #echo "${HASH}" + web_get "${URL}" "${VM_PATH}" + if [ -n "${HASH}" ]; then + check_hash "${ISO}" "${HASH}" + fi + make_vm_config "${ISO}" +} + trap cleanup EXIT if ((BASH_VERSINFO[0] < 4)) From 6b86e81e729b2f3d564485a6219a079258588bd0 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 18:48:42 +0000 Subject: [PATCH 9/9] macOS, Windows & Ubuntu do not use create_vm() The get_() function for macOS, Windows and Ubuntu are more complete because they do not solely use wget/aria2. Their get_() functions include the code to create VMs and therefore do not use the generic create_vm() helper. --- quickget | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quickget b/quickget index b651b56..3a314e4 100755 --- a/quickget +++ b/quickget @@ -1931,7 +1931,12 @@ if [ -n "${2}" ]; then VM_PATH="${OS}-${RELEASE}-${EDITION}" validate_release releases_"${OS}" get_"${OS}" "${EDITION}" + elif [ "${OS}" == "macos" ]; then + # macOS doesn't use create_vm() + validate_release releases_macos + get_macos elif [[ "${OS}" == *"ubuntu"* ]]; then + # Ubuntu doesn't use create_vm() validate_release releases_ubuntu get_ubuntu elif [ "${OS}" == "windows" ]; then @@ -1946,6 +1951,7 @@ if [ -n "${2}" ]; then exit 1 fi fi + # Windows doesn't use create_vm() validate_release releases_windows get_windows "${LANG}" else