Skip to content

Commit

Permalink
Fix add-apt-repositories.sh & add-apt-keys
Browse files Browse the repository at this point in the history
The loop syntax was wrong, so fix or remove it
(curl already has the retry option)

Also add retry and failed messages
  • Loading branch information
Flamefire committed Jul 4, 2024
1 parent 55cf2c2 commit 714e120
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 4 additions & 5 deletions ci/add-apt-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ function do_add_key
keyfilename=$(basename -s .key "$key_url")
fi
echo -e "\tDownloading APT key from '$key_url' to '$keyfilename'"
for i in {1..${NET_RETRY_COUNT:-3}}; do
curl -sSL --retry ${NET_RETRY_COUNT:-5} "$key_url" | sudo gpg --dearmor -o "/etc/apt/trusted.gpg.d/${keyfilename}" && return 0 || sleep 10
done

return 1 # Failed
if ! curl -sSL --retry ${NET_RETRY_COUNT:-5} "$key_url" | sudo gpg --dearmor -o "/etc/apt/trusted.gpg.d/${keyfilename}"; then
echo "Failed downloading $keyfilename"
return 1
fi
}

for key_url in "$@"; do
Expand Down
11 changes: 9 additions & 2 deletions ci/add-apt-repositories.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ set -eu
function do_add_repository {
name=$1
echo -e "\tAdding repository $name"
for i in {1..${NET_RETRY_COUNT:-3}}; do
sudo -E apt-add-repository -y "$name" && return 0 || sleep 10;
for i in $(seq ${NET_RETRY_COUNT:-3}); do
if [[ $i -ne 1 ]]; then
sleep 10
echo -e "\tRetrying"
fi
if sudo -E apt-add-repository -y "$name"; then
return 0
fi
done
echo "Failed adding $name"
return 1 # Failed
}

Expand Down

0 comments on commit 714e120

Please sign in to comment.