Merge lp:~cristiklein/ubuntu/precise/vm-builder/lp468809 into lp:ubuntu/precise/vm-builder

Proposed by Cristian Klein
Status: Needs review
Proposed branch: lp:~cristiklein/ubuntu/precise/vm-builder/lp468809
Merge into: lp:ubuntu/precise/vm-builder
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/ubuntu/precise/vm-builder/lp468809
Reviewer Review Type Date Requested Status
Cristian Klein (community) Disapprove
Martin Pitt Needs Fixing
James Hunt (community) Approve
Review via email: mp+161427@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 Precise 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 precise --addsourcefile /etc/apt/sources.list.d/cassandra.list --addpkg cassandra

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

Thanks for your contribution. This looks like a useful feature.

Please could you update the group.add_setting() call as it should show '/etc/apt/sources.list.d/' rather than '/etc/source.list.d/'.

52. By Cristian Klein

Fix: help message for command-line option

Revision history for this message
Cristian Klein (cristiklein) wrote :

On 2013-05-13 12:02, James Hunt wrote:
> Thanks for your contribution. This looks like a useful feature.
>
> Please could you update the group.add_setting() call as it should
> show '/etc/apt/sources.list.d/' rather than '/etc/source.list.d/'.

Fixed. Thanks for the review!

Revision history for this message
James Hunt (jamesodhunt) wrote :

Thanks - LGTM.

review: Approve
Revision history for this message
Martin Pitt (pitti) wrote :

This looks like a new feature to me, not an SRU bug fix. If you want this to be an SRU, please adjust the LP bug accoridngly and get an SRU exception from teh SRU team. If this was mis-targetted and is really aimed at saucy, please re-target the MP to the saucy branch.

Please also add a changelog, to describe the changes and refer to the bug. Thanks!

review: Needs Fixing
Revision history for this message
Cristian Klein (cristiklein) wrote :

I will add the changelog and re-target the MP to the saucy branch. Thanks!

review: Disapprove

Unmerged revisions

52. By Cristian Klein

Fix: help message for command-line option

51. 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 2010-12-02 11:19:30 +0000
3+++ VMBuilder/plugins/ubuntu/dapper.py 2013-05-13 10:41:24 +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 2011-10-19 21:13:13 +0000
22+++ VMBuilder/plugins/ubuntu/distro.py 2013-05-13 10:41:24 +0000
23@@ -62,6 +62,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@@ -124,6 +125,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