mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-02 01:18:08 +01:00
Add mirror support to download-distfiles.sh
This commit is contained in:
parent
f772cbe131
commit
88ea21dfc9
2 changed files with 9 additions and 2 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# Optional arguments: Mirrors
|
||||||
|
|
||||||
download_source() {
|
download_source() {
|
||||||
local distfiles="${1}"
|
local distfiles="${1}"
|
||||||
local url="${2}"
|
local url="${2}"
|
||||||
|
|
@ -15,6 +17,10 @@ download_source() {
|
||||||
local dest_path="${distfiles}/${fname}"
|
local dest_path="${distfiles}/${fname}"
|
||||||
if ! [ -e "${dest_path}" ]; then
|
if ! [ -e "${dest_path}" ]; then
|
||||||
echo "Downloading ${fname}"
|
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
|
curl --fail --location "${url}" --output "${dest_path}" || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -33,6 +39,9 @@ check_source() {
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
mirrors=( "$@" )
|
||||||
|
mirrors_len="$#"
|
||||||
|
|
||||||
cd "$(dirname "$(readlink -f "$0")")"
|
cd "$(dirname "$(readlink -f "$0")")"
|
||||||
mkdir -p distfiles
|
mkdir -p distfiles
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,6 @@ do_file() {
|
||||||
echo "${uri}: ERROR! Must have tarball name if no http source."
|
echo "${uri}: ERROR! Must have tarball name if no http source."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Heuristic: all tarball filenames start with t
|
|
||||||
suffix="t${tarball#*.t}"
|
|
||||||
tarball="${dest}/${tarball}"
|
tarball="${dest}/${tarball}"
|
||||||
|
|
||||||
# Check if tarball already generated + matches checksum
|
# Check if tarball already generated + matches checksum
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue