install_packages 535 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. # Copyright Broadcom, Inc. All Rights Reserved.
  3. # SPDX-License-Identifier: APACHE-2.0
  4. set -eu
  5. n=0
  6. max=2
  7. export DEBIAN_FRONTEND=noninteractive
  8. until [ $n -gt $max ]; do
  9. set +e
  10. (
  11. apt-get update -qq &&
  12. apt-get install -y --no-install-recommends "$@"
  13. )
  14. CODE=$?
  15. set -e
  16. if [ $CODE -eq 0 ]; then
  17. break
  18. fi
  19. if [ $n -eq $max ]; then
  20. exit $CODE
  21. fi
  22. echo "apt failed, retrying"
  23. n=$(($n + 1))
  24. done
  25. apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives