Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | # Class for generating signed RPM packages. |
| 8 | # |
| 9 | # Configuration variables used by this class: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10 | # RPM_GPG_PASSPHRASE |
| 11 | # The passphrase of the signing key. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | # RPM_GPG_NAME |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 13 | # Name of the key to sign with. May be key id or key name. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 14 | # 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 18 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | # GPG_BIN |
| 26 | # Optional variable for specifying the gpg binary/wrapper to use for |
| 27 | # signing. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | # RPM_GPG_SIGN_CHUNK |
| 29 | # Optional variable indicating the number of packages used per gpg |
| 30 | # invocation |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 31 | # GPG_PATH |
| 32 | # Optional variable for specifying the gnupg "home" directory: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 33 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | inherit sanity |
| 35 | |
| 36 | RPM_SIGN_PACKAGES='1' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 37 | RPM_SIGN_FILES ?= '0' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 38 | RPM_GPG_BACKEND ?= 'local' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 39 | # SHA-256 is used by default |
| 40 | RPM_FILE_CHECKSUM_DIGEST ?= '8' |
| 41 | RPM_GPG_SIGN_CHUNK ?= "${BB_NUMBER_THREADS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | |
| 43 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 44 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 45 | if d.getVar('RPM_GPG_PASSPHRASE_FILE'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 46 | raise_sanity_error('RPM_GPG_PASSPHRASE_FILE is replaced by RPM_GPG_PASSPHRASE', d) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 47 | # Check configuration |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 48 | for var in ('RPM_GPG_NAME', 'RPM_GPG_PASSPHRASE'): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | if not d.getVar(var): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 50 | raise_sanity_error("You need to define %s in the config" % var, d) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 51 | |
| 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | } |
| 57 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | python sign_rpm () { |
| 59 | import glob |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 60 | from oe.gpg_sign import get_signer |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 62 | signer = get_signer(d, d.getVar('RPM_GPG_BACKEND')) |
| 63 | rpms = glob.glob(d.getVar('RPM_PKGWRITEDIR') + '/*') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 65 | signer.sign_rpms(rpms, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | d.getVar('RPM_GPG_NAME'), |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 67 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | } |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 73 | sign_rpm[vardepsexclude] += "RPM_GPG_SIGN_CHUNK" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 74 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 75 | do_package_index[depends] += "signing-keys:do_deploy" |
| 76 | do_rootfs[depends] += "signing-keys:do_populate_sysroot" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 77 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 78 | PACKAGE_WRITE_DEPS += "gnupg-native" |