pkgmeek: try the Pkgfile url before hitting the PKGMK_SOURCE_MIRRORS

This commit is contained in:
John McQuah 2022-06-03 12:11:53 -04:00
parent 817de00615
commit 3aacbacba0

View File

@ -75,7 +75,8 @@ here="${_local_[$u]}"; url="${source[$u]}";
errDL+=1; }
done ; }
[ $errDL = 0 ] && info "Successfully obtained all needed source files." || exit $E_DOWNLOAD
[ $errDL = 0 ] && { [ "$PKGMK_MTIME_ONLY" = "yes" ] || \
info "Successfully obtained all needed source files."; } || exit $E_DOWNLOAD
# If the user only asked for '-utd', perform the check using the sources that do exist.
check_pkg_mtime; pkg_utd=$?
@ -365,7 +366,7 @@ check_pkg_mtime() { # can be called even if some sources are missing
}
fetch_source() {
local u="$1"; local h="$2"; local m=0; local REPO SAVE_AS OCONTINUE OOUT; local finished=0;
local u="$1"; local h="$2"; local finished=0; local REPO SAVE_AS OCONTINUE OOUT
# Determine whether git can be used to obtain sources
local PKGMK_GIT_COMMAND="/usr/bin/git"
@ -377,13 +378,14 @@ fetch_source() {
[[ "$PKGMK_DOWNLOAD_PROG" =~ curl$ ]] && { OCONTINUE="-C -"; OOUT="$PKGMK_CURL_OPTIONS -o"; }
[[ "$PKGMK_DOWNLOAD_PROG" =~ (wget|curl)$ ]] || SAVE_AS=/bin/false
while [ $m -le ${#PKGMK_SOURCE_MIRRORS[@]} ] && [ $finished = 0 ] && [[ ! $SAVE_AS =~ false$ ]]; do
# when the index goes past the last element of PKGMK_SOURCE_MIRRORS,
# switch to using the url in the 'source' array.
local m=${#PKGMK_SOURCE_MIRRORS[@]}
# nonexistent element of PKGMK_SOURCE_MIRRORS means that the
# url given in the Pkgfile will be tried first
while [ $m -ge 0 ] && [ $finished = 0 ] && [[ ! $SAVE_AS =~ false$ ]]; do
[ "${PKGMK_SOURCE_MIRRORS[m]}" = "" ] && um=$u || \
{ REPO=$(echo ${PKGMK_SOURCE_MIRRORS[m]} | sed 's,/$,,');
um=$REPO/$(echo $u | sed 's,.*/,,'); }
m=$(( m+1 ))
m=$(( m-1 ))
# interrupted downloads from a previous run should be put where wget or curl will find them
[ -s "$src_dir/$h.partial" ] && { ln -s "$src_dir/$h.partial" . ;