diff options
Diffstat (limited to 'meta/classes/sign_ipk.bbclass')
-rw-r--r-- | meta/classes/sign_ipk.bbclass | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/meta/classes/sign_ipk.bbclass b/meta/classes/sign_ipk.bbclass new file mode 100644 index 0000000000..a481f6d9a8 --- /dev/null +++ b/meta/classes/sign_ipk.bbclass | |||
@@ -0,0 +1,52 @@ | |||
1 | # 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 | |||
23 | inherit sanity | ||
24 | |||
25 | IPK_SIGN_PACKAGES = '1' | ||
26 | IPK_GPG_BACKEND ?= 'local' | ||
27 | IPK_GPG_SIGNATURE_TYPE ?= 'ASC' | ||
28 | |||
29 | python () { | ||
30 | # Check configuration | ||
31 | for var in ('IPK_GPG_NAME', 'IPK_GPG_PASSPHRASE_FILE'): | ||
32 | if not d.getVar(var, True): | ||
33 | raise_sanity_error("You need to define %s in the config" % var, d) | ||
34 | |||
35 | sigtype = d.getVar("IPK_GPG_SIGNATURE_TYPE", True) | ||
36 | 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 | |||
40 | def 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 | |||
45 | signer = get_signer(d, d.getVar('IPK_GPG_BACKEND', True)) | ||
46 | sig_type = d.getVar('IPK_GPG_SIGNATURE_TYPE', True) | ||
47 | is_ascii_sig = (sig_type.upper() != "BIN") | ||
48 | |||
49 | signer.detach_sign(ipk_to_sign, | ||
50 | d.getVar('IPK_GPG_NAME', True), | ||
51 | d.getVar('IPK_GPG_PASSPHRASE_FILE', True), | ||
52 | armor=is_ascii_sig) | ||