]> git.decadent.org.uk Git - dak.git/commitdiff
dak admin: add forget-signature subcommand
authorAnsgar Burchardt <ansgar@debian.org>
Sun, 3 Aug 2014 15:03:32 +0000 (17:03 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Sun, 3 Aug 2014 15:40:55 +0000 (17:40 +0200)
The forget-signature command removes the entry for a given file from
the signature_history. This allows reprocessing the file.

dak/admin.py

index da8669895f345044ef5430f27dccfaa192c7bf13..43e20ecfe9209b6f87c2237e8a620f650740618a 100755 (executable)
@@ -24,6 +24,7 @@ import sys
 import apt_pkg
 
 import daklib.archive
+import daklib.gpg
 
 from daklib import utils
 from daklib.dbconn import *
@@ -143,6 +144,8 @@ Perform administrative work on the dak database.
      change-component SUITE COMPONENT binary BINARY...
          Move source or binary packages to a different component by copying
          associated files and changing the overrides.
+
+  forget-signature FILE:    forget that we saw FILE
 """
     sys.exit(exit_code)
 
@@ -927,6 +930,26 @@ dispatch['change-component'] = change_component
 
 ################################################################################
 
+def forget_signature(args):
+    filename = args[1]
+    with open(filename, 'r') as fh:
+        data = fh.read()
+
+    session = DBConn().session()
+    keyrings = [ k.keyring_name for k in session.query(Keyring).filter_by(active=True).order_by(Keyring.priority) ]
+    signed_file = daklib.gpg.SignedFile(data, keyrings)
+    history = SignatureHistory.from_signed_file(signed_file).query(session)
+    if history is not None:
+        session.delete(history)
+        session.commit()
+    else:
+        print "Signature was not known to dak."
+    session.rollback()
+
+dispatch['forget-signature'] = forget_signature
+
+################################################################################
+
 def main():
     """Perform administrative work on the dak database"""
     global dryrun