summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/gpg_sign.py
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-03-21 02:25:50 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-25 10:29:14 +0000
commit3e5c5fe330b6a48c53ce9715abaae4250201e1a2 (patch)
tree7ae6839b16bc860628e75f480c5c21e60dcc9d3c /meta/lib/oe/gpg_sign.py
parent05d7e0db5d1de2643284edf7fccaf47616145bd6 (diff)
downloadpoky-3e5c5fe330b6a48c53ce9715abaae4250201e1a2.tar.gz
gpg_sign.py: get rid of pexpect
The python-expect is not installed on the distro such as Ubuntu by default, and we can get rid of it. Use RPM_GPG_PASSPHRASE to replace of RPM_GPG_PASSPHRASE_FILE which is more straightforward. (From OE-Core rev: 4a8a74c62836a20610daf029d4cec0b3087758b2) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/gpg_sign.py')
-rw-r--r--meta/lib/oe/gpg_sign.py24
1 files changed, 6 insertions, 18 deletions
diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index e738397880..b83ee86728 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -26,32 +26,20 @@ class LocalSigner(object):
26 raise bb.build.FuncFailed('Failed to export gpg public key (%s): %s' % 26 raise bb.build.FuncFailed('Failed to export gpg public key (%s): %s' %
27 (keyid, output)) 27 (keyid, output))
28 28
29 def sign_rpms(self, files, keyid, passphrase_file): 29 def sign_rpms(self, files, keyid, passphrase):
30 """Sign RPM files""" 30 """Sign RPM files"""
31 import pexpect
32 31
33 cmd = self.rpm_bin + " --addsign --define '_gpg_name %s' " % keyid 32 cmd = self.rpm_bin + " --addsign --define '_gpg_name %s' " % keyid
33 cmd += "--define '_gpg_passphrase %s' " % passphrase
34 if self.gpg_bin: 34 if self.gpg_bin:
35 cmd += "--define '%%__gpg %s' " % self.gpg_bin 35 cmd += "--define '%%__gpg %s' " % self.gpg_bin
36 if self.gpg_path: 36 if self.gpg_path:
37 cmd += "--define '_gpg_path %s' " % self.gpg_path 37 cmd += "--define '_gpg_path %s' " % self.gpg_path
38 cmd += ' '.join(files) 38 cmd += ' '.join(files)
39 39
40 # Need to use pexpect for feeding the passphrase 40 status, output = oe.utils.getstatusoutput(cmd)
41 proc = pexpect.spawn(cmd) 41 if status:
42 try: 42 raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output)
43 proc.expect_exact('Enter pass phrase:', timeout=15)
44 with open(passphrase_file) as fobj:
45 proc.sendline(fobj.readline().rstrip('\n'))
46 proc.expect(pexpect.EOF, timeout=900)
47 proc.close()
48 except pexpect.TIMEOUT as err:
49 bb.error('rpmsign timeout: %s' % err)
50 proc.terminate()
51 if os.WEXITSTATUS(proc.status) or not os.WIFEXITED(proc.status):
52 bb.error('rpmsign failed: %s' % proc.before.strip())
53 raise bb.build.FuncFailed("Failed to sign RPM packages")
54
55 43
56 def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True): 44 def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True):
57 """Create a detached signature of a file""" 45 """Create a detached signature of a file"""