yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00667
[Merge] lp:~bac/charms/oneiric/buildbot-slave/fix-apt-sources into lp:~yellow/charms/oneiric/buildbot-slave/trunk
Brad Crittenden has proposed merging lp:~bac/charms/oneiric/buildbot-slave/fix-apt-sources into lp:~yellow/charms/oneiric/buildbot-slave/trunk.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~bac/charms/oneiric/buildbot-slave/fix-apt-sources/+merge/101007
Duplicated changes from the buildbot-master to redo /etc/apt/sources.list if there are problems.
--
https://code.launchpad.net/~bac/charms/oneiric/buildbot-slave/fix-apt-sources/+merge/101007
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~bac/charms/oneiric/buildbot-slave/fix-apt-sources into lp:~yellow/charms/oneiric/buildbot-slave/trunk.
=== modified file 'hooks/install'
--- hooks/install 2012-03-20 15:29:09 +0000
+++ hooks/install 2012-04-05 17:17:26 +0000
@@ -3,11 +3,13 @@
# Copyright 2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
+from datetime import datetime
import os
import shlex
import subprocess
import sys
import tempfile
+import textwrap
def run(*args, **kwargs):
@@ -75,7 +77,42 @@
raise
+def fix_apt_sources():
+ # Problems have frequently been seen with the repositories used by ec2 not
+ # having the correct hash and being unuseable. To avoid that problem, we
+ # replace /etc/apt/sources.list with known good repositories. The cost of
+ # this is having to go outside of the ec2 environment to download
+ # packages.
+ good_sources = textwrap.dedent("""\
+ # Installed by the buildbot-master charm installation hook at
+ # {}
+ deb http://security.ubuntu.com/ubuntu/ precise-security universe main
+ deb-src http://security.ubuntu.com/ubuntu/ precise-security universe main
+ deb http://archive.ubuntu.com/ubuntu precise-updates universe main
+ deb-src http://archive.ubuntu.com/ubuntu precise-updates universe main
+ deb http://archive.ubuntu.com/ubuntu precise main universe
+ deb-src http://archive.ubuntu.com/ubuntu precise main universe
+ """.format(datetime.now()))
+ # Move the old sources.list out of the way.
+ sources_list = '/etc/apt/sources.list'
+ os.rename(sources_list, sources_list + '.old')
+ with open(sources_list, 'w') as fd:
+ fd.write(good_sources)
+
+
def install_packages():
+ try:
+ # Attempt exercising 'apt-get' to see if there are errors in the
+ # repositories, as frequently seen on EC2. If so, fix the apt sources
+ # file. This approach will work if the failure is seen initially but
+ # will not succeed if it is intermittent.
+ run('apt-get', 'update')
+ except subprocess.CalledProcessError as e:
+ log("Error running 'apt-get update':")
+ log(str(e))
+ log("Proceeding with re-written /etc/apt/sources.list")
+ fix_apt_sources()
+ run('apt-get', 'update')
install_extra_repository('ppa:yellow/ppa')
apt_get_install('python-shelltoolbox')
Follow ups