summaryrefslogtreecommitdiffstats
path: root/meta/classes/sign_rpm.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/sign_rpm.bbclass')
-rw-r--r--meta/classes/sign_rpm.bbclass30
1 files changed, 9 insertions, 21 deletions
diff --git a/meta/classes/sign_rpm.bbclass b/meta/classes/sign_rpm.bbclass
index 39f877a23c..4da17633a7 100644
--- a/meta/classes/sign_rpm.bbclass
+++ b/meta/classes/sign_rpm.bbclass
@@ -4,8 +4,7 @@
4# RPM_GPG_PASSPHRASE_FILE 4# RPM_GPG_PASSPHRASE_FILE
5# Path to a file containing the passphrase of the signing key. 5# Path to a file containing the passphrase of the signing key.
6# RPM_GPG_NAME 6# RPM_GPG_NAME
7# Name of the key to sign with. Alternatively you can define 7# Name of the key to sign with. May be key id or key name.
8# %_gpg_name macro in your ~/.oerpmmacros file.
9# RPM_GPG_PUBKEY 8# RPM_GPG_PUBKEY
10# Path to a file containing the public key (in "armor" format) 9# Path to a file containing the public key (in "armor" format)
11# corresponding the signing key. 10# corresponding the signing key.
@@ -20,9 +19,11 @@ inherit sanity
20RPM_SIGN_PACKAGES='1' 19RPM_SIGN_PACKAGES='1'
21 20
22 21
23_check_gpg_name () { 22python () {
24 macrodef=`rpm -E '%_gpg_name'` 23 # Check configuration
25 [ "$macrodef" == "%_gpg_name" ] && return 1 || return 0 24 for var in ('RPM_GPG_NAME', 'RPM_GPG_PASSPHRASE_FILE'):
25 if not d.getVar(var, True):
26 raise_sanity_error("You need to define %s in the config" % var, d)
26} 27}
27 28
28 29
@@ -31,16 +32,7 @@ def rpmsign_wrapper(d, files, passphrase, gpg_name=None):
31 32
32 # Find the correct rpm binary 33 # Find the correct rpm binary
33 rpm_bin_path = d.getVar('STAGING_BINDIR_NATIVE', True) + '/rpm' 34 rpm_bin_path = d.getVar('STAGING_BINDIR_NATIVE', True) + '/rpm'
34 cmd = rpm_bin_path + " --addsign " 35 cmd = rpm_bin_path + " --addsign --define '_gpg_name %s' " % gpg_name
35 if gpg_name:
36 cmd += "--define '%%_gpg_name %s' " % gpg_name
37 else:
38 try:
39 bb.build.exec_func('_check_gpg_name', d)
40 except bb.build.FuncFailed:
41 raise_sanity_error("You need to define RPM_GPG_NAME in bitbake "
42 "config or the %_gpg_name RPM macro defined "
43 "(e.g. in ~/.oerpmmacros", d)
44 if d.getVar('GPG_BIN', True): 36 if d.getVar('GPG_BIN', True):
45 cmd += "--define '%%__gpg %s' " % d.getVar('GPG_BIN', True) 37 cmd += "--define '%%__gpg %s' " % d.getVar('GPG_BIN', True)
46 if d.getVar('GPG_PATH', True): 38 if d.getVar('GPG_PATH', True):
@@ -66,12 +58,8 @@ def rpmsign_wrapper(d, files, passphrase, gpg_name=None):
66python sign_rpm () { 58python sign_rpm () {
67 import glob 59 import glob
68 60
69 rpm_gpg_pass_file = (d.getVar("RPM_GPG_PASSPHRASE_FILE", True) or "") 61 with open(d.getVar("RPM_GPG_PASSPHRASE_FILE", True)) as fobj:
70 if rpm_gpg_pass_file: 62 rpm_gpg_passphrase = fobj.readlines()[0].rstrip('\n')
71 with open(rpm_gpg_pass_file) as fobj:
72 rpm_gpg_passphrase = fobj.readlines()[0].rstrip('\n')
73 else:
74 raise_sanity_error("You need to define RPM_GPG_PASSPHRASE_FILE in the config", d)
75 63
76 rpm_gpg_name = (d.getVar("RPM_GPG_NAME", True) or "") 64 rpm_gpg_name = (d.getVar("RPM_GPG_NAME", True) or "")
77 65