Merge lp:~bart-jukie/vmbuilder/fixes into lp:vmbuilder/trunk

Proposed by bartman
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bart-jukie/vmbuilder/fixes
Merge into: lp:vmbuilder/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~bart-jukie/vmbuilder/fixes
Reviewer Review Type Date Requested Status
Ubuntu Virtualisation team Pending
Review via email: mp+4042@code.launchpad.net
To post a comment you must log in.
Revision history for this message
bartman (bart-jukie) wrote :

I have some misc patches for the python-vm-builder package. If you want me to fix anything up, let me know.

Summary:
 * added --post-install-script to run a script right after the image is built, but before it's transfered to the disk image.
 * added --variant to handle building a minbase debootstrap image.
 * make sure rootsize, optsize and swapsize are integers.
 * make it possible to install w/o console-steup.
 * fix some build issues.

lp:~bart-jukie/vmbuilder/fixes updated
294. By bartman

fix access to vmxtemplate variable

295. By bartman

remove cpu from templte parameters

- it's not used in the template, and
- it's not provided by VM object.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VMBuilder/plugins/cli/__init__.py'
2--- VMBuilder/plugins/cli/__init__.py 2008-11-27 17:20:39 +0000
3+++ VMBuilder/plugins/cli/__init__.py 2009-02-28 21:03:04 +0000
4@@ -80,6 +80,9 @@
5
6 def set_disk_layout(self, vm):
7 if not vm.part:
8+ vm.rootsize = int(vm.rootsize)
9+ vm.swapsize = int(vm.swapsize)
10+ vm.optsize = int(vm.optsize)
11 if vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
12 vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/')
13 vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None)
14
15=== modified file 'VMBuilder/plugins/ubuntu/dapper.py'
16--- VMBuilder/plugins/ubuntu/dapper.py 2008-12-16 15:29:50 +0000
17+++ VMBuilder/plugins/ubuntu/dapper.py 2009-02-28 22:47:37 +0000
18@@ -102,6 +102,9 @@
19 logging.debug("Unpreventing daemons from starting")
20 self.unprevent_daemons_starting()
21
22+ logging.debug("Execute post install script")
23+ self.post_install_script()
24+
25 def update(self):
26 self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade')
27
28@@ -203,7 +206,10 @@
29 self.install_from_template('/boot/grub/device.map', 'devicemap', { 'prefix' : self.disk_prefix })
30
31 def debootstrap(self):
32- cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch, self.vm.suite, self.destdir, self.debootstrap_mirror()]
33+ cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch]
34+ if self.vm.variant:
35+ cmd += ['--variant=%s' % self.vm.variant]
36+ cmd += [self.vm.suite, self.destdir, self.debootstrap_mirror()]
37 run_cmd(*cmd)
38
39 def debootstrap_mirror(self):
40@@ -288,3 +294,9 @@
41 self.run_in_target('locale-gen', self.vm.lang)
42 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })
43 self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')
44+
45+ def post_install_script(self):
46+ if self.vm.post_install_script:
47+ run_cmd(self.vm.post_install_script, self.destdir)
48+
49+
50
51=== modified file 'VMBuilder/plugins/ubuntu/distro.py'
52--- VMBuilder/plugins/ubuntu/distro.py 2008-12-16 13:39:21 +0000
53+++ VMBuilder/plugins/ubuntu/distro.py 2009-02-28 22:47:37 +0000
54@@ -53,6 +53,7 @@
55 group = self.vm.setting_group('Installation options')
56 group.add_option('--suite', default='jaunty', help='Suite to install. Valid options: %s [default: %%default]' % ' '.join(self.suites))
57 group.add_option('--flavour', '--kernel-flavour', help='Kernel flavour to use. Default and valid options depend on architecture and suite')
58+ group.add_option('--variant', metavar='VARIANT', help='Passed to debootstrap --variant flag; use minbase, buildd, or fakechroot.')
59 group.add_option('--iso', metavar='PATH', help='Use an iso image as the source for installation of file. Full path to the iso must be provided. If --mirror is also provided, it will be used in the final sources.list of the vm. This requires suite and kernel parameter to match what is available on the iso, obviously.')
60 group.add_option('--mirror', metavar='URL', help='Use Ubuntu mirror at URL instead of the default, which is http://archive.ubuntu.com/ubuntu for official arches and http://ports.ubuntu.com/ubuntu-ports otherwise')
61 group.add_option('--install-mirror', metavar='URL', help='Use Ubuntu mirror at URL for the installation only. Apt\'s sources.list will still use default or URL set by --mirror')
62@@ -61,6 +62,7 @@
63 group.add_option('--components', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,universe).')
64 group.add_option('--ppa', metavar='PPA', action='append', help='Add ppa belonging to PPA to the vm\'s sources.list.')
65 group.add_option('--lang', metavar='LANG', default=self.get_locale(), help='Set the locale to LANG [default: %default]')
66+ group.add_option('--post-install-script', metavar='PATH', help='Run script to update the installed image; scritp is passed the install dir')
67 self.vm.register_setting_group(group)
68
69 group = self.vm.setting_group('Settings for the initial user')
70
71=== modified file 'VMBuilder/plugins/ubuntu/edgy.py'
72--- VMBuilder/plugins/ubuntu/edgy.py 2008-12-04 16:28:48 +0000
73+++ VMBuilder/plugins/ubuntu/edgy.py 2009-02-28 22:47:22 +0000
74@@ -20,6 +20,7 @@
75 import logging
76 import suite
77 import shutil
78+import os
79 import VMBuilder.disk as disk
80 from VMBuilder.util import run_cmd
81 from VMBuilder.plugins.ubuntu.dapper import Dapper
82@@ -49,9 +50,12 @@
83
84 def copy_settings(self):
85 self.copy_to_target('/etc/default/locale', '/etc/default/locale')
86- shutil.rmtree('%s/etc/console-setup' % self.destdir)
87- self.copy_to_target('/etc/console-setup', '/etc/console-setup')
88- self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup')
89+ csdir = '%s/etc/console-setup' % self.destdir
90+ have_cs = os.path.isdir(csdir)
91+ if have_cs:
92+ shutil.rmtree(csdir)
93+ self.copy_to_target('/etc/console-setup', '/etc/console-setup')
94+ self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup')
95 self.copy_to_target('/etc/timezone', '/etc/timezone')
96 self.run_in_target('dpkg-reconfigure', '-pcritical', 'tzdata')
97 self.run_in_target('locale-gen', 'en_US')
98@@ -59,4 +63,5 @@
99 self.run_in_target('locale-gen', self.vm.lang)
100 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })
101 self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')
102- self.run_in_target('dpkg-reconfigure', '-pcritical', 'console-setup')
103+ if have_cs:
104+ self.run_in_target('dpkg-reconfigure', '-pcritical', 'console-setup')
105
106=== modified file 'VMBuilder/vm.py'
107--- VMBuilder/vm.py 2009-02-17 13:31:40 +0000
108+++ VMBuilder/vm.py 2009-02-28 21:36:54 +0000
109@@ -137,7 +137,7 @@
110 self.register_setting('--in-place', action='store_true', default=False, help='Install directly into the filesystem images. This is needed if your $TMPDIR is nodev and/or nosuid, but will result in slightly larger file system images.')
111 self.register_setting('--tmpfs', metavar="OPTS", help='Use a tmpfs as the working directory, specifying its size or "-" to use tmpfs default (suid,dev,size=1G).')
112 self.register_setting('-m', '--mem', type='int', default=128, help='Assign MEM megabytes of memory to the guest vm. [default: %default]')
113- self.register_setting('--cpus', type='int', default=1, help='Number of virtual CPU's. [default: %default]')
114+ self.register_setting('--cpus', type='int', default=1, help='Number of virtual CPU\'s. [default: %default]')
115
116 group = self.setting_group('Network related options')
117 domainname = '.'.join(socket.gethostbyname_ex(socket.gethostname())[0].split('.')[1:])

Subscribers

People subscribed via source and target branches