blob: a8ea75faaa9429cfe5ae3a51a7b46c3f5c03507b [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Class for generating signed RPM packages.
2#
3# Configuration variables used by this class:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05004# RPM_GPG_PASSPHRASE
5# The passphrase of the signing key.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006# RPM_GPG_NAME
Patrick Williamsf1e5d692016-03-30 15:21:19 -05007# Name of the key to sign with. May be key id or key name.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008# RPM_GPG_BACKEND
9# Optional variable for specifying the backend to use for signing.
10# Currently the only available option is 'local', i.e. local signing
11# on the build host.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012# GPG_BIN
13# Optional variable for specifying the gpg binary/wrapper to use for
14# signing.
Patrick Williamsf1e5d692016-03-30 15:21:19 -050015# GPG_PATH
16# Optional variable for specifying the gnupg "home" directory:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017#
18inherit sanity
19
20RPM_SIGN_PACKAGES='1'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050021RPM_GPG_BACKEND ?= 'local'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022
23
Patrick Williamsf1e5d692016-03-30 15:21:19 -050024python () {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050025 if d.getVar('RPM_GPG_PASSPHRASE_FILE', True):
26 raise_sanity_error('RPM_GPG_PASSPHRASE_FILE is replaced by RPM_GPG_PASSPHRASE', d)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050027 # Check configuration
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050028 for var in ('RPM_GPG_NAME', 'RPM_GPG_PASSPHRASE'):
Patrick Williamsf1e5d692016-03-30 15:21:19 -050029 if not d.getVar(var, True):
30 raise_sanity_error("You need to define %s in the config" % var, d)
31
32 # Set the expected location of the public key
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 d.setVar('RPM_GPG_PUBKEY', os.path.join(d.getVar('STAGING_DIR_TARGET', False),
34 d.getVar('sysconfdir', False),
35 'pki',
36 'rpm-gpg',
37 'RPM-GPG-KEY-${DISTRO_VERSION}'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038}
39
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040python sign_rpm () {
41 import glob
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042 from oe.gpg_sign import get_signer
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044 signer = get_signer(d, d.getVar('RPM_GPG_BACKEND', True))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 rpms = glob.glob(d.getVar('RPM_PKGWRITEDIR', True) + '/*')
46
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047 signer.sign_rpms(rpms,
48 d.getVar('RPM_GPG_NAME', True),
49 d.getVar('RPM_GPG_PASSPHRASE', True))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050051
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050052do_package_index[depends] += "signing-keys:do_deploy"
53do_rootfs[depends] += "signing-keys:do_populate_sysroot"