ci-dockerfiles-deployment: Stop unattended-upgrades on EC2 instances

More or less regularly causes other apt operations to fail.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: I5887d1d4135831e09e09114a48f364a5bc68b5f2
diff --git a/ci-dockerfiles-deployment/builders.sh b/ci-dockerfiles-deployment/builders.sh
index 5f4aabf..c21bc22 100644
--- a/ci-dockerfiles-deployment/builders.sh
+++ b/ci-dockerfiles-deployment/builders.sh
@@ -7,7 +7,18 @@
 echo "    Gerrit Environment"
 env |grep '^GERRIT'
 echo "########################################################################"
-env |grep '^AWS'
+
+ON_EC2="0"
+if [ -f /sys/hypervisor/uuid ] && grep -q ^ec2 /sys/hypervisor/uuid; then
+    ON_EC2="1"
+fi
+
+if [ "${ON_EC2}" == "1" ]; then
+    # On EC2 instances, stop and remove unattended-upgrades service which
+    # may interfere with any apt operations below.
+    sudo systemctl stop unattended-upgrades
+    sudo apt-get remove -y -qq unattended-upgrades
+fi
 
 # For dpkg-architecture call below
 sudo apt-get -y -qq install --no-install-recommends dpkg-dev