blob: ee0c4808fa121ce4342f40b68f3b45041601a614 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007# Class for generating signed RPM packages.
8#
9# Configuration variables used by this class:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050010# RPM_GPG_PASSPHRASE
11# The passphrase of the signing key.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012# RPM_GPG_NAME
Patrick Williamsf1e5d692016-03-30 15:21:19 -050013# Name of the key to sign with. May be key id or key name.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050014# RPM_GPG_BACKEND
15# Optional variable for specifying the backend to use for signing.
16# Currently the only available option is 'local', i.e. local signing
17# on the build host.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018# RPM_FILE_CHECKSUM_DIGEST
19# Optional variable for specifying the algorithm for generating file
20# checksum digest.
21# RPM_FSK_PATH
22# Optional variable for the file signing key.
23# RPM_FSK_PASSWORD
24# Optional variable for the file signing key password.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025# GPG_BIN
26# Optional variable for specifying the gpg binary/wrapper to use for
27# signing.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050028# RPM_GPG_SIGN_CHUNK
29# Optional variable indicating the number of packages used per gpg
30# invocation
Patrick Williamsf1e5d692016-03-30 15:21:19 -050031# GPG_PATH
32# Optional variable for specifying the gnupg "home" directory:
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034inherit sanity
35
36RPM_SIGN_PACKAGES='1'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050037RPM_SIGN_FILES ?= '0'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038RPM_GPG_BACKEND ?= 'local'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050039# SHA-256 is used by default
40RPM_FILE_CHECKSUM_DIGEST ?= '8'
41RPM_GPG_SIGN_CHUNK ?= "${BB_NUMBER_THREADS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042
43
Patrick Williamsf1e5d692016-03-30 15:21:19 -050044python () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045 if d.getVar('RPM_GPG_PASSPHRASE_FILE'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046 raise_sanity_error('RPM_GPG_PASSPHRASE_FILE is replaced by RPM_GPG_PASSPHRASE', d)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050047 # Check configuration
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048 for var in ('RPM_GPG_NAME', 'RPM_GPG_PASSPHRASE'):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049 if not d.getVar(var):
Patrick Williamsf1e5d692016-03-30 15:21:19 -050050 raise_sanity_error("You need to define %s in the config" % var, d)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050051
52 if d.getVar('RPM_SIGN_FILES') == '1':
53 for var in ('RPM_FSK_PATH', 'RPM_FSK_PASSWORD'):
54 if not d.getVar(var):
55 raise_sanity_error("You need to define %s in the config" % var, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056}
57
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058python sign_rpm () {
59 import glob
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050060 from oe.gpg_sign import get_signer
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 signer = get_signer(d, d.getVar('RPM_GPG_BACKEND'))
63 rpms = glob.glob(d.getVar('RPM_PKGWRITEDIR') + '/*')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050065 signer.sign_rpms(rpms,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 d.getVar('RPM_GPG_NAME'),
Brad Bishopd7bf8c12018-02-25 22:55:05 -050067 d.getVar('RPM_GPG_PASSPHRASE'),
68 d.getVar('RPM_FILE_CHECKSUM_DIGEST'),
69 int(d.getVar('RPM_GPG_SIGN_CHUNK')),
70 d.getVar('RPM_FSK_PATH'),
71 d.getVar('RPM_FSK_PASSWORD'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072}
Andrew Geisslerd25ed322020-06-27 00:28:28 -050073sign_rpm[vardepsexclude] += "RPM_GPG_SIGN_CHUNK"
Patrick Williamsf1e5d692016-03-30 15:21:19 -050074
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050075do_package_index[depends] += "signing-keys:do_deploy"
76do_rootfs[depends] += "signing-keys:do_populate_sysroot"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050077
Brad Bishop316dfdd2018-06-25 12:45:53 -040078PACKAGE_WRITE_DEPS += "gnupg-native"