[apt-retry] - Added logic to retry apt update

When there is failure to fetch any of the apt urls, it skips and
continues. Due to which apt install fails in next step.
So added retry if apt fetch fails before proceeding to apt install.

Change-Id: I658024481b1be98d280cb1c9c4c2fb733a0d5697
This commit is contained in:
Yasin, Siraj (SY495P) 2019-12-06 16:26:45 +00:00 committed by Sreejith Punnapuzha
parent fe29812aca
commit ff0a7ccabb
1 changed files with 5 additions and 4 deletions

View File

@ -82,15 +82,16 @@ set -x
end=$(($(date +%s) + APT_INSTALL_TIMEOUT))
while true; do
if ! apt-get update; then
if ! apt-get update 2>&1 | grep -q '^W: Failed to fetch'; then
break
else
now=$(date +%s)
if [[ ${now} -gt ${end} ]]; then
log Failed to update apt-cache.
log "Failed to update apt-cache."
exit 1
fi
log "re-try apt-get update..."
sleep 10
else
break
fi
done