Merge lp:~cristiklein/vmbuilder/lp468809 into lp:vmbuilder

Proposed by Cristian Klein
Status: Needs review
Proposed branch: lp:~cristiklein/vmbuilder/lp468809
Merge into: lp:vmbuilder
Diff against target: 43 lines (+15/-0)
2 files modified
VMBuilder/plugins/ubuntu/dapper.py (+8/-0)
VMBuilder/plugins/ubuntu/distro.py (+7/-0)
To merge this branch: bzr merge lp:~cristiklein/vmbuilder/lp468809
Reviewer Review Type Date Requested Status
Serge Hallyn Pending
Review via email: mp+186716@code.launchpad.net

Description of the change

A popular request is to allow ubuntu-vm-builder to add packages from a 3rd-party repository (not a PPA). For example, one might want to install Cassandra in an Ubuntu Saucy VM. Previously, this was only possible using the "--firstboot" option and a carefully-written script.

This branch enables support for adding 3rd party repositories from a file. More precisely, it adds the "--addsourcefile" option which tells ubuntu-vm-builder to copy a certain file to the VM's /etc/apt/sources.list.d/ folder.

For example, assuming one already has Cassandra's repository on the current system, a Cassandra-ready VM can be created as follows:

  sudo ./ubuntu-vm-builder kvm saucy --addsourcefile /etc/apt/sources.list.d/cassandra.list --addpkg cassandras

To post a comment you must log in.

Unmerged revisions

489. By Cristian Klein

Added option to include additional files in /etc/apt/sources.list.d/. (LP: #468809)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VMBuilder/plugins/ubuntu/dapper.py'
2--- VMBuilder/plugins/ubuntu/dapper.py 2013-03-06 08:56:30 +0000
3+++ VMBuilder/plugins/ubuntu/dapper.py 2013-09-20 07:32:01 +0000
4@@ -234,6 +234,14 @@
5 'components' : components,
6 'ppa' : ppa,
7 'suite' : suite })
8+
9+ # copy extra source files
10+ extrasourcefiles = self.context.get_setting('addsourcefile')
11+ for sourcefile in extrasourcefiles:
12+ destination_dirname = '/etc/apt/sources.list.d'
13+ destination_basename = os.path.basename(sourcefile)
14+ destination = os.path.join(destination_dirname, destination_basename)
15+ self.context.install_file(destination, source = sourcefile)
16
17 # If setting up the final mirror, allow apt-get update to fail
18 # (since we might be on a complete different network than the
19
20=== modified file 'VMBuilder/plugins/ubuntu/distro.py'
21--- VMBuilder/plugins/ubuntu/distro.py 2013-04-29 16:08:42 +0000
22+++ VMBuilder/plugins/ubuntu/distro.py 2013-09-20 07:32:01 +0000
23@@ -63,6 +63,7 @@
24 group.add_setting('install-security-mirror', metavar='URL', help='Use the security mirror at URL for installation only. Apt\'s sources.list will still use default or URL set by --security-mirror')
25 group.add_setting('components', type='list', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,universe).')
26 group.add_setting('ppa', metavar='PPA', type='list', help='Add ppa belonging to PPA to the vm\'s sources.list.')
27+ group.add_setting('addsourcefile', metavar='SOURCEFILE', type='list', help='Add additional sources in /etc/apt/source.list.d/.')
28 group.add_setting('lang', metavar='LANG', default=get_locale(), help='Set the locale to LANG [default: %default]')
29 group.add_setting('timezone', metavar='TZ', default='UTC', help='Set the timezone to TZ in the vm. [default: %default]')
30
31@@ -125,6 +126,12 @@
32 if seedfile and not os.path.exists(seedfile):
33 raise VMBuilderUserError("Seedfile '%s' does not exist" % seedfile)
34
35+ # check if the supplied sources.list.d files exist
36+ extrasourcefiles = self.context.get_setting('addsourcefile')
37+ for sourcefile in extrasourcefiles:
38+ if not os.path.exists(sourcefile):
39+ raise VMBuilderUserError("Source file '%s' does not exist" % sourcefile)
40+
41 lang = self.get_setting('lang')
42
43 # FIXME

Subscribers

People subscribed via source and target branches