build-package.sh: retry if downloading of Release{,.gpg} failed when fast-build mode is on
Release or Release.gpg files may be absent if a new .deb file was uploaded to apt repository recently. We may need to do a multiple attempts in a loop to retry downloading of these files. Needed after 99e9ab67b634a89d0be9eca12c4f1cdc091ee6e8, where I have disabled looping in termux_download but curl doesn't do retries on 404 error. We want immediate failure only for 404's on source and build tool URLs.
This commit is contained in:
parent
17d8de18d7
commit
5ddf251200
@ -23,17 +23,18 @@ termux_download() {
|
||||
if [ "$CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
|
||||
>&2 printf "Wrong checksum for %s:\nExpected: %s\nActual: %s\n" \
|
||||
"$URL" "$CHECKSUM" "$ACTUAL_CHECKSUM"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
printf "WARNING: No checksum check for %s:\nActual: %s\n" \
|
||||
"$URL" "$ACTUAL_CHECKSUM"
|
||||
fi
|
||||
mv "$TMPFILE" "$DESTINATION"
|
||||
return
|
||||
return 0
|
||||
fi
|
||||
|
||||
termux_error_exit "Failed to download $URL"
|
||||
echo "Failed to download $URL" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
# Make script standalone executable as well as sourceable
|
||||
|
@ -8,7 +8,7 @@ termux_download_deb() {
|
||||
return "$?"
|
||||
fi
|
||||
|
||||
local DEB_FILE=${PACKAGE}_${VERSION}_${PACKAGE_ARCH}.deb
|
||||
local DEB_FILE="${PACKAGE}_${VERSION}_${PACKAGE_ARCH}.deb"
|
||||
PKG_HASH=""
|
||||
|
||||
for idx in $(seq ${#TERMUX_REPO_URL[@]}); do
|
||||
@ -27,12 +27,11 @@ termux_download_deb() {
|
||||
|
||||
if [ "$PKG_HASH" = "" ]; then
|
||||
return 1
|
||||
else
|
||||
termux_download ${TERMUX_REPO_URL[$idx-1]}/${PKG_PATH} \
|
||||
$TERMUX_COMMON_CACHEDIR-$PACKAGE_ARCH/${DEB_FILE} \
|
||||
$PKG_HASH
|
||||
return 0
|
||||
fi
|
||||
|
||||
termux_download "${TERMUX_REPO_URL[${idx}-1]}/${PKG_PATH}" \
|
||||
"${TERMUX_COMMON_CACHEDIR}-${PACKAGE_ARCH}/${DEB_FILE}" \
|
||||
"$PKG_HASH"
|
||||
}
|
||||
|
||||
# Make script standalone executable as well as sourceable
|
||||
|
@ -25,11 +25,23 @@ termux_get_repo_files() {
|
||||
local TERMUX_REPO_NAME=$(echo ${TERMUX_REPO_URL[$idx-1]} | sed -e 's%https://%%g' -e 's%http://%%g' -e 's%/%-%g')
|
||||
local RELEASE_FILE=${TERMUX_COMMON_CACHEDIR}/${TERMUX_REPO_NAME}-${TERMUX_REPO_DISTRIBUTION[$idx-1]}-Release
|
||||
|
||||
termux_download "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release" \
|
||||
"$RELEASE_FILE" SKIP_CHECKSUM
|
||||
local download_attempts=6
|
||||
while ((download_attempts > 0)); do
|
||||
if termux_download "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release" \
|
||||
"$RELEASE_FILE" SKIP_CHECKSUM && \
|
||||
termux_download "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release.gpg" \
|
||||
"${RELEASE_FILE}.gpg" SKIP_CHECKSUM; then
|
||||
break
|
||||
fi
|
||||
|
||||
termux_download "${TERMUX_REPO_URL[$idx-1]}/dists/${TERMUX_REPO_DISTRIBUTION[$idx-1]}/Release.gpg" \
|
||||
"${RELEASE_FILE}.gpg" SKIP_CHECKSUM
|
||||
download_attempts=$((download_attempts - 1))
|
||||
if ((download_attempts < 1)); then
|
||||
termux_error_exit "Failed to download package repository metadata. Try to build without -i/-I option."
|
||||
fi
|
||||
|
||||
echo "Retrying download in 30 seconds (${download_attempts} attempts left)..." >&2
|
||||
sleep 30
|
||||
done
|
||||
|
||||
gpg --verify "${RELEASE_FILE}.gpg" "$RELEASE_FILE"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user