commit: 88ea21dfc94ac6ed63f64dccf403e94d1d901665
parent f772cbe1312c99616aac65822411c75ca180dafb
Author: fosslinux <fosslinux@aussies.space>
Date: Fri, 27 Dec 2024 12:19:55 +1100
Add mirror support to download-distfiles.sh
Diffstat:
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/download-distfiles.sh b/download-distfiles.sh
@@ -4,6 +4,8 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
+# Optional arguments: Mirrors
+
download_source() {
local distfiles="${1}"
local url="${2}"
@@ -15,6 +17,10 @@ download_source() {
local dest_path="${distfiles}/${fname}"
if ! [ -e "${dest_path}" ]; then
echo "Downloading ${fname}"
+ if [ "${mirrors_len}" -ne 0 ]; then
+ local mirror_ix="$((RANDOM % mirrors_len))"
+ url="${mirrors[${mirror_ix}]}/${fname}"
+ fi
curl --fail --location "${url}" --output "${dest_path}" || true
fi
}
@@ -33,6 +39,9 @@ check_source() {
set -e
+mirrors=( "$@" )
+mirrors_len="$#"
+
cd "$(dirname "$(readlink -f "$0")")"
mkdir -p distfiles
diff --git a/mirror.sh b/mirror.sh
@@ -121,8 +121,6 @@ do_file() {
echo "${uri}: ERROR! Must have tarball name if no http source."
exit 1
fi
- # Heuristic: all tarball filenames start with t
- suffix="t${tarball#*.t}"
tarball="${dest}/${tarball}"
# Check if tarball already generated + matches checksum