]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blobdiff - modules/sign.py
Support for split debugsource packaes
[projects/pld-ftp-admin.git] / modules / sign.py
index 522af24699b91970b70af62a5fa5d73b0c207413..dc5cc4fac964a25fd66e362251a6a8d829b60c5e 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
 import os
@@ -27,6 +27,7 @@ def is_signed(rpm_file):
         return None
 
     ts = rpm.ts()
+    ts.setVSFlags(rpm.RPMVSF_NODSAHEADER)
     fdno = os.open(rpm_file, os.O_RDONLY)
     hdr = ts.hdrFromFdno(fdno)
     os.close(fdno)
@@ -39,20 +40,24 @@ def is_signed(rpm_file):
 
 def signpkgs(files, password):
     if not os.path.isfile('/usr/bin/gpg'):
-        raise OSError, 'Missing gnupg binary'
+        raise OSError('Missing gnupg binary')
     if not os.path.isfile('/bin/rpm'):
-        raise OSError, 'Missing rpm binary'
+        raise OSError('Missing rpm binary')
 
     os.putenv('LC_ALL', 'C')
     args = ['--resign', '--define', '_signature gpg', '--define', '_gpg_name ' + sign_key] + files
-    child = pexpect.spawn('/bin/rpm', args)
+    child = pexpect.spawn('/bin/rpm', args, encoding='utf-8')
     child.logfile_read = sys.stderr
-    child.expect('Enter pass phrase:', timeout=30)
-    child.sendline(password)
+    # TODO: we need a smarter way to figuring out if rpm already stored password in gpg-agent
+    try:
+        child.expect(u'Enter pass phrase:', timeout=30)
+        child.sendline(password)
+    except pexpect.exceptions.TIMEOUT:
+        print('WARN: rpm did not ask for password', file=sys.stderr)
     child.expect(pexpect.EOF, timeout=None)
     child.close()
     rc = child.exitstatus
     if rc != 0:
-        raise OSError, 'package signing failed'
+        raise OSError('package signing failed')
     for rpm in files:
-        os.chmod(rpm, 0644)
+        os.chmod(rpm, 0o644)
This page took 0.040175 seconds and 4 git commands to generate.