sign_rpm.bbclass 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. # Class for generating signed RPM packages.
  7. #
  8. # Configuration variables used by this class:
  9. # RPM_GPG_PASSPHRASE
  10. # The passphrase of the signing key.
  11. # RPM_GPG_NAME
  12. # Name of the key to sign with. May be key id or key name.
  13. # RPM_GPG_BACKEND
  14. # Optional variable for specifying the backend to use for signing.
  15. # Currently the only available option is 'local', i.e. local signing
  16. # on the build host.
  17. # RPM_FILE_CHECKSUM_DIGEST
  18. # Optional variable for specifying the algorithm for generating file
  19. # checksum digest.
  20. # RPM_FSK_PATH
  21. # Optional variable for the file signing key.
  22. # RPM_FSK_PASSWORD
  23. # Optional variable for the file signing key password.
  24. # GPG_BIN
  25. # Optional variable for specifying the gpg binary/wrapper to use for
  26. # signing.
  27. # RPM_GPG_SIGN_CHUNK
  28. # Optional variable indicating the number of packages used per gpg
  29. # invocation
  30. # GPG_PATH
  31. # Optional variable for specifying the gnupg "home" directory:
  32. inherit sanity
  33. RPM_SIGN_PACKAGES='1'
  34. RPM_SIGN_FILES ?= '0'
  35. RPM_GPG_BACKEND ?= 'local'
  36. # SHA-256 is used by default
  37. RPM_FILE_CHECKSUM_DIGEST ?= '8'
  38. RPM_GPG_SIGN_CHUNK ?= "${BB_NUMBER_THREADS}"
  39. python () {
  40. if d.getVar('RPM_GPG_PASSPHRASE_FILE'):
  41. raise_sanity_error('RPM_GPG_PASSPHRASE_FILE is replaced by RPM_GPG_PASSPHRASE', d)
  42. # Check configuration
  43. for var in ('RPM_GPG_NAME', 'RPM_GPG_PASSPHRASE'):
  44. if not d.getVar(var):
  45. raise_sanity_error("You need to define %s in the config" % var, d)
  46. if d.getVar('RPM_SIGN_FILES') == '1':
  47. for var in ('RPM_FSK_PATH', 'RPM_FSK_PASSWORD'):
  48. if not d.getVar(var):
  49. raise_sanity_error("You need to define %s in the config" % var, d)
  50. }
  51. python sign_rpm () {
  52. import glob
  53. from oe.gpg_sign import get_signer
  54. signer = get_signer(d, d.getVar('RPM_GPG_BACKEND'))
  55. rpms = glob.glob(d.getVar('RPM_PKGWRITEDIR') + '/*')
  56. signer.sign_rpms(rpms,
  57. d.getVar('RPM_GPG_NAME'),
  58. d.getVar('RPM_GPG_PASSPHRASE'),
  59. d.getVar('RPM_FILE_CHECKSUM_DIGEST'),
  60. int(d.getVar('RPM_GPG_SIGN_CHUNK')),
  61. d.getVar('RPM_FSK_PATH'),
  62. d.getVar('RPM_FSK_PASSWORD'))
  63. }
  64. sign_rpm[vardepsexclude] += "RPM_GPG_SIGN_CHUNK"
  65. do_package_index[depends] += "signing-keys:do_deploy"
  66. do_rootfs[depends] += "signing-keys:do_populate_sysroot"
  67. PACKAGE_WRITE_DEPS += "gnupg-native"