[Treepkg-commits] r91 - trunk/treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jun 20 16:54:28 CEST 2008


Author: bh
Date: 2008-06-20 16:54:27 +0200 (Fri, 20 Jun 2008)
New Revision: 91

Modified:
   trunk/treepkg/debian.py
Log:
Add a function to sign a debian .dsc or .control file


Modified: trunk/treepkg/debian.py
===================================================================
--- trunk/treepkg/debian.py	2008-06-20 14:40:29 UTC (rev 90)
+++ trunk/treepkg/debian.py	2008-06-20 14:54:27 UTC (rev 91)
@@ -7,7 +7,10 @@
 
 """Support code for debian packages"""
 
+import os
+
 from treepkg.util import extract_value_for_key
+import treepkg.run
 
 
 class DebianControlFile(object):
@@ -54,3 +57,20 @@
         arch = extract_value_for_key(paragraph, "Architecture:")
         self.packages.append((package_name, arch))
 
+
+
+def sign_file(filename, keyid):
+    """Signs a debian .dsc or .control file"""
+    contents = open(filename).read()
+
+    # make sure contents ends with an empty line.  The signed files have
+    # to have an empty line before the OpenPGP signature block
+    if not contents.endswith("\n"):
+        contents += "\n"
+    contents += "\n"
+
+    asc_file = filename + ".asc"
+    treepkg.run.call(["gpg", "--clearsign", "--armor", "--textmode",
+                      "--local-user", keyid, "-o", asc_file, "-"],
+                     inputdata=contents, suppress_output=True)
+    os.rename(asc_file, filename)



More information about the Treepkg-commits mailing list