File: apt-install

package info (click to toggle)
criu 4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 11,500 kB
  • sloc: ansic: 139,280; python: 7,484; sh: 3,824; java: 2,799; makefile: 2,659; asm: 1,137; perl: 206; xml: 117; exp: 45
file content (23 lines) | stat: -rwxr-xr-x 615 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/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
	(( install_retry_counter+=1 ))
	if [ "${install_retry_counter}" -gt "${max_apt_retries}" ]; then
		exit 1
	fi
	apt-get update -y && apt-get install -y --no-install-recommends "$@" && break

	# In case it is a network error let's wait a bit.
	echo "Retrying attempt ${install_retry_counter}"
	sleep "${install_retry_counter}"
done