diff options
author | Scott Moser <smoser@ubuntu.com> | 2013-10-24 13:32:05 -0700 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2013-10-24 13:32:05 -0700 |
commit | f7d51c7ee1a7520a27a22cab6b0f350d5b5aaf8b (patch) | |
tree | d87bb250f7e52d5fa8cd8893ef0d308cc20cec2c | |
parent | b27fab81c99fcb05f4c633bad62d4151edc702e6 (diff) | |
parent | 0473a7f4acacdfe2d9e3840a6f89399f60f7a9d2 (diff) | |
download | vyos-cloud-init-f7d51c7ee1a7520a27a22cab6b0f350d5b5aaf8b.tar.gz vyos-cloud-init-f7d51c7ee1a7520a27a22cab6b0f350d5b5aaf8b.zip |
support calling add-apt-repository on cloud-archive: entries
LP: #1244355
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | cloudinit/config/cc_apt_configure.py | 30 | ||||
-rw-r--r-- | doc/examples/cloud-config.txt | 4 |
3 files changed, 28 insertions, 7 deletions
@@ -5,6 +5,7 @@ - fix DataSourceAzure incompatibility with 2.6 (LP: #1232175) - fix power_state_change config module so that example works. Improve its documentation and add reference to 'timeout' + - support apt-add-archive with 'cloud-archive:' format. (LP: #1244355) 0.7.3: - fix omnibus chef installer (LP: #1182265) [Chris Wing] - small fix for OVF datasource for iso transport on non-iso9660 filesystem diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py index 5a407016..b094ea22 100644 --- a/cloudinit/config/cc_apt_configure.py +++ b/cloudinit/config/cc_apt_configure.py @@ -20,6 +20,7 @@ import glob import os +import re from cloudinit import templater from cloudinit import util @@ -30,6 +31,9 @@ PROXY_TPL = "Acquire::HTTP::Proxy \"%s\";\n" APT_CONFIG_FN = "/etc/apt/apt.conf.d/94cloud-init-config" APT_PROXY_FN = "/etc/apt/apt.conf.d/95cloud-init-proxy" +# this will match 'XXX:YYY' (ie, 'cloud-archive:foo' or 'ppa:bar') +ADD_APT_REPO_MATCH = r"^[\w-]+:\w" + # A temporary shell program to get a given gpg key # from a given keyserver EXPORT_GPG_KEYID = """ @@ -78,7 +82,15 @@ def handle(name, cfg, cloud, log, _args): params = mirrors params['RELEASE'] = release params['MIRROR'] = mirror - errors = add_sources(cfg['apt_sources'], params) + + matchcfg = cfg.get('add_apt_repo_match', ADD_APT_REPO_MATCH) + if matchcfg: + matcher = re.compile(matchcfg).search + else: + matcher = lambda f: False + + errors = add_sources(cfg['apt_sources'], params, + aa_repo_match=matcher) for e in errors: log.warn("Add source error: %s", ':'.join(e)) @@ -147,7 +159,7 @@ def generate_sources_list(codename, mirrors, cloud, log): templater.render_to_file(template_fn, '/etc/apt/sources.list', params) -def add_sources(srclist, template_params=None): +def add_sources(srclist, template_params=None, aa_repo_match=None): """ add entries in /etc/apt/sources.list.d for each abbreviated sources.list entry in 'srclist'. When rendering template, also @@ -156,6 +168,9 @@ def add_sources(srclist, template_params=None): if template_params is None: template_params = {} + if aa_repo_match is None: + aa_repo_match = lambda f: False + errorlist = [] for ent in srclist: if 'source' not in ent: @@ -163,15 +178,16 @@ def add_sources(srclist, template_params=None): continue source = ent['source'] - if source.startswith("ppa:"): + source = templater.render_string(source, template_params) + + if aa_repo_match(source): try: util.subp(["add-apt-repository", source]) - except: - errorlist.append([source, "add-apt-repository failed"]) + except util.ProcessExecutionError as e: + errorlist.append([source, + ("add-apt-repository failed. " + str(e))]) continue - source = templater.render_string(source, template_params) - if 'filename' not in ent: ent['filename'] = 'cloud_config_sources.list' diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index bcfd7917..546a1b98 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -72,6 +72,10 @@ apt_pipelining: False # then apt_mirror above will have no effect apt_preserve_sources_list: true +# 'source' entries in apt-sources that match this python regex +# expression will be passed to add-apt-repository +add_apt_repo_match = "^[\w-]+:\w" + apt_sources: - source: "deb http://ppa.launchpad.net/byobu/ppa/ubuntu karmic main" keyid: F430BBA5 # GPG key ID published on a key server |