[elbe-devel] [PATCH v3] pbuilder: fix package build with local dependency

bage at linutronix.de bage at linutronix.de
Fri Mar 15 16:06:32 CET 2019


From: Bastian Germann <bage at linutronix.de>

f8dd2f15f57e (Replace gpgme with maintained gpg module) switched from using
pygpgme to pyme (on jessie). However pyme has an upstream bug which is
documented at https://sourceforge.net/p/pyme/bugs/9/

Unfortunately this was never fixed in Debian.
It causes the public key export of the projectrepo to fail. Therefore
pbuilder refuses to install build-dependencies from the projectrepo.
Additionally it causes elbe sign to fail.

Work around the bug by avoiding the pyme.core.Data(file=filedescriptor)
constructor. pyme.core.Data(file=filename) is fine for reading data;
it cannot be used for writing.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/egpg.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/elbepack/egpg.py b/elbepack/egpg.py
index 019cdefa..32b07402 100644
--- a/elbepack/egpg.py
+++ b/elbepack/egpg.py
@@ -167,8 +167,12 @@ def sign(infile, outfile, fingerprint):
 
     try:
         indata = core.Data(file=infile)
-        outdata = core.Data(file=outfile)
+        outdata = core.Data()
         ctx.op_sign(indata, outdata, sig.mode.NORMAL)
+        outdata.seek(0, os.SEEK_SET)
+        signature = outdata.read()
+        with open(outfile, 'w') as fd:
+            fd.write(signature)
     except Exception as ex:
         print("Error signing file %s" % ex.message)
 
@@ -177,9 +181,7 @@ def sign_file(fname, fingerprint):
     outfilename = fname + '.gpg'
 
     try:
-        with open(fname, 'r') as infile:
-            with open(outfilename, 'w') as outfile:
-                sign(infile, outfile, fingerprint)
+        sign(fname, outfilename, fingerprint)
     except Exception as ex:
         print("Error signing file %s" % ex.message)
 
@@ -210,7 +212,11 @@ def export_key(fingerprint, outfile):
     ctx.set_armor(True)
 
     try:
-        ctx.op_export(fingerprint, 0, outfile)
+        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))
 
-- 
2.11.0




More information about the elbe-devel mailing list