This adds a wrapper around apt-get to loop until the lock is available
for dpkg operations.
Change-Id: I85d3b1f1e6992a046d021a192997f307c7ca4785
Signed-off-by: Rudy Grigar <rgrigar@linuxfoundation.org>
EOF
+ # Wrap apt-get to wait for the lock to become available for operation
+ # http://askubuntu.com/questions/132059/how-to-make-a-package-manager-wait-if-another-instance-of-apt-is-running
+ cat <<EOF >> /usr/local/bin/apt-get
+#!/bin/bash
+
+i=0
+tput sc
+while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
+ case $(($i % 4)) in
+ 0 ) j="-" ;;
+ 1 ) j="\\" ;;
+ 2 ) j="|" ;;
+ 3 ) j="/" ;;
+ esac
+ tput rc
+ echo -en "\r[$j] Waiting for other software managers to finish..."
+ sleep 0.5
+ ((i=i+1))
+done
+
+/usr/bin/apt-get "$@"
+
+EOF
+ chmod +x /usr/local/bin/apt-get
+
echo "---> Updating operating system"
apt-get update
apt-get upgrade