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
=== modified file 'VMBuilder/plugins/cli/__init__.py'
--- VMBuilder/plugins/cli/__init__.py 2008-11-27 17:20:39 +0000
+++ VMBuilder/plugins/cli/__init__.py 2009-02-28 21:03:04 +0000
@@ -80,6 +80,9 @@
8080
81 def set_disk_layout(self, vm):81 def set_disk_layout(self, vm):
82 if not vm.part:82 if not vm.part:
83 vm.rootsize = int(vm.rootsize)
84 vm.swapsize = int(vm.swapsize)
85 vm.optsize = int(vm.optsize)
83 if vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:86 if vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
84 vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/')87 vm.add_filesystem(size='%dM' % vm.rootsize, type='ext3', mntpnt='/')
85 vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None)88 vm.add_filesystem(size='%dM' % vm.swapsize, type='swap', mntpnt=None)
8689
=== modified file 'VMBuilder/plugins/ubuntu/dapper.py'
--- VMBuilder/plugins/ubuntu/dapper.py 2008-12-16 15:29:50 +0000
+++ VMBuilder/plugins/ubuntu/dapper.py 2009-02-28 22:47:37 +0000
@@ -102,6 +102,9 @@
102 logging.debug("Unpreventing daemons from starting")102 logging.debug("Unpreventing daemons from starting")
103 self.unprevent_daemons_starting()103 self.unprevent_daemons_starting()
104104
105 logging.debug("Execute post install script")
106 self.post_install_script()
107
105 def update(self):108 def update(self):
106 self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade')109 self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade')
107 110
@@ -203,7 +206,10 @@
203 self.install_from_template('/boot/grub/device.map', 'devicemap', { 'prefix' : self.disk_prefix })206 self.install_from_template('/boot/grub/device.map', 'devicemap', { 'prefix' : self.disk_prefix })
204207
205 def debootstrap(self):208 def debootstrap(self):
206 cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch, self.vm.suite, self.destdir, self.debootstrap_mirror()]209 cmd = ['/usr/sbin/debootstrap', '--arch=%s' % self.vm.arch]
210 if self.vm.variant:
211 cmd += ['--variant=%s' % self.vm.variant]
212 cmd += [self.vm.suite, self.destdir, self.debootstrap_mirror()]
207 run_cmd(*cmd)213 run_cmd(*cmd)
208 214
209 def debootstrap_mirror(self):215 def debootstrap_mirror(self):
@@ -288,3 +294,9 @@
288 self.run_in_target('locale-gen', self.vm.lang)294 self.run_in_target('locale-gen', self.vm.lang)
289 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })295 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })
290 self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')296 self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')
297
298 def post_install_script(self):
299 if self.vm.post_install_script:
300 run_cmd(self.vm.post_install_script, self.destdir)
301
302
291303
=== modified file 'VMBuilder/plugins/ubuntu/distro.py'
--- VMBuilder/plugins/ubuntu/distro.py 2008-12-16 13:39:21 +0000
+++ VMBuilder/plugins/ubuntu/distro.py 2009-02-28 22:47:37 +0000
@@ -53,6 +53,7 @@
53 group = self.vm.setting_group('Installation options')53 group = self.vm.setting_group('Installation options')
54 group.add_option('--suite', default='jaunty', help='Suite to install. Valid options: %s [default: %%default]' % ' '.join(self.suites))54 group.add_option('--suite', default='jaunty', help='Suite to install. Valid options: %s [default: %%default]' % ' '.join(self.suites))
55 group.add_option('--flavour', '--kernel-flavour', help='Kernel flavour to use. Default and valid options depend on architecture and suite')55 group.add_option('--flavour', '--kernel-flavour', help='Kernel flavour to use. Default and valid options depend on architecture and suite')
56 group.add_option('--variant', metavar='VARIANT', help='Passed to debootstrap --variant flag; use minbase, buildd, or fakechroot.')
56 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.')57 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.')
57 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')58 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')
58 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')59 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')
@@ -61,6 +62,7 @@
61 group.add_option('--components', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,universe).')62 group.add_option('--components', metavar='COMPS', help='A comma seperated list of distro components to include (e.g. main,universe).')
62 group.add_option('--ppa', metavar='PPA', action='append', help='Add ppa belonging to PPA to the vm\'s sources.list.')63 group.add_option('--ppa', metavar='PPA', action='append', help='Add ppa belonging to PPA to the vm\'s sources.list.')
63 group.add_option('--lang', metavar='LANG', default=self.get_locale(), help='Set the locale to LANG [default: %default]')64 group.add_option('--lang', metavar='LANG', default=self.get_locale(), help='Set the locale to LANG [default: %default]')
65 group.add_option('--post-install-script', metavar='PATH', help='Run script to update the installed image; scritp is passed the install dir')
64 self.vm.register_setting_group(group)66 self.vm.register_setting_group(group)
6567
66 group = self.vm.setting_group('Settings for the initial user')68 group = self.vm.setting_group('Settings for the initial user')
6769
=== modified file 'VMBuilder/plugins/ubuntu/edgy.py'
--- VMBuilder/plugins/ubuntu/edgy.py 2008-12-04 16:28:48 +0000
+++ VMBuilder/plugins/ubuntu/edgy.py 2009-02-28 22:47:22 +0000
@@ -20,6 +20,7 @@
20import logging20import logging
21import suite21import suite
22import shutil22import shutil
23import os
23import VMBuilder.disk as disk24import VMBuilder.disk as disk
24from VMBuilder.util import run_cmd25from VMBuilder.util import run_cmd
25from VMBuilder.plugins.ubuntu.dapper import Dapper26from VMBuilder.plugins.ubuntu.dapper import Dapper
@@ -49,9 +50,12 @@
4950
50 def copy_settings(self):51 def copy_settings(self):
51 self.copy_to_target('/etc/default/locale', '/etc/default/locale')52 self.copy_to_target('/etc/default/locale', '/etc/default/locale')
52 shutil.rmtree('%s/etc/console-setup' % self.destdir)53 csdir = '%s/etc/console-setup' % self.destdir
53 self.copy_to_target('/etc/console-setup', '/etc/console-setup')54 have_cs = os.path.isdir(csdir)
54 self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup')55 if have_cs:
56 shutil.rmtree(csdir)
57 self.copy_to_target('/etc/console-setup', '/etc/console-setup')
58 self.copy_to_target('/etc/default/console-setup', '/etc/default/console-setup')
55 self.copy_to_target('/etc/timezone', '/etc/timezone')59 self.copy_to_target('/etc/timezone', '/etc/timezone')
56 self.run_in_target('dpkg-reconfigure', '-pcritical', 'tzdata')60 self.run_in_target('dpkg-reconfigure', '-pcritical', 'tzdata')
57 self.run_in_target('locale-gen', 'en_US')61 self.run_in_target('locale-gen', 'en_US')
@@ -59,4 +63,5 @@
59 self.run_in_target('locale-gen', self.vm.lang)63 self.run_in_target('locale-gen', self.vm.lang)
60 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })64 self.install_from_template('/etc/default/locale', 'locale', { 'lang' : self.vm.lang })
61 self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')65 self.run_in_target('dpkg-reconfigure', '-pcritical', 'locales')
62 self.run_in_target('dpkg-reconfigure', '-pcritical', 'console-setup')66 if have_cs:
67 self.run_in_target('dpkg-reconfigure', '-pcritical', 'console-setup')
6368
=== modified file 'VMBuilder/vm.py'
--- VMBuilder/vm.py 2009-02-17 13:31:40 +0000
+++ VMBuilder/vm.py 2009-02-28 21:36:54 +0000
@@ -137,7 +137,7 @@
137 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.')137 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.')
138 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).')138 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).')
139 self.register_setting('-m', '--mem', type='int', default=128, help='Assign MEM megabytes of memory to the guest vm. [default: %default]')139 self.register_setting('-m', '--mem', type='int', default=128, help='Assign MEM megabytes of memory to the guest vm. [default: %default]')
140 self.register_setting('--cpus', type='int', default=1, help='Number of virtual CPU's. [default: %default]')140 self.register_setting('--cpus', type='int', default=1, help='Number of virtual CPU\'s. [default: %default]')
141141
142 group = self.setting_group('Network related options')142 group = self.setting_group('Network related options')
143 domainname = '.'.join(socket.gethostbyname_ex(socket.gethostname())[0].split('.')[1:])143 domainname = '.'.join(socket.gethostbyname_ex(socket.gethostname())[0].split('.')[1:])

Subscribers

People subscribed via source and target branches