#!/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 }