X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=packer%2Fprovision%2Fbaseline.sh;h=aae30d44b1e3be34881adf56e5646a8ef1fedde7;hb=f424082e6078b61dd3f4494b39ee3488c1e61eb0;hp=c1ce0bbaeab85be7b614808827a8626c5e1a1806;hpb=08c714f7f59dac1a853b761f3c1ca115d9cf5344;p=releng%2Fbuilder.git diff --git a/packer/provision/baseline.sh b/packer/provision/baseline.sh index c1ce0bbae..aae30d44b 100644 --- a/packer/provision/baseline.sh +++ b/packer/provision/baseline.sh @@ -7,6 +7,8 @@ set -xeu -o pipefail enable_service() { # Enable services for Ubuntu instances + # We purposely want to allow globbing to build the package array + # shellcheck disable=SC2206 services=($@) for service in "${services[@]}"; do @@ -72,6 +74,8 @@ ensure_ubuntu_install() { # On Ubuntu sometimes the mirrors fail to install a package. This wrapper # checks that a package is successfully installed before moving on. + # We purposely want to allow globbing to build the package array + # shellcheck disable=SC2206 packages=($@) for pkg in "${packages[@]}" @@ -79,6 +83,10 @@ ensure_ubuntu_install() { # Retry installing package 5 times if necessary for i in {0..5} do + + # Wait for any background apt processes to finish before running apt + while pgrep apt > /dev/null; do sleep 1; done + echo "$i: Installing $pkg" if [ "$(dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then apt-cache policy "$pkg" @@ -277,9 +285,6 @@ Dpkg::Options { EOF - # Add hostname to /etc/hosts to fix 'unable to resolve host' issue with sudo - sed -i "/127.0.0.1/s/$/ $(hostname)/" /etc/hosts - echo "---> Updating operating system" # add additional repositories