[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] dak admin: add forget-signature subcommand



The forget-signature command removes the entry for a given file from
the signature_history. This allows reprocessing the file.
---
 dak/admin.py |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/dak/admin.py b/dak/admin.py
index da86698..43e20ec 100755
--- a/dak/admin.py
+++ b/dak/admin.py
@@ -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
-- 
1.7.10.4



Reply to: