blob: bc2e947107c444a2e4b330849c8df6c42ba8d65c [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 () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 if d.getVar('RPM_GPG_PASSPHRASE_FILE'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050026 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'):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 if not d.getVar(var):
Patrick Williamsf1e5d692016-03-30 15:21:19 -050030 raise_sanity_error("You need to define %s in the config" % var, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031}
32
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033python sign_rpm () {
34 import glob
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050035 from oe.gpg_sign import get_signer
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
Brad Bishop6e60e8b2018-02-01 10:27:11 -050037 signer = get_signer(d, d.getVar('RPM_GPG_BACKEND'))
38 rpms = glob.glob(d.getVar('RPM_PKGWRITEDIR') + '/*')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050040 signer.sign_rpms(rpms,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041 d.getVar('RPM_GPG_NAME'),
42 d.getVar('RPM_GPG_PASSPHRASE'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043}
Patrick Williamsf1e5d692016-03-30 15:21:19 -050044
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050045do_package_index[depends] += "signing-keys:do_deploy"
46do_rootfs[depends] += "signing-keys:do_populate_sysroot"