mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2024-08-14 22:46:53 +00:00
Prompt the user to download the Windows iso manually. Closes #612
This commit is contained in:
parent
4286405639
commit
8d3cf4c1a7
1 changed files with 72 additions and 48 deletions
120
quickget
120
quickget
|
@ -1907,12 +1907,19 @@ function dbg_windows() {
|
|||
|
||||
# Adapted from https://gist.github.com/hongkongkiwi/15a5bf16437315df256c118c163607cb
|
||||
function get_windows() {
|
||||
# Use the API to automatically download a Windows .iso image
|
||||
# The API we were using is unmaintained and not currently functional
|
||||
# 0 : Prompt for a manual ISO download
|
||||
# 1 : Use the API for automated download
|
||||
local API_GUIDED_DOWNLOAD=0
|
||||
|
||||
local ARCH="x64"
|
||||
local INDEX=0
|
||||
local LANG_CODE="en"
|
||||
local LANG_EDITION="${1}"
|
||||
local LATEST_WINDOWS_VERSION=""
|
||||
local WINDOWS_NAME=""
|
||||
local WINDOWS_ISO_URL=""
|
||||
local VERSION_ID=""
|
||||
local EDITION_ID=""
|
||||
local LANGUAGE_ID=""
|
||||
|
@ -1922,59 +1929,72 @@ function get_windows() {
|
|||
local DOWNLOAD_ID=""
|
||||
local DOWNLOAD_URL=""
|
||||
|
||||
# Ignore the most recent Windows 10 release for now.
|
||||
case ${RELEASE} in
|
||||
10) INDEX=0;;
|
||||
11) INDEX=0;;
|
||||
esac
|
||||
if [ ${API_GUIDED_DOWNLOAD} -eq 1 ]; then
|
||||
# Ignore the most recent Windows 10 release for now.
|
||||
case ${RELEASE} in
|
||||
10) INDEX=0;;
|
||||
11) INDEX=0;;
|
||||
esac
|
||||
|
||||
echo "Getting Windows ${RELEASE} URL..."
|
||||
WINDOWS_VERSIONS=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))')
|
||||
dbg_windows "${WINDOWS_VERSIONS}"
|
||||
LATEST_WINDOWS_VERSION=$(echo "${WINDOWS_VERSIONS}" | jq -c 'map(select(.name | contains("Windows '"${RELEASE}"'")))['${INDEX}']')
|
||||
dbg_windows "${LATEST_WINDOWS_VERSION}"
|
||||
WINDOWS_NAME=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .name)
|
||||
dbg_windows "${WINDOWS_NAME}"
|
||||
VERSION_ID=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .version_id)
|
||||
dbg_windows "${VERSION_ID}"
|
||||
echo "Getting Windows ${RELEASE} URL..."
|
||||
WINDOWS_VERSIONS=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))')
|
||||
dbg_windows "${WINDOWS_VERSIONS}"
|
||||
LATEST_WINDOWS_VERSION=$(echo "${WINDOWS_VERSIONS}" | jq -c 'map(select(.name | contains("Windows '"${RELEASE}"'")))['${INDEX}']')
|
||||
dbg_windows "${LATEST_WINDOWS_VERSION}"
|
||||
WINDOWS_NAME=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .name)
|
||||
dbg_windows "${WINDOWS_NAME}"
|
||||
VERSION_ID=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .version_id)
|
||||
dbg_windows "${VERSION_ID}"
|
||||
|
||||
case ${RELEASE} in
|
||||
8) EDITION_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows 8.1 Pro + Core").edition_id');;
|
||||
10|11) EDITION_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows '"${RELEASE}"'").edition_id');;
|
||||
esac
|
||||
dbg_windows "${EDITION_ID}"
|
||||
case ${RELEASE} in
|
||||
8) EDITION_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows 8.1 Pro + Core").edition_id');;
|
||||
10|11) EDITION_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows '"${RELEASE}"'").edition_id');;
|
||||
esac
|
||||
dbg_windows "${EDITION_ID}"
|
||||
|
||||
LANGUAGE_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_language.php?edition_id=${EDITION_ID}&lang=name_${LANG_CODE}" | jq -r '.languages[] | select(.name_'${LANG_CODE}'=="'"${LANG_EDITION}"'").language_id')
|
||||
dbg_windows "${LANGUAGE_ID}"
|
||||
ARCH_INFO=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_arch.php?language_id=${LANGUAGE_ID}")
|
||||
dbg_windows "${ARCH_INFO}"
|
||||
FILE_NAME=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).name')
|
||||
dbg_windows "${FILE_NAME}"
|
||||
ARCH_ID=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).arch_id')
|
||||
dbg_windows "${ARCH_ID}"
|
||||
DOWNLOAD_INFO=$(wget -4 -q -O- "https://tb.rg-adguard.net/dl.php?fileName=${ARCH_ID}&lang=en")
|
||||
dbg_windows "${DOWNLOAD_INFO}"
|
||||
DOWNLOAD_SHA1=$(echo "${DOWNLOAD_INFO}" | sed -e 's/<[^>]*>//g' | grep -o -P '(?<=SHA1: ).*(?= expire)' | sed 's/Link//')
|
||||
dbg_windows "${DOWNLOAD_SHA1}"
|
||||
DOWNLOAD_ID=$(echo "${DOWNLOAD_INFO}" | grep -oP '(?<=https:\/\/tb\.rg-adguard\.net/dl\.php\?go=)[0-9a-z]+')
|
||||
dbg_windows "${DOWNLOAD_ID}"
|
||||
REDIRECT_URL="https://tb.rg-adguard.net/dl.php?go=${DOWNLOAD_ID}"
|
||||
dbg_windows "${REDIRECT_URL}"
|
||||
DOWNLOAD_URL=$(curl --head --silent --write-out "%{redirect_url}\n" --output /dev/null "${REDIRECT_URL}")
|
||||
dbg_windows "${DOWNLOAD_URL}"
|
||||
LANGUAGE_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_language.php?edition_id=${EDITION_ID}&lang=name_${LANG_CODE}" | jq -r '.languages[] | select(.name_'${LANG_CODE}'=="'"${LANG_EDITION}"'").language_id')
|
||||
dbg_windows "${LANGUAGE_ID}"
|
||||
ARCH_INFO=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_arch.php?language_id=${LANGUAGE_ID}")
|
||||
dbg_windows "${ARCH_INFO}"
|
||||
FILE_NAME=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).name')
|
||||
dbg_windows "${FILE_NAME}"
|
||||
ARCH_ID=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).arch_id')
|
||||
dbg_windows "${ARCH_ID}"
|
||||
DOWNLOAD_INFO=$(wget -4 -q -O- "https://tb.rg-adguard.net/dl.php?fileName=${ARCH_ID}&lang=en")
|
||||
dbg_windows "${DOWNLOAD_INFO}"
|
||||
DOWNLOAD_SHA1=$(echo "${DOWNLOAD_INFO}" | sed -e 's/<[^>]*>//g' | grep -o -P '(?<=SHA1: ).*(?= expire)' | sed 's/Link//')
|
||||
dbg_windows "${DOWNLOAD_SHA1}"
|
||||
DOWNLOAD_ID=$(echo "${DOWNLOAD_INFO}" | grep -oP '(?<=https:\/\/tb\.rg-adguard\.net/dl\.php\?go=)[0-9a-z]+')
|
||||
dbg_windows "${DOWNLOAD_ID}"
|
||||
REDIRECT_URL="https://tb.rg-adguard.net/dl.php?go=${DOWNLOAD_ID}"
|
||||
dbg_windows "${REDIRECT_URL}"
|
||||
DOWNLOAD_URL=$(curl --head --silent --write-out "%{redirect_url}\n" --output /dev/null "${REDIRECT_URL}")
|
||||
dbg_windows "${DOWNLOAD_URL}"
|
||||
|
||||
MS_BASE_URL="https://software.download.prss.microsoft.com/"
|
||||
if [[ ! ${DOWNLOAD_URL} =~ ^${MS_BASE_URL} ]]; then
|
||||
echo "Download URL not leading to Microsoft CDN"
|
||||
exit 1
|
||||
fi
|
||||
MS_BASE_URL="https://software.download.prss.microsoft.com/"
|
||||
if [[ ! ${DOWNLOAD_URL} =~ ^${MS_BASE_URL} ]]; then
|
||||
echo "Download URL not leading to Microsoft CDN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading ${WINDOWS_NAME}..."
|
||||
web_get "${DOWNLOAD_URL}" "${VM_PATH}" "${FILE_NAME}"
|
||||
echo "Downloading ${WINDOWS_NAME}..."
|
||||
web_get "${DOWNLOAD_URL}" "${VM_PATH}" "${FILE_NAME}"
|
||||
|
||||
# Windows 10 doesn't include a SHA1, so only check the integrity if the SHA1 is available.
|
||||
if [ -n "${DOWNLOAD_SHA1}" ]; then
|
||||
check_hash "${FILE_NAME}" "${DOWNLOAD_SHA1}"
|
||||
# Windows 10 doesn't include a SHA1, so only check the integrity if the SHA1 is available.
|
||||
if [ -n "${DOWNLOAD_SHA1}" ]; then
|
||||
check_hash "${FILE_NAME}" "${DOWNLOAD_SHA1}"
|
||||
fi
|
||||
else
|
||||
case ${RELEASE} in
|
||||
10) WINDOWS_ISO_URL="https://www.microsoft.com/software-download/windows10";;
|
||||
11) WINDOWS_ISO_URL="https://www.microsoft.com/software-download/windows11";;
|
||||
esac
|
||||
echo "######################################################################"
|
||||
echo "# Download a Windows ${RELEASE} .iso image from:"
|
||||
echo "# - ${WINDOWS_ISO_URL}"
|
||||
echo "# Put the .iso image in the ${VM_PATH} directory and rename"
|
||||
echo "# it to windows-${RELEASE}.iso."
|
||||
echo "######################################################################"
|
||||
fi
|
||||
|
||||
web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}"
|
||||
|
@ -1991,7 +2011,11 @@ function get_windows() {
|
|||
mkisofs -quiet -l -o "${VM_PATH}/unattended.iso" "${VM_PATH}/unattended/"
|
||||
;;
|
||||
esac
|
||||
make_vm_config "${FILE_NAME}" "virtio-win.iso"
|
||||
|
||||
case "${API_GUIDED_DOWNLOAD}" in
|
||||
0) make_vm_config "windows-${RELEASE}.iso" "virtio-win.iso";;
|
||||
1) make_vm_config "${FILE_NAME}" "virtio-win.iso";;
|
||||
esac
|
||||
}
|
||||
|
||||
create_vm() {
|
||||
|
|
Loading…
Reference in a new issue