[Treepkg-commits] r133 - trunk/treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Nov 6 16:36:29 CET 2008


Author: bh
Date: 2008-11-06 16:36:29 +0100 (Thu, 06 Nov 2008)
New Revision: 133

Modified:
   trunk/treepkg/packager.py
Log:
SourcePackager.create_tarball: add parameter to specify compression method


Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py	2008-11-06 15:25:37 UTC (rev 132)
+++ trunk/treepkg/packager.py	2008-11-06 15:36:29 UTC (rev 133)
@@ -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,11 +98,21 @@
           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
 



More information about the Treepkg-commits mailing list