]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/filewriter.py
Merge remote branch 'origin/master' into p-s-from-db
[dak.git] / daklib / filewriter.py
index 35919634e9e971515ff5388ff14289542e752ea8..8907fa6d96fa39f7c8e2d7163f3c20e4f361bd2e 100755 (executable)
@@ -54,6 +54,11 @@ class BaseFileWriter(object):
         '''
         Returns a file object for writing.
         '''
+        # create missing directories
+        try:
+            os.makedirs(os.path.dirname(self.path))
+        except:
+            pass
         self.file = open(self.path + '.new', 'w')
         return self.file
 
@@ -93,8 +98,56 @@ class BinaryContentsFileWriter(BaseFileWriter):
             'bzip2':        False
         }
         flags.update(keywords)
-        if 'component' in flags:
+        if flags['debtype'] == 'deb':
             template = "dists/%(suite)s/%(component)s/Contents-%(architecture)s"
-        else:
-            template = "dists/%(suite)s/Contents-%(architecture)s"
+        else: # udeb
+            template = "dists/%(suite)s/%(component)s/Contents-udeb-%(architecture)s"
+        BaseFileWriter.__init__(self, template, **flags)
+
+class SourceContentsFileWriter(BaseFileWriter):
+    def __init__(self, **keywords):
+        '''
+        The value of the keywords suite and component are strings.
+        Output files are gzip compressed only.
+        '''
+        flags = {
+            'uncompressed': False,
+            'gzip':         True,
+            'bzip2':        False
+        }
+        flags.update(keywords)
+        template = "dists/%(suite)s/%(component)s/Contents-source"
+        BaseFileWriter.__init__(self, template, **flags)
+
+class PackagesFileWriter(BaseFileWriter):
+    def __init__(self, **keywords):
+        '''
+        The value of the keywords suite, component, debtype and architecture
+        are strings.  Output files are gzip compressed only.
+        '''
+        flags = {
+            'uncompressed': False,
+            'gzip':         True,
+            'bzip2':        True
+        }
+        flags.update(keywords)
+        if flags['debtype'] == 'deb':
+            template = "dists/%(suite)s/%(component)s/binary-%(architecture)s/Packages"
+        else: # udeb
+            template = "dists/%(suite)s/%(component)s/debian-installer/binary-%(architecture)s/Packages"
+        BaseFileWriter.__init__(self, template, **flags)
+
+class SourcesFileWriter(BaseFileWriter):
+    def __init__(self, **keywords):
+        '''
+        The value of the keywords suite and component are strings. Output
+        files are gzip compressed only.
+        '''
+        flags = {
+            'uncompressed': False,
+            'gzip':         True,
+            'bzip2':        True
+        }
+        flags.update(keywords)
+        template = "dists/%(suite)s/%(component)s/source/Sources"
         BaseFileWriter.__init__(self, template, **flags)