# HG changeset patch # User Bernhard Herzog # Date 1225985789 0 # Node ID b82fe4d258939a37797d428caf8a692a80e735be # Parent 98ffe5f3863b09b7887edc8d72c3c67f62adaae0 SourcePackager.create_tarball: add parameter to specify compression method diff -r 98ffe5f3863b -r b82fe4d25893 treepkg/packager.py --- a/treepkg/packager.py Thu Nov 06 15:25:37 2008 +0000 +++ b/treepkg/packager.py Thu Nov 06 15:36:29 2008 +0000 @@ -87,7 +87,7 @@ override this method if necessary. """ - def create_tarball(self, tarballname, workdir, basedir): + def create_tarball(self, tarballname, workdir, basedir, compression="gz"): """Creates a new tarball. Parameters: @@ -98,10 +98,20 @@ basedir -- The basedirectory of the files that are packaged into the tarfile. This should be a relative filename directly in workdir. + compression -- The compression method to use as a string. + Suported are 'gz' for gzip compression (the + default) and 'bz2' for bzip2. """ logging.info("Creating tarball %r", tarballname) - run.call(cmdexpand("tar czf $tarballname -C $workdir $basedir", - **locals())) + if compression == "gz": + compression_flag = "z" + elif compression == "bz2": + compression_flag = "j" + else: + raise ValueError("Unknown compression method %r" % compression) + + run.call(cmdexpand("tar c -$compression_flag -f $tarballname" + " -C $workdir $basedir", **locals())) def copy_debian_directory(self, pkgbasedir, pkgbaseversion, changemsg): """Copies the debian directory and updates the copy's changelog