From 1dc780b9e27b779f15bce6ee7911a91d55dea479 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 22 Feb 2022 15:15:56 +0000 Subject: [PATCH] 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##*/}"