]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/filewriter.py
daklib/filewriter.py: change default compression to gzip and xz
[dak.git] / daklib / filewriter.py
index 7fa68289e8a933d92979ff179c77463f7ebd4a57..2015f14f08b2e6fb593e82f0ec33dcd4625eeec4 100644 (file)
@@ -27,7 +27,7 @@ Helper code for file writing with optional compression.
 
 from daklib.config import Config
 
-from subprocess import check_call
+from daklib.daksubprocess import check_call
 
 import os, os.path
 
@@ -47,6 +47,7 @@ class BaseFileWriter(object):
         self.uncompressed = 'none' in compression
         self.gzip = 'gzip' in compression
         self.bzip2 = 'bzip2' in compression
+        self.xz = 'xz' in compression
         self.path = template % keywords
 
     def open(self):
@@ -79,6 +80,9 @@ class BaseFileWriter(object):
         if self.bzip2:
             check_call('bzip2 -9 <%s.new >%s.bz2.new' % (self.path, self.path), shell = True)
             self.rename('%s.bz2' % self.path)
+        if self.xz:
+            check_call('xz -c <{0}.new >{0}.xz.new'.format(self.path), shell=True)
+            self.rename('{0}.xz'.format(self.path))
         if self.uncompressed:
             self.rename(self.path)
         else:
@@ -121,7 +125,7 @@ class PackagesFileWriter(BaseFileWriter):
         are strings.  Output files are gzip compressed only.
         '''
         flags = {
-            'compression': ['gzip', 'bzip2'],
+            'compression': ['gzip', 'xz'],
         }
         flags.update(keywords)
         if flags['debtype'] == 'deb':
@@ -137,7 +141,7 @@ class SourcesFileWriter(BaseFileWriter):
         files are gzip compressed only.
         '''
         flags = {
-            'compression': ['gzip', 'bzip2'],
+            'compression': ['gzip', 'xz'],
         }
         flags.update(keywords)
         template = "%(archive)s/dists/%(suite)s/%(component)s/source/Sources"