Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/linux/apt-retry.sh
3520 views
1
#!/bin/sh
2
################################################################################
3
## Copied from https://github.com/actions/runner-images/blob/ubuntu22/20240825.1/images/ubuntu/scripts/build/configure-apt-mock.sh
4
################################################################################
5
6
i=1
7
while [ $i -le 30 ];do
8
err=$(mktemp)
9
"$@" 2>$err
10
11
# no errors, break the loop and continue normal flow
12
test -f $err || break
13
cat $err >&2
14
15
retry=false
16
17
if grep -q 'Could not get lock' $err;then
18
# apt db locked needs retry
19
retry=true
20
elif grep -q 'Could not open file /var/lib/apt/lists' $err;then
21
# apt update is not completed, needs retry
22
retry=true
23
elif grep -q 'IPC connect call failed' $err;then
24
# the delay should help with gpg-agent not ready
25
retry=true
26
elif grep -q 'Temporary failure in name resolution' $err;then
27
# It looks like DNS is not updated with random generated hostname yet
28
retry=true
29
elif grep -q 'dpkg frontend is locked by another process' $err;then
30
# dpkg process is busy by another process
31
retry=true
32
fi
33
34
rm $err
35
if [ $retry = false ]; then
36
break
37
fi
38
39
sleep 5
40
echo "...retry $i"
41
i=$((i + 1))
42
done
43
44