mirror of
https://github.com/void-linux/void-packages.git
synced 2025-04-22 17:17:03 +02:00
xbps-src: add option to use distfiles mirror as a fallback
This adds an optional configuration to add a fallback distfiles mirror The idea is that normally, distfiles should be fetched from the urls in the template. However, occasionally the urls have rotted, or are simply down temporairily, in which case the fetch will fail. A workaround to this has been to use the $XBPS_DISTFILES_MIRROR option, however the downside to this is that it is always tried first, and 99% of the time isn't needed. This adds the $XBPS_DISTFILES_FALLBACK option, which can be set to an addiontional list of mirrors which will be attempted after both $XBPS_DISTFILES_MIRROR, and the urls in the template have failed to fetch the distfiles Co-authored-by: oreo639 <oreo6391@gmail.com>
This commit is contained in:
parent
2f69057b87
commit
98461414eb
2 changed files with 16 additions and 9 deletions
|
@ -128,11 +128,11 @@ link_cksum() {
|
|||
}
|
||||
|
||||
try_mirrors() {
|
||||
local curfile="$1" distfile="$2" cksum="$3" f="$4"
|
||||
local curfile="$1" distfile="$2" cksum="$3" f="$4" mirror_list="$5"
|
||||
local filesum basefile mirror path scheme good
|
||||
[ -z "$XBPS_DISTFILES_MIRROR" ] && return 1
|
||||
[ -z "$mirror_list" ] && return 1
|
||||
basefile="${f##*/}"
|
||||
for mirror in $XBPS_DISTFILES_MIRROR; do
|
||||
for mirror in $mirror_list; do
|
||||
scheme="file"
|
||||
if [[ $mirror == *://* ]]; then
|
||||
scheme="${mirror%%:/*}"
|
||||
|
@ -148,8 +148,8 @@ try_mirrors() {
|
|||
continue
|
||||
fi
|
||||
fi
|
||||
if [[ "$mirror" == *voidlinux* ]]; then
|
||||
# For distfiles.voidlinux.* append the subdirectory
|
||||
if [[ "$mirror" == *sources.voidlinux.* ]]; then
|
||||
# For sources.voidlinux.* append the subdirectory
|
||||
mirror="$mirror/$pkgname-$version"
|
||||
fi
|
||||
msg_normal "$pkgver: fetching distfile '$curfile' from mirror '$mirror'...\n"
|
||||
|
@ -286,11 +286,14 @@ hook() {
|
|||
fi
|
||||
|
||||
# If distfile does not exist, download it from a mirror location.
|
||||
if try_mirrors "$curfile" "$distfile" "${_checksums[$i]}" "${_distfiles[$i]}"; then
|
||||
if try_mirrors "$curfile" "$distfile" "${_checksums[$i]}" "${_distfiles[$i]}" "$XBPS_DISTFILES_MIRROR"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! try_urls "$curfile"; then
|
||||
if try_mirrors "$curfile" "$distfile" "${_checksums[$i]}" "${_distfiles[$i]}" "$XBPS_DISTFILES_FALLBACK"; then
|
||||
continue
|
||||
fi
|
||||
msg_error "$pkgver: failed to fetch '$curfile'.\n"
|
||||
fi
|
||||
done
|
||||
|
|
10
xbps-src
10
xbps-src
|
@ -343,10 +343,11 @@ read_pkg() {
|
|||
}
|
||||
|
||||
setup_distfiles_mirror() {
|
||||
local mirror_list="$1"
|
||||
local mirror scheme path
|
||||
|
||||
# Scheme file:// mirror locations only work with uchroot
|
||||
for mirror in $XBPS_DISTFILES_MIRROR; do
|
||||
for mirror in $mirror_list; do
|
||||
scheme="file"
|
||||
if [[ "$mirror" == *://* ]]; then
|
||||
scheme="${mirror%%://*}"
|
||||
|
@ -696,7 +697,7 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
|
|||
XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
|
||||
XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
|
||||
XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
|
||||
XBPS_PRESERVE_PKGS XBPS_IGNORE_BROKENNESS
|
||||
XBPS_PRESERVE_PKGS XBPS_IGNORE_BROKENNESS XBPS_DISTFILES_FALLBACK
|
||||
|
||||
for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
|
||||
eval val="\$XBPS_$i"
|
||||
|
@ -760,7 +761,10 @@ done
|
|||
if [ -z "$IN_CHROOT" ]; then
|
||||
trap 'exit_func' INT TERM
|
||||
if [ -n "$XBPS_DISTFILES_MIRROR" ]; then
|
||||
setup_distfiles_mirror
|
||||
setup_distfiles_mirror "$XBPS_DISTFILES_MIRROR"
|
||||
fi
|
||||
if [ -n "$XBPS_DISTFILES_FALLBACK" ]; then
|
||||
setup_distfiles_mirror "$XBPS_DISTFILES_FALLBACK"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue