]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blobdiff - modules/sign.py
pexpect needs explicit encoding when run under python3
[projects/pld-ftp-admin.git] / modules / sign.py
index 2a23e9c1678d95edbafe3f77eae2241f8c468031..ef9e814b5d8c01b5353984585539796964f9a44d 100644 (file)
@@ -27,7 +27,7 @@ def is_signed(rpm_file):
         return None
 
     ts = rpm.ts()
-    ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
+    ts.setVSFlags(rpm.RPMVSF_NODSAHEADER)
     fdno = os.open(rpm_file, os.O_RDONLY)
     hdr = ts.hdrFromFdno(fdno)
     os.close(fdno)
@@ -40,13 +40,13 @@ 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)
@@ -54,4 +54,6 @@ def signpkgs(files, password):
     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, 0o644)
This page took 0.06159 seconds and 4 git commands to generate.