[elbe-devel] [PATCH v2] egpg: use gpg executable to export keys
Manuel Traut
manut at linutronix.de
Thu Apr 4 09:44:19 CEST 2019
The python-gpg bindings return the exported key in the keybox format.
python-pyme seemed to return it in gpg format.
The key is needed in gpg format for apt-key add.
I see now method to export the key in gpg format with python-gpg.
Therefore call the 'gpg' command to export they key.
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
changes since v1: use shellhelper, and fshelper
elbepack/egpg.py | 15 ++-------------
elbepack/repomanager.py | 8 +++-----
2 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/elbepack/egpg.py b/elbepack/egpg.py
index 7c3827cf..1da1553c 100644
--- a/elbepack/egpg.py
+++ b/elbepack/egpg.py
@@ -216,17 +216,6 @@ def generate_elbe_internal_key():
def export_key(fingerprint, outfile):
- os.environ['GNUPGHOME'] = "/var/cache/elbe/gnupg"
- ctx = core.Context()
- ctx.set_armor(True)
-
- try:
- outdata = core.Data()
- ctx.op_export(fingerprint, 0, outdata)
- outdata.seek(0, os.SEEK_SET)
- key = outdata.read()
- outfile.write(key)
- except Exception:
- print("Error exporting key %s" % (fingerprint))
-
+ system("/usr/bin/gpg -a -o %s --export %s" % (outfile, fingerprint),
+ env_add={"GNUPGHOME": "/var/cache/elbe/gnupg"})
return '/var/cache/elbe/gnupg/pubring.kbx'
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index 19a481ab..8898d4d2 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -159,11 +159,9 @@ class RepoBase(object):
fp.write("\n")
fp.close()
- with self.fs.open("repo.pub", "w") as pubkey_fp:
- keyring = export_key(self.keyid, pubkey_fp)
- if keyring:
- shutil.copyfile(keyring, os.path.join(self.fs.path,
- "elbe-keyring.gpg"))
+ keyring = export_key(self.keyid, self.fs.fname("/repo.pub"))
+ if keyring:
+ shutil.copyfile(keyring, self.fs.fname("/elbe-keyring.gpg"))
if need_update:
self.log.do(
--
2.20.1
More information about the elbe-devel
mailing list