diff options
author | Adin Scannell <ascannell@google.com> | 2020-02-27 15:35:19 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-27 15:36:13 -0800 |
commit | c96bb4d2ebc6a24b3111d986c5d40574ec8ff660 (patch) | |
tree | 3d541d78a05d6427f0846560d02e709498b15bd3 /scripts/common.sh | |
parent | 88f73699225bd50102bbacb6f78052338f205cdd (diff) |
Fix apt-get reliability issues.
This is frequently causing the core build scripts to fail. The core ubuntu
distribution will perform an auto-update at first start, which may cause the
lock file to be held. All apt-get commands may be done in a loop in order to
retry to avoid this issue. We may want to consider retrying other pieces, but
for now this should avoid the most frequent cause of build flakes.
PiperOrigin-RevId: 297704789
Diffstat (limited to 'scripts/common.sh')
-rwxr-xr-x | scripts/common.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/common.sh b/scripts/common.sh index 3ca699e4a..735a383de 100755 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -84,3 +84,17 @@ function install_runsc() { # Restart docker to pick up the new runtime configuration. sudo systemctl restart docker } + +# Installs the given packages. Note that the package names should be verified to +# be correct, otherwise this may result in a loop that spins until time out. +function apt_install() { + while true; do + if (sudo apt-get update && sudo apt-get install -y "$@"); then + break + fi + result=$? + if [[ $result -ne 100 ]]; then + return $result + fi + done +} |