Wait for backgroup apt upgrade 95/12795/1
authorrobert.tomczyk <robert.tomczyk@est.tech>
Mon, 14 Mar 2022 14:27:17 +0000 (14:27 +0000)
committerrobert.tomczyk <robert.tomczyk@est.tech>
Mon, 14 Mar 2022 14:27:17 +0000 (14:27 +0000)
Make sure the backgrund apt upgrade finish before
we proceed with the job

Change-Id: Ifb12a085b39096827715754cd38d00c3e00654df

jjb/infra/update-jenkins-slave.sh

index 9473aae00d7e794bcda484c6946217c41a9287ac..6d8bdd01ec3917a7ff6d7ecaf14ffaa85577c446 100644 (file)
@@ -3,6 +3,19 @@ set -o errexit
 set -o nounset
 set -o pipefail
 
+# Wait for other apt process to finish by checking the dpkg lock file.
+try=0
+while sudo lsof ${DPKG_LOCK}  > /dev/null 2>&1 ; do
+  echo "DPKG file locked: ${DPKG_LOCK}."
+  echo "   Waiting for another pkg instalaltion process to finish ..."
+  sleep 10
+  if [[ ${try} -gt 60 ]] ; then
+    echo "ERROR: Max number of re-tries reached, exiting..."
+    exit 1
+  fi
+  try=$((try + 1))
+done
+
 sudo apt install -y -q=3 python3-minimal python3-pip virtualenv
 
 # workaround for https://github.com/pypa/virtualenv/issues/1029
@@ -35,4 +48,4 @@ echo "Info: Updating the CI slave image"
 cd "infra/jenkins/slave-setup/${TARGET}/"
 packer validate *-ubuntu*.json
 packer build *-ubuntu*.json
-echo "----------------------------------------------------"
\ No newline at end of file
+echo "----------------------------------------------------"