Mercurial > treepkg
changeset 207:b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 06 Nov 2008 15:36:29 +0000 |
parents | 98ffe5f3863b |
children | 1527c37bd7aa |
files | treepkg/packager.py |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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