Skip to content

Commit 3aa97bb

Browse files
committed
Support multiple mirrors in fetch_stage3_archive_name() #250
1 parent 018b055 commit 3aa97bb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/core.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,20 @@ function get_stage3_archive_regex() {
377377
function fetch_stage3_archive_name() {
378378
__fetch_stage3_archive_name=
379379
ARCH="${ARCH:-amd64}"
380-
ARCH_URL="${ARCH_URL:-${MIRROR}releases/${ARCH}/autobuilds/current-${STAGE3_BASE}/}"
380+
local mirrors_split mirror stage3_url stage3_path
381+
if [ -z "${ARCH_URL}" ]; then
382+
stage3_path="/releases/${ARCH}/autobuilds/current-${STAGE3_BASE}/"
383+
read -ra mirrors_split <<<"${MIRROR}"
384+
for mirror in "${mirrors_split[@]}"; do
385+
stage3_url="${mirror}${stage3_path}"
386+
if wget --spider "${stage3_url}" 2>/dev/null; then
387+
ARCH_URL="${stage3_url}"
388+
break;
389+
fi
390+
done
391+
fi
392+
[[ -z "${ARCH_URL}" ]] && die "Could not find stage3 location on mirror(s): ${MIRROR} with url path: ${stage3_path}"
393+
381394
local remote_files remote_line remote_date remote_file_type max_cap
382395
readarray -t remote_files <<< "$(wget -qO- "${ARCH_URL}")"
383396
remote_date=0

0 commit comments

Comments
 (0)