aboutsummaryrefslogtreecommitdiff
path: root/node/slave-helpers
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2012-04-23 20:58:56 +0300
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2012-04-23 20:58:56 +0300
commit3e44bda3a1c8d53ef188b0088c95b28b0e1356de (patch)
tree25229d7a9f26f4ac1ae5bae9ae6d7b2e2227e3d1 /node/slave-helpers
parentdcf6a3d7a4f2abe235856e6bc3f9b9b8a08480b0 (diff)
Add reusable module of EC2 apt-get helpers.
Diffstat (limited to 'node/slave-helpers')
-rwxr-xr-xnode/slave-helpers37
1 files changed, 37 insertions, 0 deletions
diff --git a/node/slave-helpers b/node/slave-helpers
new file mode 100755
index 0000000..c27e8a3
--- /dev/null
+++ b/node/slave-helpers
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+###############################################################################
+# Copyright (c) 2011 Linaro
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+
+
+setup_ubuntu_s3_mirror () {
+ sed -i.bk 's,^\(.*://[^.]*.ec2.archive.ubuntu.com\)/,\1.s3.amazonaws.com/,' /etc/apt/sources.list
+ echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99no-pipelining
+}
+
+# Stubborn apt-get, retrying on errors
+apt-get-retry () {
+ local fatal="yes";
+ if [ "$1" == "--non-fatal" ]; then
+ fatal=""
+ shift
+ fi
+ local delay=1;
+ while [ $delay -lt 100 ]; do
+ if apt-get "$@"; then
+ return
+ fi
+ echo "apt-get failed, sleeping ${delay}s before retrying"
+ sleep $delay
+ delay=$((delay * 2))
+ done
+ if [ -n "$fatal" ]; then
+ echo "apt-get failed after several attempts, aborting"
+ exit 1
+ fi
+}