Probe for TC mirror during tinyipa build
this patch adds a script with known Tinycore Linux HTTP mirrors and if TINYCORE_MIRROR_URL env var was not provided explicitly, sets in to the first URL from the list that responds to HEAD request. The HEAD request is performed without retries and with timeout of 10 seconds. The list of mirrors is taken from official TC wiki [0]. Currently not responding mirrors are moved to the bottom of the list, ant those that currently respond with 404 are moved to the very bottom. The main official repo is left at the first mirror to try. [0] http://wiki.tinycorelinux.net/wiki:mirrors Change-Id: I539db06baf1d27b428b75d412851367bfe8a2608
This commit is contained in:
parent
005927b80e
commit
3a4d319059
@ -2,9 +2,10 @@
|
||||
|
||||
set -ex
|
||||
WORKDIR=$(readlink -f $0 | xargs dirname)
|
||||
source ${WORKDIR}/tc-mirror.sh
|
||||
BUILDDIR="$WORKDIR/tinyipabuild"
|
||||
BUILD_AND_INSTALL_TINYIPA=${BUILD_AND_INSTALL_TINYIPA:-false}
|
||||
TINYCORE_MIRROR_URL=${TINYCORE_MIRROR_URL:-"http://repo.tinycorelinux.net"}
|
||||
TINYCORE_MIRROR_URL=${TINYCORE_MIRROR_URL:-}
|
||||
|
||||
CHROOT_PATH="/tmp/overides:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
CHROOT_CMD="sudo chroot $BUILDDIR /usr/bin/env -i PATH=$CHROOT_PATH http_proxy=$http_proxy https_proxy=$https_proxy no_proxy=$no_proxy"
|
||||
@ -32,6 +33,9 @@ fi
|
||||
# Download and Cache Tiny Core Files
|
||||
##############################################
|
||||
|
||||
# Find a working TC mirror if none is explicitly provided
|
||||
choose_tc_mirror
|
||||
|
||||
cd $WORKDIR/build_files
|
||||
wget -N $TINYCORE_MIRROR_URL/7.x/x86_64/release/distribution_files/corepure64.gz
|
||||
wget -N $TINYCORE_MIRROR_URL/7.x/x86_64/release/distribution_files/vmlinuz64
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
set -ex
|
||||
WORKDIR=$(readlink -f $0 | xargs dirname)
|
||||
source ${WORKDIR}/tc-mirror.sh
|
||||
BUILDDIR="$WORKDIR/tinyipabuild"
|
||||
FINALDIR="$WORKDIR/tinyipafinal"
|
||||
BUILD_AND_INSTALL_TINYIPA=${BUILD_AND_INSTALL_TINYIPA:-true}
|
||||
TINYCORE_MIRROR_URL=${TINYCORE_MIRROR_URL:-"http://repo.tinycorelinux.net"}
|
||||
TINYCORE_MIRROR_URL=${TINYCORE_MIRROR_URL:-}
|
||||
ENABLE_SSH=${ENABLE_SSH:-false}
|
||||
SSH_PUBLIC_KEY=${SSH_PUBLIC_KEY:-}
|
||||
PYOPTIMIZE_TINYIPA=${PYOPTIMIZE_TINYIPA:-true}
|
||||
@ -19,6 +20,10 @@ TC_CHROOT_CMD="sudo chroot --userspec=$TC:$STAFF $FINALDIR /usr/bin/env -i PATH=
|
||||
|
||||
echo "Finalising tinyipa:"
|
||||
|
||||
# Find a working TC mirror if none is explicitly provided
|
||||
choose_tc_mirror
|
||||
|
||||
|
||||
if $ENABLE_SSH ; then
|
||||
echo "Validating location of public SSH key"
|
||||
if [ -n "$SSH_PUBLIC_KEY" ]; then
|
||||
|
52
imagebuild/tinyipa/tc-mirror.sh
Normal file
52
imagebuild/tinyipa/tc-mirror.sh
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
#NOTE(pas-ha)
|
||||
# The first URL is the official TC repo,
|
||||
# the rest of the list is taken from
|
||||
# http://wiki.tinycorelinux.net/wiki:mirrors
|
||||
# as of time of this writing.
|
||||
# Only HTTP mirrors were considered with the following ordering
|
||||
# - those that were unavailable are moved to the bottom of the list
|
||||
# - those that already responded with 404 are moved to the very bottom
|
||||
|
||||
TC_MIRRORS="http://repo.tinycorelinux.net
|
||||
http://distro.ibiblio.org/tinycorelinux
|
||||
http://mirror.cedia.org.ec/tinycorelinux
|
||||
http://mirror.epn.edu.ec/tinycorelinux
|
||||
http://mirrors.163.com/tinycorelinux
|
||||
http://kambing.ui.ac.id/tinycorelinux
|
||||
http://ftp.nluug.nl/os/Linux/distr/tinycorelinux
|
||||
http://ftp.vim.org/os/Linux/distr/tinycorelinux
|
||||
http://www.gtlib.gatech.edu/pub/tinycore
|
||||
http://tinycore.mirror.uber.com.au
|
||||
http://l4u-00.jinr.ru/LinuxArchive/Ftp/tinycorelinux"
|
||||
|
||||
function probe_url {
|
||||
wget -q --spider --tries 1 --timeout 10 "$1" 2>&1
|
||||
}
|
||||
|
||||
function choose_tc_mirror {
|
||||
if [ -z ${TINYCORE_MIRROR_URL} ]; then
|
||||
for url in ${TC_MIRRORS}; do
|
||||
echo "Checking Tiny Core Linux mirror ${url}"
|
||||
if probe_url ${url} ; then
|
||||
echo "Check succeeded: ${url} is responding."
|
||||
TINYCORE_MIRROR_URL=${url}
|
||||
break
|
||||
else
|
||||
echo "Check failed: ${url} is not responding"
|
||||
fi
|
||||
done
|
||||
if [ -z ${TINYCORE_MIRROR_URL} ]; then
|
||||
echo "Failed to find working Tiny Core Linux mirror"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Probing provided Tiny Core Linux mirror ${TINYCORE_MIRROR_URL}"
|
||||
if probe_url ${TINYCORE_MIRROR_URL} ; then
|
||||
echo "Check succeeded: ${TINYCORE_MIRROR_URL} is responding."
|
||||
else
|
||||
echo "Check failed: ${TINYCORE_MIRROR_URL} is not responding"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
Loading…
Reference in New Issue
Block a user