pkgmeek: add support for PKGMK_SOURCE_MIRRORS
This commit is contained in:
parent
1885070666
commit
817de00615
@ -70,8 +70,7 @@ here="${_local_[$u]}"; url="${source[$u]}";
|
|||||||
# appropriate name in the current directory
|
# appropriate name in the current directory
|
||||||
[ -e "$here" ] || [ "$src_dir" = "" ] || [ ! -e "$src_dir/$here" ] || ln -sf "$src_dir/$here" ;
|
[ -e "$here" ] || [ "$src_dir" = "" ] || [ ! -e "$src_dir/$here" ] || ln -sf "$src_dir/$here" ;
|
||||||
[ -e "$here" ] || [ ! -e "$PKGMK_ROOT/$here" ] || ln -sf "$PKGMK_ROOT/$here" . ;
|
[ -e "$here" ] || [ ! -e "$PKGMK_ROOT/$here" ] || ln -sf "$PKGMK_ROOT/$here" . ;
|
||||||
[ -e "$here" ] || fetch_source "$url" "$here";
|
[ -e "$here" ] || fetch_source "$url" "$here"; # <-- should also be able to resume partial downloads
|
||||||
# but if not, exit with an informative error message
|
|
||||||
[ -e "$here" ] || { error "failed to download $here. Check connection and try again.";
|
[ -e "$here" ] || { error "failed to download $here. Check connection and try again.";
|
||||||
errDL+=1; }
|
errDL+=1; }
|
||||||
done ; }
|
done ; }
|
||||||
@ -366,28 +365,40 @@ check_pkg_mtime() { # can be called even if some sources are missing
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetch_source() {
|
fetch_source() {
|
||||||
local u="$1"; local h="$2"; local SAVE_AS OCONTINUE OOUT;
|
local u="$1"; local h="$2"; local m=0; local REPO SAVE_AS OCONTINUE OOUT; local finished=0;
|
||||||
|
|
||||||
# Determine whether git can be used to obtain sources
|
# Determine whether git can be used to obtain sources
|
||||||
PKGMK_GIT_COMMAND="/usr/bin/git"
|
local PKGMK_GIT_COMMAND="/usr/bin/git"
|
||||||
[ -x "$PKGMK_GIT_COMMAND" ] || PKGMK_GIT_COMMAND="/bin/false"
|
[ -x "$PKGMK_GIT_COMMAND" ] || PKGMK_GIT_COMMAND="/bin/false"
|
||||||
[[ $u =~ ^(https|http|ssh|git)://.*/(.+)\.git$ ]] && SAVE_AS="$PKGMK_GIT_COMMAND clone $u"
|
[[ $u =~ ^(https|http|ssh|git)://.*/(.+)\.git$ ]] && \
|
||||||
|
{ "$PKGMK_GIT_COMMAND clone $u $h"; return $?; }
|
||||||
|
|
||||||
[[ "$PKGMK_DOWNLOAD_PROG" =~ wget$ ]] && { OCONTINUE="-c"; OOUT="-O"; }
|
[[ "$PKGMK_DOWNLOAD_PROG" =~ wget$ ]] && { OCONTINUE="-c"; OOUT="$PKGMK_WGET_OPTIONS -O"; }
|
||||||
[[ "$PKGMK_DOWNLOAD_PROG" =~ curl$ ]] && { OCONTINUE="-C -"; OOUT="-o"; }
|
[[ "$PKGMK_DOWNLOAD_PROG" =~ curl$ ]] && { OCONTINUE="-C -"; OOUT="$PKGMK_CURL_OPTIONS -o"; }
|
||||||
[[ "$PKGMK_DOWNLOAD_PROG" =~ (wget|curl)$ ]] || SAVE_AS=/bin/false
|
[[ "$PKGMK_DOWNLOAD_PROG" =~ (wget|curl)$ ]] || SAVE_AS=/bin/false
|
||||||
|
|
||||||
[ -s "$src_dir/$h.partial" ] && { ln -s "$src_dir/$h.partial" . ;
|
while [ $m -le ${#PKGMK_SOURCE_MIRRORS[@]} ] && [ $finished = 0 ] && [[ ! $SAVE_AS =~ false$ ]]; do
|
||||||
SAVE_AS="$PKGMK_DOWNLOAD_PROG $u $OCONTINUE $OOUT"; } \
|
# when the index goes past the last element of PKGMK_SOURCE_MIRRORS,
|
||||||
|| SAVE_AS="$PKGMK_DOWNLOAD_PROG $u $OOUT"
|
# switch to using the url in the 'source' array.
|
||||||
|
[ "${PKGMK_SOURCE_MIRRORS[m]}" = "" ] && um=$u || \
|
||||||
|
{ REPO=$(echo ${PKGMK_SOURCE_MIRRORS[m]} | sed 's,/$,,');
|
||||||
|
um=$REPO/$(echo $u | sed 's,.*/,,'); }
|
||||||
|
m=$(( m+1 ))
|
||||||
|
|
||||||
if $SAVE_AS "$h.partial"; then
|
# interrupted downloads from a previous run should be put where wget or curl will find them
|
||||||
[ "$src_dir" = "" ] || [ ! -w "$src_dir"/ ] || { mv "$h.partial" "$src_dir/$h";
|
[ -s "$src_dir/$h.partial" ] && { ln -s "$src_dir/$h.partial" . ;
|
||||||
ln -sf "$src_dir/$h" . ; }
|
SAVE_AS="$PKGMK_DOWNLOAD_PROG $um $OCONTINUE $OOUT"; } \
|
||||||
else # an interrupted download should not have its efforts destroyed by cleanup_work()
|
|| SAVE_AS="$PKGMK_DOWNLOAD_PROG $um $OOUT"
|
||||||
[ ! -e "$h.partial" ] || [ "$src_dir" = "" ] || [ ! -w "$src_dir"/ ] \
|
|
||||||
|| mv "$h.partial" "$src_dir"
|
if $SAVE_AS "$h.partial"; then
|
||||||
fi
|
finished=1
|
||||||
|
[ "$src_dir" = "" ] || [ ! -w "$src_dir"/ ] || { mv "$h.partial" "$src_dir/$h";
|
||||||
|
ln -sf "$src_dir/$h" . ; }
|
||||||
|
else # an interrupted download should not have its efforts destroyed by cleanup_work()
|
||||||
|
[ ! -e "$h.partial" ] || [ "$src_dir" = "" ] || [ ! -w "$src_dir"/ ] \
|
||||||
|
|| mv "$h.partial" "$src_dir"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cat_manifest() {
|
cat_manifest() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user