Path: blob/main/build/azure-pipelines/linux/apt-retry.sh
3520 views
#!/bin/sh1################################################################################2## Copied from https://github.com/actions/runner-images/blob/ubuntu22/20240825.1/images/ubuntu/scripts/build/configure-apt-mock.sh3################################################################################45i=16while [ $i -le 30 ];do7err=$(mktemp)8"$@" 2>$err910# no errors, break the loop and continue normal flow11test -f $err || break12cat $err >&21314retry=false1516if grep -q 'Could not get lock' $err;then17# apt db locked needs retry18retry=true19elif grep -q 'Could not open file /var/lib/apt/lists' $err;then20# apt update is not completed, needs retry21retry=true22elif grep -q 'IPC connect call failed' $err;then23# the delay should help with gpg-agent not ready24retry=true25elif grep -q 'Temporary failure in name resolution' $err;then26# It looks like DNS is not updated with random generated hostname yet27retry=true28elif grep -q 'dpkg frontend is locked by another process' $err;then29# dpkg process is busy by another process30retry=true31fi3233rm $err34if [ $retry = false ]; then35break36fi3738sleep 539echo "...retry $i"40i=$((i + 1))41done424344