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: I10b7187428f5cd3b48659f75683be9d4f9b706bb
diff --git a/ci-dockerfiles-deployment/builders.sh b/ci-dockerfiles-deployment/builders.sh
index e942123..3e67839 100644
--- a/ci-dockerfiles-deployment/builders.sh
+++ b/ci-dockerfiles-deployment/builders.sh
@@ -8,6 +8,18 @@
 env |grep '^GERRIT'
 echo "########################################################################"
 
+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
 if ! type dpkg-architecture
 then