Mercurial > treepkg
changeset 166:61fd2892b80b
Add a function to sign a debian .dsc or .control file
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Fri, 20 Jun 2008 14:54:27 +0000 |
parents | c7ac67366492 |
children | 36004ee0b3a1 |
files | treepkg/debian.py |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/treepkg/debian.py Fri Jun 20 14:40:29 2008 +0000 +++ b/treepkg/debian.py Fri Jun 20 14:54:27 2008 +0000 @@ -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)