]> git.decadent.org.uk Git - dak.git/blobdiff - dak/check_archive.py
Add missing checksums for source packages.
[dak.git] / dak / check_archive.py
index 1fb8560baaa628bb61abec14f56adce4094b50ac..3e537d805c1073d811c9ac9a1edbc1ed6a24885b 100755 (executable)
@@ -72,6 +72,7 @@ The following MODEs are available:
   validate-indices   - ensure files mentioned in Packages & Sources exist
   files-not-symlinks - check files in the database aren't symlinks
   validate-builddeps - validate build-dependencies of .dsc files in the archive
+  add-missing-source-checksums - add missing checksums for source packages
 """
     sys.exit(exit_code)
 
@@ -164,7 +165,7 @@ def check_dscs():
         except CantOpenError:
             utils.warn("missing dsc file (%s)" % f)
             count += 1
-        except Exception, e:
+        except Exception as e:
             utils.warn("miscellaneous error parsing dsc file (%s): %s" % (f, str(e)))
             count += 1
 
@@ -478,6 +479,17 @@ def check_build_depends():
 
 ################################################################################
 
+def add_missing_source_checksums():
+    """ Add missing source checksums to source_metadata """
+    session = DBConn().session()
+    for checksum in ['Files', 'Checksums-Sha1', 'Checksums-Sha256']:
+        rows = session.execute('SELECT source_metadata_add_missing_checksum(:type)', {'type': checksum}).scalar()
+        if rows > 0:
+            print "Added {0} missing entries for {1}".format(rows, checksum)
+    session.commit()
+
+################################################################################
+
 def main ():
     global db_files, waste, excluded
 
@@ -525,6 +537,8 @@ def main ():
         check_files_not_symlinks()
     elif mode == "validate-builddeps":
         check_build_depends()
+    elif mode == "add-missing-source-checksums":
+        add_missing_source_checksums()
     else:
         utils.warn("unknown mode '%s'" % (mode))
         usage(1)