← Back to team overview

yellow team mailing list archive

[Merge] lp:~bac/charms/oneiric/buildbot-master/fix-apt-sources into lp:~yellow/charms/oneiric/buildbot-master/trunk

 

Brad Crittenden has proposed merging lp:~bac/charms/oneiric/buildbot-master/fix-apt-sources into lp:~yellow/charms/oneiric/buildbot-master/trunk.

Requested reviews:
  Launchpad Yellow Squad (yellow)

For more details, see:
https://code.launchpad.net/~bac/charms/oneiric/buildbot-master/fix-apt-sources/+merge/100853

Change /etc/apt/sources.list to overcome problems with EC2 repository hash that leaves the EC2 repositories unusable.


-- 
https://code.launchpad.net/~bac/charms/oneiric/buildbot-master/fix-apt-sources/+merge/100853
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~bac/charms/oneiric/buildbot-master/fix-apt-sources into lp:~yellow/charms/oneiric/buildbot-master/trunk.
=== modified file 'hooks/install'
--- hooks/install	2012-03-20 15:29:18 +0000
+++ hooks/install	2012-04-04 18:48:28 +0000
@@ -3,9 +3,11 @@
 # 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 shutil
 import subprocess
+import textwrap
 
 
 def run(*args, **kwargs):
@@ -72,6 +74,29 @@
         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():
     apt_get_install = command('apt-get', 'install', '-y', '--force-yes')
     apt_get_install('bzr', 'python-boto')
@@ -79,8 +104,10 @@
     apt_get_install('python-shelltoolbox')
 
 
+fix_apt_sources()
 install_packages()
 
+
 # These modules depend on shelltoolbox being installed so they must not be
 # imported until that package is available.
 from helpers import (


Follow ups