Hi, On Fri, Dec 04, 2009 at 03:38:37PM +0100, Holger Levsen wrote: > tags 559449 + confirmed > thanks > > Hi Patrick, > > thanks for your bugreport with patch! > > On Freitag, 4. Dezember 2009, Patrick Schoenfeld wrote: > > I'd like to use piuparts but neither with creating a new chroot on every > > run, nor by unpacking a tarball on every run, but with LVM snapshots. > > There is a bug report about adding schroot support, but I didn't see any > > benefit of using schroot in contrast to just using LVM snapshots, > > less requierements (=no lvm) to use it?
I don't get that, because I don't see what benefits this would provide over using the methods piuparts is already to.. oh wait. There is one: With schroot piuparts could run without root permissions. Ok, I don't care to much about it, but anyone else sureley does :) > > so > > I implemented the latter. My patch is attached. Feel free to apply it > > or if you have any questions/comments get back to me. > > Looks good to me, will apply. Right now I just don't get how this is related: Oops. That was an accident. > Could you also please provide a patch for piuparts.1.txt? ;-) Extra bonus > points for a > debian/changelog entry ;-) See new attached patch. Best Regards, Patrick
Index: debian/changelog =================================================================== --- debian/changelog (Revision 535) +++ debian/changelog (Arbeitskopie) @@ -1,3 +1,11 @@ +piuparts (0.38) unstable; urgency=low + + * piuparts.py: + - Add support for using LVM snapshots. Thanks to + Patrick Schoenfeld for the patch. (Closes: #559449) + + -- Patrick Schoenfeld <[email protected]> Fri, 04 Dec 2009 15:55:42 +0100 + piuparts (0.37) unstable; urgency=low * piuparts-report.py: report packages with update-rc.d warnings and those Index: piuparts.1.txt =================================================================== --- piuparts.1.txt (Revision 535) +++ piuparts.1.txt (Arbeitskopie) @@ -47,6 +47,15 @@ + The tarball can be created with the '-s' option, or you can use one that *pbuilder* has created (see '-p'). If you create one manually, make sure the root of the chroot is the root of the tarball. +*--lvm-volume*='lvm-volume':: + Use the specified lvm-volume as source for the chroot, instead of building a + new one with debootstrap. This creates a snapshot of the given LVM volume and + mounts it to the chroot path. + +*--lvm-snapshot-size*='snapshot-size':: + Use the specified snapshot-size as snapshot size when creating a new LVM + snapshot (default: 1G) + *-d* 'name', *--distribution*='name':: Which Debian distribution to use: a code name (etch, lenny, sid) or experimental. The default is sid (i.e, unstable). Index: piuparts.py =================================================================== --- piuparts.py (Revision 535) +++ piuparts.py (Arbeitskopie) @@ -49,6 +49,7 @@ import subprocess import unittest import urllib +import uuid from debian_bundle import deb822 @@ -137,6 +138,7 @@ self.debian_distros = [] self.bindmounts = [] self.basetgz = None + self.lvm_volume = None self.savetgz = None self.endmeta = None self.saveendmeta = None @@ -554,6 +556,8 @@ if settings.basetgz: self.unpack_from_tgz(settings.basetgz) + elif settings.lvm_volume: + self.setup_from_lvm(settings.lvm_volume) else: self.setup_minimal_chroot() @@ -585,6 +589,10 @@ if not settings.keep_tmpdir and os.path.exists(self.name): self.unmount_proc() self.unmount_selinux() + if settings.lvm_volume: + logging.debug('Unmounting and removing LVM snapshot %s' % self.lvm_snapshot_name) + run(['umount', self.name]) + run(['lvremove', '-f', self.lvm_snapshot]) shutil.rmtree(self.name) logging.debug("Removed directory tree at %s" % self.name) elif settings.keep_tmpdir: @@ -608,6 +616,18 @@ logging.debug("Unpacking %s into %s" % (tarball, self.name)) run(["tar", "-C", self.name, "-zxf", tarball]) + def setup_from_lvm(self, lvm_volume): + """Create a chroot by creating an LVM snapshot.""" + self.lvm_base = os.path.dirname(lvm_volume) + self.lvm_vol_name = os.path.basename(lvm_volume) + self.lvm_snapshot_name = self.lvm_vol_name + "-" + str(uuid.uuid1()); + self.lvm_snapshot = os.path.join(self.lvm_base, self.lvm_snapshot_name) + + logging.debug("Creating LVM snapshot %s from %s" % (self.lvm_snapshot, lvm_volume)) + run(['lvcreate', '-n', self.lvm_snapshot, '-s', lvm_volume, '-L', settings.lvm_snapshot_size]) + logging.info("Mounting LVM snapshot to %s" % self.name); + run(['mount', self.lvm_snapshot, self.name]) + def run(self, command, ignore_errors=False): return run(["chroot", self.name] + command, ignore_errors=ignore_errors) @@ -1712,7 +1732,6 @@ def set_basetgz_to_pbuilder(option, opt, value, parser, *args, **kwargs): parser.values.basetgz = "/var/cache/pbuilder/base.tgz" - def parse_command_line(): """Parse the command line, change global settings, return non-options.""" @@ -1731,7 +1750,16 @@ help="Use TARBALL as the contents of the initial " + "chroot, instead of building a new one with " + "debootstrap.") - + + parser.add_option("--lvm-volume", metavar="LVM-VOL", action="store", + help="Use LVM-VOL as source for the chroot, instead of building " + + "a new one with debootstrap. This creates a snapshot of the " + + "given LVM volume and mounts it to the chroot path") + + parser.add_option("--lvm-snapshot-size", metavar="SNAPSHOT-SIZE", action="store", + default="1G", help="Use SNAPSHOT-SIZE as snapshot size when creating " + + "a new LVM snapshot (default: 1G)") + parser.add_option("-B", "--end-meta", metavar="FILE", help="XXX") @@ -1854,6 +1882,8 @@ settings.defaults = opts.defaults settings.args_are_package_files = not opts.apt settings.basetgz = opts.basetgz + settings.lvm_volume = opts.lvm_volume + settings.lvm_snapshot_size = opts.lvm_snapshot_size settings.bindmounts += opts.bindmount settings.debian_distros = opts.distribution settings.ignored_files += opts.ignore

