2020-08-14 08:37:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e -x
|
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
install_retry_counter=0
|
|
|
|
max_apt_retries=5
|
|
|
|
|
|
|
|
# This function loops a couple of times over apt-get, hoping to
|
|
|
|
# avoid CI errors due to errors during apt-get
|
|
|
|
# hashsum mismatches, DNS errors and similar things
|
|
|
|
while true; do
|
2020-09-23 06:29:35 +00:00
|
|
|
(( install_retry_counter+=1 ))
|
2021-04-22 15:30:47 -07:00
|
|
|
if [ "${install_retry_counter}" -gt "${max_apt_retries}" ]; then
|
2020-08-14 08:37:25 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-08-07 15:45:37 -07:00
|
|
|
apt-get update -y && apt-get install -y --no-install-recommends "$@" && break
|
2020-08-14 08:37:25 +00:00
|
|
|
|
|
|
|
# In case it is a network error let's wait a bit.
|
|
|
|
echo "Retrying attempt ${install_retry_counter}"
|
2021-04-22 15:30:47 -07:00
|
|
|
sleep "${install_retry_counter}"
|
2020-08-14 08:37:25 +00:00
|
|
|
done
|