common: retry ftp download during CI

This commit is contained in:
Piotr Wójcik 2020-01-29 23:28:40 +01:00 committed by Piotr
parent 3d18522142
commit 588e8cdb7b
3 changed files with 18 additions and 4 deletions

View File

@ -198,7 +198,7 @@ try_mirrors() {
hook() { hook() {
local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version" local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
local dfcount=0 dfgood=0 errors=0 local dfcount=0 dfgood=0 errors=0 max_retries
if [ ! -d "$srcdir" ]; then if [ ! -d "$srcdir" ]; then
mkdir -p -m775 "$srcdir" mkdir -p -m775 "$srcdir"
@ -266,10 +266,21 @@ hook() {
try_mirrors $curfile $distfile $dfcount $pkgname-$version $f try_mirrors $curfile $distfile $dfcount $pkgname-$version $f
fi fi
# If distfile does not exist, download it from the original location. # If distfile does not exist, download it from the original location.
if [ ! -f "$distfile" ]; then if [[ "$FTP_RETRIES" && "${f}" =~ ^ftp:// ]]; then
msg_normal "$pkgver: fetching distfile '$curfile'...\n" max_retries="$FTP_RETRIES"
flock "${distfile}.part" $fetch_cmd "$f" else
max_retries=1
fi fi
for retry in $(seq 1 1 $max_retries); do
if [ ! -f "$distfile" ]; then
if [ "$retry" == 1 ]; then
msg_normal "$pkgver: fetching distfile '$curfile'...\n"
else
msg_normal "$pkgver: fetch attempt $retry of $max_retries...\n"
fi
flock "${distfile}.part" $fetch_cmd "$f"
fi
done
if [ ! -f "$distfile" ]; then if [ ! -f "$distfile" ]; then
msg_error "$pkgver: failed to fetch $curfile.\n" msg_error "$pkgver: failed to fetch $curfile.\n"
fi fi

View File

@ -13,6 +13,8 @@ if [ -r /proc/cpuinfo ]; then
NPROCS=$(grep ^proc /proc/cpuinfo|wc -l) NPROCS=$(grep ^proc /proc/cpuinfo|wc -l)
fi fi
export FTP_RETRIES=10
for pkg in ${PKGS}; do for pkg in ${PKGS}; do
/hostrepo/xbps-src -j$NPROCS -H "$HOME"/hostdir $arch pkg "$pkg" /hostrepo/xbps-src -j$NPROCS -H "$HOME"/hostdir $arch pkg "$pkg"
[ $? -eq 1 ] && exit 1 [ $? -eq 1 ] && exit 1

View File

@ -173,6 +173,7 @@ chroot_handler() {
${SOCKS_PROXY:+SOCKS_PROXY="${SOCKS_PROXY}"} \ ${SOCKS_PROXY:+SOCKS_PROXY="${SOCKS_PROXY}"} \
${NO_PROXY:+NO_PROXY="${NO_PROXY}"} \ ${NO_PROXY:+NO_PROXY="${NO_PROXY}"} \
${HTTP_PROXY_AUTH:+HTTP_PROXY_AUTH="${HTTP_PROXY_AUTH}"} \ ${HTTP_PROXY_AUTH:+HTTP_PROXY_AUTH="${HTTP_PROXY_AUTH}"} \
${FTP_RETRIES:+FTP_RETRIES="${FTP_RETRIES}"} \
SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \ SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \ XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \
$XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \ $XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \