]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/upload.py
Add by-hash support
[dak.git] / daklib / upload.py
index 2cc70743baba35a3f7ca21da660ee48d225946cd..4c10f45f4e433e36bfd40a40fcff31673f2fc5b9 100644 (file)
@@ -73,12 +73,21 @@ class FileDoesNotExist(UploadException):
 class HashedFile(object):
     """file with checksums
     """
-    def __init__(self, filename, size, md5sum, sha1sum, sha256sum, section=None, priority=None):
+    def __init__(self, filename, size, md5sum, sha1sum, sha256sum, section=None, priority=None, input_filename=None):
         self.filename = filename
         """name of the file
         @type: str
         """
 
+        if input_filename is None:
+            input_filename = filename
+        self.input_filename = input_filename
+        """name of the file on disk
+
+        Used for temporary files that should not be installed using their on-disk name.
+        @type: str
+        """
+
         self.size = size
         """size in bytes
         @type: long
@@ -146,13 +155,13 @@ class HashedFile(object):
 
         @raise InvalidHashException: hash mismatch
         """
-        path = os.path.join(directory, self.filename)
+        path = os.path.join(directory, self.input_filename)
         try:
             with open(path) as fh:
                 self.check_fh(fh)
         except IOError as e:
             if e.errno == errno.ENOENT:
-                raise FileDoesNotExist(self.filename)
+                raise FileDoesNotExist(self.input_filename)
             raise
 
     def check_fh(self, fh):
@@ -365,6 +374,8 @@ class Changes(object):
         for f in self.files.itervalues():
             if re_file_dsc.match(f.filename) or re_file_source.match(f.filename) or re_file_binary.match(f.filename):
                 continue
+            if re_file_buildinfo.match(f.filename):
+                continue
             if f.section != 'byhand' and f.section[:4] != 'raw-':
                 raise InvalidChangesException("{0}: {1} looks like a byhand package, but is in section {2}".format(self.filename, f.filename, f.section))
             byhand.append(f)
@@ -445,7 +456,7 @@ class Binary(object):
         @type: HashedFile
         """
 
-        path = os.path.join(directory, hashed_file.filename)
+        path = os.path.join(directory, hashed_file.input_filename)
         data = apt_inst.DebFile(path).control.extractdata("control")
 
         self.control = apt_pkg.TagSection(data)
@@ -518,7 +529,7 @@ class Source(object):
         # make sure the hash for the dsc is valid before we use it
         self._dsc_file.check(directory)
 
-        dsc_file_path = os.path.join(directory, self._dsc_file.filename)
+        dsc_file_path = os.path.join(directory, self._dsc_file.input_filename)
         data = open(dsc_file_path, 'r').read()
         self._signed_file = SignedFile(data, keyrings, require_signature)
         self.dsc = apt_pkg.TagSection(self._signed_file.contents)