summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Short <zulcss@ubuntu.com>2009-04-06 23:04:47 +0100
committerBazaar Package Importer <jamesw@ubuntu.com>2009-04-06 23:04:47 +0100
commit2747d3630baa60e125dfa4ccca97aa178e3cce47 (patch)
tree4fe1d272d1e0329b44b4c62bc95954cb68c01d7f
parentb40123f1114a55c42bbd0abac08f12d75a550367 (diff)
downloadcloud-init-git-ubuntu-0.3.3ubuntu9.tar.gz
* ec2-set-apt-sources.py:ubuntu-0.3.3ubuntu9
- Use a template to generate the sources.list and generate it based on the lsb_release.
-rw-r--r--.ec2-fetch-credentials.py.swpbin12288 -> 0 bytes
-rw-r--r--debian/changelog7
-rwxr-xr-xdebian/rules3
-rwxr-xr-xec2-set-apt-sources.py43
-rw-r--r--templates/sources.list.tmpl4
5 files changed, 35 insertions, 22 deletions
diff --git a/.ec2-fetch-credentials.py.swp b/.ec2-fetch-credentials.py.swp
deleted file mode 100644
index 52a749de..00000000
--- a/.ec2-fetch-credentials.py.swp
+++ /dev/null
Binary files differ
diff --git a/debian/changelog b/debian/changelog
index 39d5f332..a752af7b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ec2-init (0.3.3ubuntu9) jaunty; urgency=low
+
+ * ec2-set-apt-sources.py:
+ - Use a template to generate the sources.list and generate it based on the lsb_release.
+
+ -- Chuck Short <zulcss@ubuntu.com> Tue, 31 Mar 2009 15:15:55 -0400
+
ec2-init (0.3.3ubuntu8) jaunty; urgency=low
* ec2-set-apt-sources.py:
diff --git a/debian/rules b/debian/rules
index 64c70033..641694d9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,11 +7,12 @@ DEB_UPDATE_RCD_PARAMS:= start 90 2 3 4 5 . stop 20 1 .
build/ec2-init::
install -d debian/tmp/usr/sbin
mkdir -p debian/tmp/var/ec2
- mkdir -p debian/tmp/etc/ec2-init
+ mkdir -p debian/tmp/etc/ec2-init/templates
install -m 775 ec2-fetch-credentials.py debian/tmp/usr/sbin/ec2-fetch-credentials
install -m 775 ec2-run-user-data.py debian/tmp/usr/sbin/ec2-run-user-data
install -m 755 ec2-set-hostname.py debian/tmp/usr/sbin/ec2-set-hostname
install -m 755 ec2-set-apt-sources.py debian/tmp/usr/sbin/ec2-set-apt-sources
install -m755 ec2-get-info.py debian/tmp/usr/sbin/ec2-get-info
install -m755 ec2-set-defaults.py debian/tmp/usr/sbin/ec2-set-defaults
+ install -m755 templates/* debian/tmp/etc/ec2-init/templates
dh_installinit -p ec2-init --name rightscale-init -- defaults 99 09
diff --git a/ec2-set-apt-sources.py b/ec2-set-apt-sources.py
index f6549dc5..0cf4f09d 100755
--- a/ec2-set-apt-sources.py
+++ b/ec2-set-apt-sources.py
@@ -18,35 +18,36 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-
-import urllib
import os
-from configobj import ConfigObj
+import sys
+import urllib
+from Cheetah.Template import Template
-api_ver = '2008-02-01'
-metadata = None
-filename='/etc/ec2-init/ec2-config.cfg'
+def detectZone():
+ api_ver = '2008-02-01'
+ metadat = None
-base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
-zone = urllib.urlopen('%s/placement/availability-zone' % base_url).read()
+ base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
+ zone = urllib.urlopen('%s/placement/availability-zone' % base_url).read()
+ if zone.startswith("us"):
+ archive = "http://us.ec2.archive.ubuntu.com/ubuntu/"
+ elif zone.startswith("eu"):
+ archive = "http://eu.ec2.archive.ubuntu.com/ubuntu/"
-if zone.startswith("us"):
- archive = "http://us.ec2.archive.ubuntu.com/ubuntu"
-elif zone.startswith("eu"):
- archive = "http://eu.ec2.archive.ubuntu.com/ubuntu"
+ return(archive)
-config = ConfigObj(filename)
-distro = config['distro']
+t = os.popen("lsb_release -c").read()
+codename = t.split()
+mirror = detectZone()
+distro = codename[1]
+
+mp = {'mirror' : mirror, 'codename' : distro}
+t = Template(file="/etc/ec2-init/templates/sources.list.tmpl", searchList=[mp])
f = open("/var/run/ec2/sources.list", "w")
-f.write('deb %s %s main universe\n' % (archive,distro))
-f.write('deb-src %s %s main universe\n' % (archive,distro))
-f.write('deb %s %s-updates main universe\n' % (archive,distro))
-f.write('deb http://security.ubuntu.com/ubuntu %s-security main universe\n' %(distro))
-f.write('deb-src http://security.ubuntu.com/ubuntu %s-security main universe\n', %(distro))
-f.write('deb http://ppa.launchpad.net/ubuntu-on-ec2/ppa/ubuntu %s main\n' %(distro))
-f.write('deb-src http://ppa.launchpad.net/ubuntu-on-ec2/ppa/ubuntu %s main\n' %(distro))
+f.write('%s' %(t))
f.close()
+
os.system("mv /etc/apt/sources.list /etc/apt/sources.list-ec2-init")
os.system("ln -s /var/run/ec2/sources.list /etc/apt/sources.list")
os.system("apt-get update 2>&1 > /dev/null")
diff --git a/templates/sources.list.tmpl b/templates/sources.list.tmpl
new file mode 100644
index 00000000..bd999dda
--- /dev/null
+++ b/templates/sources.list.tmpl
@@ -0,0 +1,4 @@
+deb $mirror $codename main universe
+deb $mirror $codename-updates main universe
+deb http://security.ubuntu.com/ubuntu $codename-security main restricted
+deb-src http://security.ubuntu.com/ubuntu $codename-security main restricted