Skip to content

Commit 0a16748

Browse files
committed
feat(quickget): add architecture-aware output and filenames
- Display supported architectures when running ./quickget <os> (shows "Archs: amd64 arm64") - Add get_supported_archs() helper to enumerate available architectures - Add arch_suffix() helper and append architecture suffix to VM dir/config names for foreign architectures (e.g., alpine-v3.23-arm64/) - Add NORMALISED_HOST_ARCH variable to detect foreign vs native architecture - Include arch="x86_64" or arch="aarch64" in config files for foreign downloads
1 parent 3c785eb commit 0a16748

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

quickget

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ case "${HOST_ARCH}" in
1515
*) ARCH="amd64";;
1616
esac
1717

18+
function arch_suffix() {
19+
# Return architecture suffix for foreign architectures, empty for native
20+
if [ "${ARCH}" != "${NORMALISED_HOST_ARCH}" ]; then
21+
echo "-${ARCH}"
22+
fi
23+
}
24+
1825
function cleanup() {
1926
if [ -n "$(jobs -p)" ]; then
2027
kill "$(jobs -p)" 2>/dev/null
@@ -165,17 +172,22 @@ function error_specify_release() {
165172
*ubuntu-server*)
166173
echo -en " - Releases:\t"
167174
releases_ubuntu-server
175+
echo -en " - Archs:\t"
176+
get_supported_archs "${OS}"
168177
;;
169178
*ubuntu*)
170179
echo -en " - Releases:\t"
171180
releases_ubuntu
181+
echo -en " - Archs:\t"
182+
get_supported_archs "${OS}"
172183
;;
173184
*windows*)
174185
echo -en " - Releases:\t"
175186
"releases_${OS}"
176187
echo -en " - Languages:\t"
177188
"languages_${OS}"
178189
echo "${I18NS[@]}"
190+
# Windows uses multi-arch ISOs, skip architecture display
179191
;;
180192
*)
181193
echo -en " - Releases:\t"
@@ -184,6 +196,8 @@ function error_specify_release() {
184196
echo -en " - Editions:\t"
185197
"editions_${OS}" | fmt -w 80
186198
fi
199+
echo -en " - Archs:\t"
200+
get_supported_archs "${OS}"
187201
;;
188202
esac
189203
echo -e "\nERROR! You must specify a release."
@@ -1450,6 +1464,18 @@ function is_arch_supported() {
14501464
[[ " ${SUPPORTED} " == *" ${CHECK_ARCH} "* ]]
14511465
}
14521466

1467+
# Get supported architectures for an OS
1468+
function get_supported_archs() {
1469+
local OS="${1}"
1470+
# Check if arch function exists for this OS
1471+
if [[ $(type -t "arch_${OS}") == function ]]; then
1472+
arch_"${OS}"
1473+
else
1474+
# Default: amd64 only
1475+
echo "amd64"
1476+
fi
1477+
}
1478+
14531479
function editions_zorin() {
14541480
# Lite edition not available for Zorin 18 (Pro-only starting from 18)
14551481
# When RELEASE is unset (e.g. csv_data context), return all editions
@@ -1622,7 +1648,6 @@ function web_get() {
16221648
if [[ ${OS} != windows && ${OS} != macos && ${OS} != windows-server ]]; then
16231649
echo "Downloading $(pretty_name "${OS}") ${RELEASE} ${EDITION}"
16241650
echo "- URL: ${URL}"
1625-
echo "- PATH: ${PWD}/${DIR}/${FILE}"
16261651
fi
16271652

16281653
if ! curl --disable --progress-bar --location --output "${DIR}/${FILE}" --continue-at - --user-agent "${USER_AGENT}" "${HEADERS[@]}" -- "${URL}"; then
@@ -1789,8 +1814,12 @@ function make_vm_config() {
17891814
if [ ! -e "${CONF_FILE}" ]; then
17901815
echo "Making ${CONF_FILE}"
17911816
local ARCH_LINE=""
1792-
if [ "${ARCH}" == "arm64" ]; then
1793-
ARCH_LINE="arch=\"aarch64\""
1817+
if [ "${ARCH}" != "${NORMALISED_HOST_ARCH}" ]; then
1818+
if [ "${ARCH}" == "arm64" ]; then
1819+
ARCH_LINE="arch=\"aarch64\""
1820+
else
1821+
ARCH_LINE="arch=\"x86_64\""
1822+
fi
17941823
fi
17951824
cat << EOF > "${CONF_FILE}"
17961825
#!${QUICKEMU} --vm
@@ -3096,10 +3125,10 @@ function get_ubuntu() {
30963125
else
30973126
URL="https://cdimage.ubuntu.com/${OS}/jammy/daily-live/current"
30983127
fi
3099-
VM_PATH="${OS}-jammy-live"
3128+
VM_PATH="${OS}-jammy-live$(arch_suffix)"
31003129
elif [[ "${RELEASE}" == "daily"* ]] || [ "${RELEASE}" == "dvd" ]; then
31013130
URL="https://cdimage.ubuntu.com/${OS}/${RELEASE}/current"
3102-
VM_PATH="${OS}-${RELEASE}"
3131+
VM_PATH="${OS}-${RELEASE}$(arch_suffix)"
31033132
elif [ "${OS}" == "ubuntu" ] && [ "${UBUNTU_ARCH}" == "arm64" ]; then
31043133
# ARM64 desktop ISOs are hosted on cdimage.ubuntu.com
31053134
URL="https://cdimage.ubuntu.com/releases/${RELEASE}/release"
@@ -3993,6 +4022,8 @@ QUICKEMU=$(resolve_quickemu)
39934022
I18NS=()
39944023
OPERATION=""
39954024
CHECK_ALL_ARCH="false"
4025+
# Normalised host architecture for foreign arch detection
4026+
NORMALISED_HOST_ARCH="${ARCH}"
39964027
CURL=$(command -v curl)
39974028
if [ ! -x "${CURL}" ]; then
39984029
echo "ERROR! curl not found. Please install curl"
@@ -4182,7 +4213,7 @@ fi
41824213

41834214
if [ -n "${2}" ]; then
41844215
RELEASE="${2}"
4185-
VM_PATH="${OS}-${RELEASE}"
4216+
VM_PATH="${OS}-${RELEASE}$(arch_suffix)"
41864217
# If the OS has an editions_() function, use it.
41874218
if [[ $(type -t "editions_${OS}") == function ]]; then
41884219
validate_release "releases_${OS}"
@@ -4215,7 +4246,7 @@ if [ -n "${2}" ]; then
42154246
fi
42164247
fi
42174248
handle_missing
4218-
VM_PATH="${OS}-${RELEASE}-${EDITION}"
4249+
VM_PATH="${OS}-${RELEASE}-${EDITION}$(arch_suffix)"
42194250
create_vm "$("get_${OS}" "${EDITION}")"
42204251
elif [ "${OS}" == "macos" ]; then
42214252
# macOS doesn't use create_vm()
@@ -4238,7 +4269,7 @@ if [ -n "${2}" ]; then
42384269
if ! is_valid_language "${I18N}"; then
42394270
error_not_supported_lang
42404271
fi
4241-
VM_PATH="$(echo "${OS}-${RELEASE}-${I18N// /-}" | tr -d '()')"
4272+
VM_PATH="$(echo "${OS}-${RELEASE}-${I18N// /-}" | tr -d '()')$(arch_suffix)"
42424273
fi
42434274
validate_release "releases_${OS}"
42444275
get_windows

0 commit comments

Comments
 (0)