From e9f26f7758b529f5a0a71acf60a4286c5346bac5 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 19 Oct 2021 20:36:05 +0100 Subject: [PATCH] Update Pop!_OS support to use their API. Close #137 Also adds support for downloading the intel or nvidia versions and checks the hash. --- quickget | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/quickget b/quickget index eed792a..3eca08b 100755 --- a/quickget +++ b/quickget @@ -65,7 +65,7 @@ function list_all() { local LANG local OS local RELEASE - echo "Display Name,OS,Release,Language" + echo "Display Name,OS,Release,Option" for OS in $(os_support); do DISPLAY_NAME="$(pretty_name "${OS}")" if [[ "${OS}" == *"ubuntu"* ]]; then @@ -81,6 +81,10 @@ function list_all() { for LANG in "${LANGS[@]}"; do echo "${DISPLAY_NAME},${OS},${RELEASE},${LANG}", done + elif [ "${OS}" == "popos" ]; then + for DRIVER in intel nvidia; do + echo "${DISPLAY_NAME},${OS},${RELEASE},${DRIVER}", + done else echo "${DISPLAY_NAME},${OS},${RELEASE},," fi @@ -686,13 +690,24 @@ function get_macos() { } function get_popos() { + local DRIVER="intel" + local HASH="" local ISO="" local URL="" + if [ -n "${1}" ]; then + DRIVER="${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}" + + URL=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${DRIVER}" | jq ".url") + URL="${URL//\"/}" + ISO=$(echo "${URL}" | sed -e "s/.*\/\([^\/]*\)$/\1/") + HASH=$(wget -q -O- "https://api.pop-os.org/builds/${RELEASE}/${DRIVER}" | jq ".sha_sum") + HASH="${HASH//\"/}" web_get "${URL}" "${VM_PATH}" + check_hash "${ISO}" "${HASH}" make_vm_config "${ISO}" } @@ -831,7 +846,21 @@ if [ -n "${2}" ]; then elif [ "${OS}" == "opensuse" ]; then get_opensuse elif [ "${OS}" == "popos" ]; then - get_popos + if [ -n "${3}" ]; then + DRIVER="${3}" + DRIVERS=(intel nvidia) + if [[ ! ${DRIVERS[*]} =~ ${DRIVER} ]]; then + echo "ERROR! ${DRIVER} is not a supported driver:" + for DRIVER in "${DRIVERS[@]}"; do + echo "${DRIVER}" + done + exit 1 + fi + else + DRIVER="intel" + fi + VM_PATH="${OS}-${RELEASE}-${DRIVER}" + get_popos "${DRIVER}" elif [[ "${OS}" == *"ubuntu"* ]]; then get_ubuntu elif [ "${OS}" == "windows" ]; then