blob: e5057b7799125ea9e612be30a1e89f059a10b39c [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# Class for generating signed IPK packages.
2#
3# Configuration variables used by this class:
4# IPK_GPG_PASSPHRASE_FILE
5# Path to a file containing the passphrase of the signing key.
6# IPK_GPG_NAME
7# Name of the key to sign with.
8# IPK_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.
12# IPK_GPG_SIGNATURE_TYPE
13# Optional variable for specifying the type of gpg signatures, can be:
14# 1. Ascii armored (ASC), default if not set
15# 2. Binary (BIN)
16# GPG_BIN
17# Optional variable for specifying the gpg binary/wrapper to use for
18# signing.
19# GPG_PATH
20# Optional variable for specifying the gnupg "home" directory:
21#
22
23inherit sanity
24
25IPK_SIGN_PACKAGES = '1'
26IPK_GPG_BACKEND ?= 'local'
27IPK_GPG_SIGNATURE_TYPE ?= 'ASC'
28
29python () {
30 # Check configuration
31 for var in ('IPK_GPG_NAME', 'IPK_GPG_PASSPHRASE_FILE'):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 if not d.getVar(var):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 raise_sanity_error("You need to define %s in the config" % var, d)
34
Brad Bishop6e60e8b2018-02-01 10:27:11 -050035 sigtype = d.getVar("IPK_GPG_SIGNATURE_TYPE")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050036 if sigtype.upper() != "ASC" and sigtype.upper() != "BIN":
37 raise_sanity_error("Bad value for IPK_GPG_SIGNATURE_TYPE (%s), use either ASC or BIN" % sigtype)
38}
39
40def sign_ipk(d, ipk_to_sign):
41 from oe.gpg_sign import get_signer
42
43 bb.debug(1, 'Signing ipk: %s' % ipk_to_sign)
44
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045 signer = get_signer(d, d.getVar('IPK_GPG_BACKEND'))
46 sig_type = d.getVar('IPK_GPG_SIGNATURE_TYPE')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047 is_ascii_sig = (sig_type.upper() != "BIN")
48
49 signer.detach_sign(ipk_to_sign,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 d.getVar('IPK_GPG_NAME'),
51 d.getVar('IPK_GPG_PASSPHRASE_FILE'),
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050052 armor=is_ascii_sig)