From: Anil Belur Date: Tue, 7 Nov 2017 22:14:26 +0000 (+1000) Subject: Ensure apt is not locked on Ubuntu nodes X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=e05ebe5db2bfef9201d3c46a76af2b60d03c912d;p=releng%2Fbuilder.git Ensure apt is not locked on Ubuntu nodes A background apt process locks /var/lib/dpkg/lock and causes apt commands to fail. Therefore check if apt is locked before running apt. Errors: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg), is another process using Change-Id: I3ced3711b26ebe9ecf5654c70d23f44e905c1f4c Signed-off-by: Anil Belur --- diff --git a/packer/provision/baseline.sh b/packer/provision/baseline.sh index 78e3b64a87..978296bb57 100644 --- a/packer/provision/baseline.sh +++ b/packer/provision/baseline.sh @@ -79,6 +79,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"