diff --git a/common/hooks/do-fetch/00-distfiles.sh b/common/hooks/do-fetch/00-distfiles.sh index 1adb86a5167..2065d5442a3 100644 --- a/common/hooks/do-fetch/00-distfiles.sh +++ b/common/hooks/do-fetch/00-distfiles.sh @@ -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 diff --git a/xbps-src b/xbps-src index c17270b62ee..1ce830c7bf9 100755 --- a/xbps-src +++ b/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