Change-Id: If93b30f7dc0a0e8f8a1a8b69b5c06282e09e4cd1
set -o errexit
set -o pipefail
set -o xtrace
+DPKG_LOCK="/var/lib/dpkg/lock-frontend"
+
+# 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 30 ]] ; then
+ echo "ERROR: Max number of re-tries reached, exiting..."
+ exit 1
+ fi
+ let "try++"
+done
sudo apt-get update
sudo apt-get install -y --no-install-recommends \