diff -Nru vm-builder-0.12.3/AUTHORS vm-builder-0.12.4/AUTHORS --- vm-builder-0.12.3/AUTHORS 2010-03-03 14:16:49.000000000 +0000 +++ vm-builder-0.12.4/AUTHORS 2010-05-11 10:12:37.000000000 +0000 @@ -1,4 +1,4 @@ -Main author and original conceptor: Soren Hansen +Main author and original conceptor: Soren Hansen These people have also helped make VMBuilder what it is today: * Andreas Heck diff -Nru vm-builder-0.12.3/debian/changelog vm-builder-0.12.4/debian/changelog --- vm-builder-0.12.3/debian/changelog 2010-10-13 13:36:14.000000000 +0000 +++ vm-builder-0.12.4/debian/changelog 2010-10-13 13:36:14.000000000 +0000 @@ -1,3 +1,20 @@ +vm-builder (0.12.4-0ubuntu0.2) lucid-security; urgency=low + + * debian/patches/0001-lp659532.patch: supply disk format in libvirt XML + for converted disks otherwise non-raw disks (eg, 'qcow2', the default in + vm-builder) won't show up in the guest with patched libvirt in + lucid-security or libvirt 0.8.3 and higher. + - LP: #659532 + + -- Jamie Strandboge Wed, 13 Oct 2010 08:08:07 -0500 + +vm-builder (0.12.4-0ubuntu0.1) lucid-proposed; urgency=low + + * New upstream, bugfix release. (LP: #539460, #536942, #535397, + #550689, #410521, #550691, others) + + -- Soren Hansen Fri, 09 Jul 2010 23:03:27 +0200 + vm-builder (0.12.3-0ubuntu1) lucid; urgency=low * New upstream bugfix release. (LP: #530331, #531409, #460398, #538674, diff -Nru vm-builder-0.12.3/debian/patches/0001-lp659532.patch vm-builder-0.12.4/debian/patches/0001-lp659532.patch --- vm-builder-0.12.3/debian/patches/0001-lp659532.patch 1970-01-01 00:00:00.000000000 +0000 +++ vm-builder-0.12.4/debian/patches/0001-lp659532.patch 2010-10-13 13:36:14.000000000 +0000 @@ -0,0 +1,55 @@ +Author: Jamie Strandboge +Description: adjust libvirt XML template to specify the qemu image format for + converted disks +Bug-Ubuntu: https://launchpad.net/bugs/659532 + +Index: vm-builder-0.12.4/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl +=================================================================== +--- vm-builder-0.12.4.orig/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl 2010-10-12 18:30:29.000000000 -0500 ++++ vm-builder-0.12.4/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl 2010-10-12 18:31:05.000000000 -0500 +@@ -35,6 +35,9 @@ + + #for $disk in $disks + ++#if $disk.format_type != None ++ ++#end if + + + +Index: vm-builder-0.12.4/VMBuilder/disk.py +=================================================================== +--- vm-builder-0.12.4.orig/VMBuilder/disk.py 2010-10-12 18:30:29.000000000 -0500 ++++ vm-builder-0.12.4/VMBuilder/disk.py 2010-10-12 18:31:05.000000000 -0500 +@@ -77,6 +77,9 @@ + self.preallocated = True + self.size = detect_size(self.filename) + ++ self.format_type = None ++ "The format type of the disks. Only used for converted disks." ++ + def devletters(self): + """ + @rtype: string +@@ -244,6 +247,7 @@ + run_cmd(qemu_img_path(), 'convert', '-O', format, self.filename, destfile) + os.unlink(self.filename) + self.filename = os.path.abspath(destfile) ++ self.format_type = format + return destfile + + class Partition(object): +Index: vm-builder-0.12.4/VMBuilder/plugins/libvirt/templates/libvirtxml_fsimage.tmpl +=================================================================== +--- vm-builder-0.12.4.orig/VMBuilder/plugins/libvirt/templates/libvirtxml_fsimage.tmpl 2010-10-12 18:31:16.000000000 -0500 ++++ vm-builder-0.12.4/VMBuilder/plugins/libvirt/templates/libvirtxml_fsimage.tmpl 2010-10-12 18:31:34.000000000 -0500 +@@ -22,6 +22,9 @@ + + #for $fs in $filesystems + ++#if $fs.format_type != None ++ ++#end if + + + diff -Nru vm-builder-0.12.3/debian/patches/series vm-builder-0.12.4/debian/patches/series --- vm-builder-0.12.3/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ vm-builder-0.12.4/debian/patches/series 2010-10-13 13:36:14.000000000 +0000 @@ -0,0 +1 @@ +0001-lp659532.patch diff -Nru vm-builder-0.12.3/NEWS vm-builder-0.12.4/NEWS --- vm-builder-0.12.3/NEWS 2010-03-30 03:06:11.000000000 +0000 +++ vm-builder-0.12.4/NEWS 2010-05-18 11:41:27.000000000 +0000 @@ -1,3 +1,13 @@ +0.12.4: + + * Revive firstscripts plugins. This fixes the --firstboot and --firstlogin + options, both of which went missing with 0.12. + * Make Plugin.install_file work in non-context plugins (plugins that are not + Distros or Hypervisors). + * Do a slightly better job at cleaning up after ourselves by removing the + distro chroot by default and removing the temporary root mount point. + * Revive QEMu hypervisor. + 0.12.3: * Reworked the way timezones and locales are handled. This fixes an diff -Nru vm-builder-0.12.3/PKG-INFO vm-builder-0.12.4/PKG-INFO --- vm-builder-0.12.3/PKG-INFO 2010-03-30 03:20:42.000000000 +0000 +++ vm-builder-0.12.4/PKG-INFO 2010-05-18 11:43:39.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: VMBuilder -Version: 0.12.3 +Version: 0.12.4 Summary: Uncomplicated VM Builder Home-page: http://launchpad.net/vmbuilder/ Author: Soren Hansen diff -Nru vm-builder-0.12.3/setup.py vm-builder-0.12.4/setup.py --- vm-builder-0.12.3/setup.py 2010-03-30 03:01:08.000000000 +0000 +++ vm-builder-0.12.4/setup.py 2010-05-12 09:32:54.000000000 +0000 @@ -15,7 +15,7 @@ print repr(e) setup(name='VMBuilder', - version='0.12.3', + version='0.12.4', description='Uncomplicated VM Builder', author='Soren Hansen', author_email='soren@ubuntu.com', diff -Nru vm-builder-0.12.3/VMBuilder/contrib/cli.py vm-builder-0.12.4/VMBuilder/contrib/cli.py --- vm-builder-0.12.3/VMBuilder/contrib/cli.py 2010-03-27 02:40:14.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/contrib/cli.py 2010-04-07 17:23:19.000000000 +0000 @@ -100,6 +100,7 @@ elif hypervisor.has_setting(option) and hypervisor.get_setting_default(option) != val: hypervisor.set_setting_fuzzy(option, val) + chroot_dir = None if self.options.existing_chroot: distro.set_chroot_dir(self.options.existing_chroot) distro.call_hooks('preflight_check') @@ -118,6 +119,12 @@ os.mkdir(destdir) self.fix_ownership(destdir) hypervisor.finalise(destdir) + # If chroot_dir is not None, it means we created it, + # and if we reach here, it means the user didn't pass + # --only-chroot. Hence, we need to remove it to clean + # up after ourselves. + if chroot_dir: + util.run_cmd('rm', '-rf', '--one-file-system', chroot_dir) except VMBuilderException, e: logging.error(e) raise @@ -215,17 +222,18 @@ try: for line in file(self.options.part): elements = line.strip().split(' ') + tmpfile = util.tmpfile(keep=False) if elements[0] == 'root': - hypervisor.add_filesystem(elements[1], default_filesystem, mntpnt='/') + hypervisor.add_filesystem(elements[1], default_filesystem, filename=tmpfile, mntpnt='/') elif elements[0] == 'swap': - hypervisor.add_filesystem(elements[1], type='swap', mntpnt=None) + hypervisor.add_filesystem(elements[1], type='swap', filename=tmpfile, mntpnt=None) elif elements[0] == '---': # We just ignore the user's attempt to specify multiple disks pass elif len(elements) == 3: - hypervisor.add_filesystem(elements[1], type=default_filesystem, mntpnt=elements[0], devletter='', device=elements[2], dummy=(int(elements[1]) == 0)) + hypervisor.add_filesystem(elements[1], type=default_filesystem, filename=tmpfile, mntpnt=elements[0], devletter='', device=elements[2], dummy=(int(elements[1]) == 0)) else: - hypervisor.add_filesystem(elements[1], type=default_filesystem, mntpnt=elements[0]) + hypervisor.add_filesystem(elements[1], type=default_filesystem, filename=tmpfile, mntpnt=elements[0]) except IOError, (errno, strerror): self.optparser.error("%s parsing --part option: %s" % (errno, strerror)) diff -Nru vm-builder-0.12.3/VMBuilder/disk.py vm-builder-0.12.4/VMBuilder/disk.py --- vm-builder-0.12.3/VMBuilder/disk.py 2010-03-29 22:04:28.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/disk.py 2010-05-07 11:47:58.000000000 +0000 @@ -361,7 +361,7 @@ if os.path.exists("/sbin/vol_id"): self.uuid = run_cmd('vol_id', '--uuid', self.filename).rstrip() elif os.path.exists("/sbin/blkid"): - self.uuid = run_cmd('blkid', '-p', '-sUUID', '-ovalue', self.filename).rstrip() + self.uuid = run_cmd('blkid', '-c', '/dev/null', '-sUUID', '-ovalue', self.filename).rstrip() def mkfs_fstype(self): map = { TYPE_EXT2: ['mkfs.ext2', '-F'], TYPE_EXT3: ['mkfs.ext3', '-F'], TYPE_EXT4: ['mkfs.ext4', '-F'], TYPE_XFS: ['mkfs.xfs'], TYPE_SWAP: ['mkswap'] } diff -Nru vm-builder-0.12.3/VMBuilder/hypervisor.py vm-builder-0.12.4/VMBuilder/hypervisor.py --- vm-builder-0.12.3/VMBuilder/hypervisor.py 2010-03-29 22:09:38.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/hypervisor.py 2010-04-07 17:27:29.000000000 +0000 @@ -19,6 +19,7 @@ # Hypervisor super class import logging +import os import VMBuilder.distro import VMBuilder.disk from VMBuilder.util import run_cmd, tmpdir @@ -68,6 +69,7 @@ self.call_hooks('install_bootloader', self.chroot_dir, self.disks) self.call_hooks('install_kernel', self.chroot_dir) self.call_hooks('unmount_partitions') + os.rmdir(self.chroot_dir) def finalise(self, destdir): self.call_hooks('convert', diff -Nru vm-builder-0.12.3/VMBuilder/__init__.py vm-builder-0.12.4/VMBuilder/__init__.py --- vm-builder-0.12.3/VMBuilder/__init__.py 2010-03-30 03:01:30.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/__init__.py 2010-05-18 11:42:37.000000000 +0000 @@ -128,7 +128,7 @@ info = vcsversion.version_info info['major'] = 0 info['minor'] = 12 - info['micro'] = 3 + info['micro'] = 4 return info logging.debug('Loading plugins') diff -Nru vm-builder-0.12.3/VMBuilder/plugins/firstscripts/__init__.py vm-builder-0.12.4/VMBuilder/plugins/firstscripts/__init__.py --- vm-builder-0.12.3/VMBuilder/plugins/firstscripts/__init__.py 2010-02-25 08:17:47.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/firstscripts/__init__.py 2010-05-07 09:54:39.000000000 +0000 @@ -1,7 +1,7 @@ # # Uncomplicated VM Builder -# Copyright (C) 2007-2009 Canonical Ltd. -# +# Copyright (C) 2007-2010 Canonical Ltd. +# # See AUTHORS for list of contributors # # This program is free software: you can redistribute it and/or modify @@ -28,36 +28,38 @@ name = 'First-Scripts plugin' def register_options(self): - group = self.context.setting_group('Scripts') - group.add_option('--firstboot', metavar='PATH', default='', help='Specify a script that will be copied into the guest and executed the first time the machine boots. This script must not be interactive.') - group.add_option('--firstlogin', metavar='PATH', default='', help='Specify a script that will be copied into the guest and will be executed the first time the user logs in. This script can be interactive.') - self.context.register_setting_group(group) + group = self.setting_group('Scripts') + group.add_setting('firstboot', metavar='PATH', help='Specify a script that will be copied into the guest and executed the first time the machine boots. This script must not be interactive.') + group.add_setting('firstlogin', metavar='PATH', help='Specify a script that will be copied into the guest and will be executed the first time the user logs in. This script can be interactive.') def preflight_check(self): - - if self.context.firstboot: - logging.debug("Checking if firstboot script %s exists" % (self.context.firstboot,)) - if not(os.path.isfile(self.context.firstboot)): - raise VMBuilderUserError('The path to the first-boot script is invalid: %s. Make sure you are providing a full path.' % self.context.firstboot) - - if self.context.firstlogin: - logging.debug("Checking if first login script %s exists" % (self.context.firstlogin,)) - if not(os.path.isfile(self.context.firstlogin)): - raise VMBuilderUserError('The path to the first-login script is invalid: %s. Make sure you are providing a full path.' % self.context.firstlogin) + firstboot = self.context.get_setting('firstboot') + if firstboot: + logging.debug("Checking if firstboot script %s exists" % (firstboot,)) + if not(os.path.isfile(firstboot) and firstboot.startswith('/')): + raise VMBuilderUserError('The path to the first-boot script is invalid: %s. Make sure you are providing a full path.' % firstboot) + + firstlogin = self.context.get_setting('firstlogin') + if firstlogin: + logging.debug("Checking if first login script %s exists" % (firstlogin,)) + if not(os.path.isfile(firstlogin) and firstlogin.startswith('/')): + raise VMBuilderUserError('The path to the first-login script is invalid: %s. Make sure you are providing a full path.' % firstlogin) def post_install(self): - logging.debug("Installing firstboot script %s" % (self.context.firstboot,)) - if self.context.firstboot: - self.context.install_file('/root/firstboot.sh', source=self.vm.firstboot, mode=0700) - os.rename('%s/etc/rc.local' % self.context.installdir, '%s/etc/rc.local.orig' % self.vm.installdir) + firstboot = self.context.get_setting('firstboot') + if firstboot: + logging.debug("Installing firstboot script %s" % (firstboot,)) + self.context.install_file('/root/firstboot.sh', source=firstboot, mode=0700) + os.rename('%s/etc/rc.local' % self.context.chroot_dir, '%s/etc/rc.local.orig' % self.context.chroot_dir) self.install_from_template('/etc/rc.local', 'firstbootrc', mode=0755) - logging.debug("Installing first login script %s" % (self.context.firstlogin,)) - if self.context.firstlogin: - self.context.install_file('/root/firstlogin.sh', source=self.vm.firstlogin, mode=0755) - os.rename('%s/etc/bash.bashrc' % self.context.installdir, '%s/etc/bash.bashrc.orig' % self.vm.installdir) + firstlogin = self.context.get_setting('firstlogin') + if firstlogin: + logging.debug("Installing first login script %s" % (firstlogin,)) + self.context.install_file('/root/firstlogin.sh', source=firstlogin, mode=0755) + os.rename('%s/etc/bash.bashrc' % self.context.chroot_dir, '%s/etc/bash.bashrc.orig' % self.context.chroot_dir) self.install_from_template('/etc/bash.bashrc', 'firstloginrc') return True -#register_plugin(Firstscripts) +register_distro_plugin(Firstscripts) diff -Nru vm-builder-0.12.3/VMBuilder/plugins/__init__.py vm-builder-0.12.4/VMBuilder/plugins/__init__.py --- vm-builder-0.12.3/VMBuilder/plugins/__init__.py 2010-02-25 23:36:41.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/__init__.py 2010-04-07 20:02:07.000000000 +0000 @@ -66,7 +66,7 @@ pass def install_file(self, path, contents=None, source=None, mode=None): - fullpath = '%s%s' % (self.chroot_dir, path) + fullpath = '%s%s' % (self.context.chroot_dir, path) if not os.path.isdir(os.path.dirname(fullpath)): os.makedirs(os.path.dirname(fullpath)) if source and not contents: diff -Nru vm-builder-0.12.3/VMBuilder/plugins/kvm/vm.py vm-builder-0.12.4/VMBuilder/plugins/kvm/vm.py --- vm-builder-0.12.3/VMBuilder/plugins/kvm/vm.py 2010-02-24 22:07:33.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/kvm/vm.py 2010-05-12 09:28:55.000000000 +0000 @@ -18,9 +18,7 @@ # from VMBuilder import register_hypervisor, Hypervisor import VMBuilder -import VMBuilder.hypervisor import os -import os.path import stat class KVM(Hypervisor): @@ -55,4 +53,15 @@ os.chmod(script, stat.S_IRWXU | stat.S_IRWXU | stat.S_IROTH | stat.S_IXOTH) self.call_hooks('fix_ownership', script) + def libvirt_domain_type_name(self): + return 'kvm' + +class QEMu(KVM): + name = 'QEMu' + arg = 'qemu' + + def libvirt_domain_type_name(self): + return 'qemu' + register_hypervisor(KVM) +register_hypervisor(QEMu) diff -Nru vm-builder-0.12.3/VMBuilder/plugins/libvirt/__init__.py vm-builder-0.12.4/VMBuilder/plugins/libvirt/__init__.py --- vm-builder-0.12.3/VMBuilder/plugins/libvirt/__init__.py 2010-03-29 22:30:11.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/libvirt/__init__.py 2010-05-12 09:31:29.000000000 +0000 @@ -37,8 +37,8 @@ if not libvirt_uri: return True - if not self.context.name == 'KVM': - raise VMBuilderUserError('The libvirt plugin is only equiped to work with KVM at the moment.') + if not self.context.name == 'KVM' and not self.context.name == 'QEMu': + raise VMBuilderUserError('The libvirt plugin is only equiped to work with KVM and QEMu at the moment.') import libvirt import xml.etree.ElementTree @@ -70,7 +70,8 @@ 'virtio_net' : self.context.distro.use_virtio_net(), 'disks' : self.context.disks, 'filesystems' : self.context.filesystems, - 'hostname' : hostname } + 'hostname' : hostname, + 'domain_type' : self.context.libvirt_domain_type_name() } if self.context.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE: vmxml = VMBuilder.util.render_template('libvirt', self.context, 'libvirtxml_fsimage', tmpl_ctxt) else: diff -Nru vm-builder-0.12.3/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl vm-builder-0.12.4/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl --- vm-builder-0.12.3/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl 2010-02-24 22:05:47.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/libvirt/templates/libvirtxml.tmpl 2010-05-12 09:31:51.000000000 +0000 @@ -1,4 +1,4 @@ - + $hostname #echo int($mem) * 1024 # $cpus diff -Nru vm-builder-0.12.3/VMBuilder/plugins/ubuntu/dapper.py vm-builder-0.12.4/VMBuilder/plugins/ubuntu/dapper.py --- vm-builder-0.12.3/VMBuilder/plugins/ubuntu/dapper.py 2010-03-29 20:23:19.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/ubuntu/dapper.py 2010-03-30 19:26:05.000000000 +0000 @@ -46,7 +46,7 @@ def check_arch_validity(self, arch): return arch in self.valid_flavours.keys() - + def install(self, destdir): raise VMBuilderException('Do not call this method!') @@ -74,7 +74,7 @@ def update(self): self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade', env={ 'DEBIAN_FRONTEND' : 'noninteractive' }) - + def install_authorized_keys(self): ssh_key = self.context.get_setting('ssh-key') if ssh_key: diff -Nru vm-builder-0.12.3/VMBuilder/plugins/ubuntu/edgy.py vm-builder-0.12.4/VMBuilder/plugins/ubuntu/edgy.py --- vm-builder-0.12.3/VMBuilder/plugins/ubuntu/edgy.py 2010-03-16 14:07:32.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/plugins/ubuntu/edgy.py 2010-03-30 19:27:36.000000000 +0000 @@ -30,9 +30,12 @@ def mangle_grub_menu_lst(self, disks): bootdev = disk.bootpart(disks) - run_cmd('sed', '-ie', 's/^# kopt=root=\([^ ]*\)\(.*\)/# kopt=root=UUID=%s\\2/g' % bootdev.fs.uuid, '%s/boot/grub/menu.lst' % self.destdir) - run_cmd('sed', '-ie', 's/^# groot.*/# groot %s/g' % bootdev.get_grub_id(), '%s/boot/grub/menu.lst' % self.destdir) - run_cmd('sed', '-ie', '/^# kopt_2_6/ d', '%s/boot/grub/menu.lst' % self.destdir) + run_cmd('sed', '-ie', 's/^# kopt=root=\([^ ]*\)\(.*\)/# kopt=root=UUID=%s\\2/g' % bootdev.fs.uuid, + '%s/boot/grub/menu.lst' % self.context.chroot_dir) + run_cmd('sed', '-ie', 's/^# groot.*/# groot %s/g' % bootdev.get_grub_id(), + '%s/boot/grub/menu.lst' % self.context.chroot_dir) + run_cmd('sed', '-ie', '/^# kopt_2_6/ d', '%s/boot/grub/menu.lst' % + self.context.chroot_dir) def fstab(self): retval = '''# /etc/fstab: static file system information. diff -Nru vm-builder-0.12.3/VMBuilder/vcsversion.py vm-builder-0.12.4/VMBuilder/vcsversion.py --- vm-builder-0.12.3/VMBuilder/vcsversion.py 2010-03-30 03:20:42.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/vcsversion.py 2010-05-18 11:43:39.000000000 +0000 @@ -5,11 +5,11 @@ """ version_info = {'branch_nick': u'vmbuilder-0.12', - 'build_date': '2010-03-29 22:20:42 -0500', + 'build_date': '2010-05-18 13:43:39 +0200', 'clean': None, - 'date': '2010-03-29 22:19:10 -0500', - 'revision_id': 'soren@linux2go.dk-20100330031910-bha8ngutjd9ij32o', - 'revno': 435} + 'date': '2010-05-18 13:43:12 +0200', + 'revision_id': 'soren@linux2go.dk-20100518114312-9knzsw8j3hitv1h2', + 'revno': 444} revisions = {} diff -Nru vm-builder-0.12.3/VMBuilder/vm.py vm-builder-0.12.4/VMBuilder/vm.py --- vm-builder-0.12.3/VMBuilder/vm.py 2010-02-25 08:12:59.000000000 +0000 +++ vm-builder-0.12.4/VMBuilder/vm.py 2010-05-11 10:12:30.000000000 +0000 @@ -70,7 +70,7 @@ self.fsmounted = False - self.optparser = _MyOptParser(epilog="ubuntu-vm-builder is Copyright (C) 2007-2009 Canonical Ltd. and written by Soren Hansen .", usage='%prog hypervisor distro [options]') + self.optparser = _MyOptParser(epilog="ubuntu-vm-builder is Copyright (C) 2007-2009 Canonical Ltd. and written by Soren Hansen .", usage='%prog hypervisor distro [options]') self.optparser.arg_help = (('hypervisor', self.hypervisor_help), ('distro', self.distro_help)) self.confparser = ConfigParser.SafeConfigParser()