Implement XBPS_DISTFILES_MIRROR (second try)

The idea is to remove some burden from the original download
locations for distfiles by specifying one or more mirror locations.

+ Works with http:// or ftp:// mirrors for all $XBPS_CHROOT_CMD variants
+ Works with file:// mirrors together with uchroot and proot
This commit is contained in:
Jürgen Buchmüller 2015-08-19 14:45:47 +02:00
parent 686b7bff71
commit 793a156a0f
3 changed files with 100 additions and 5 deletions

View file

@ -351,6 +351,32 @@ read_pkg() {
setup_pkg $XBPS_TARGET_PKG $XBPS_CROSS_BUILD
}
setup_distfiles_mirror() {
local mirror scheme path
# Scheme file:// mirror locations only work with uchroot or proot
for mirror in $XBPS_DISTFILES_MIRROR; do
scheme="file"
if [[ "$mirror" == *://* ]]; then
scheme="${mirror%%://*}"
path="${mirror#${scheme}://}"
else
path="$mirror"
fi
[ "$scheme" != "file" ] && continue
if [ "$XBPS_CHROOT_CMD" == "uchroot" -o "$XBPS_CHROOT_CMD" == "proot" ]; then
if [ ! -d "$path" ]; then
msg_warn "Invalid path in XBPS_DISTFILES_MIRROR ($mirror)\n"
continue
fi
mkdir -p "$XBPS_MASTERDIR/$path"
XBPS_CHROOT_CMD_ARGS+=" -b $path:$path"
else
msg_warn "File URLs ($mirror) don't work with '$XBPS_CHROOT_CMD'\n"
fi
done
}
readonly XBPS_VERSION_REQ="0.46"
readonly XBPS_VERSION=$(xbps-uhelper -V|awk '{print $2}')
readonly XBPS_SRC_VERSION="113"
@ -516,7 +542,7 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_PKG_OPTIONS \
XBPS_CONFIG_FILE XBPS_KEEP_ALL XBPS_HOSTDIR XBPS_MASTERDIR \
XBPS_SRC_VERSION XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR \
XBPS_BINPKG_EXISTS XBPS_LIBEXECDIR XBPS_DISTDIR
XBPS_BINPKG_EXISTS XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR
for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
eval val="\$XBPS_$i"
@ -571,6 +597,9 @@ check_build_requirements
if [ -z "$IN_CHROOT" ]; then
trap 'exit_func' INT TERM
if [ -n "$XBPS_DISTFILES_MIRROR" ]; then
setup_distfiles_mirror
fi
fi
#