sign_ipk.bbclass 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. # Class for generating signed IPK packages.
  7. #
  8. # Configuration variables used by this class:
  9. # IPK_GPG_PASSPHRASE_FILE
  10. # Path to a file containing the passphrase of the signing key.
  11. # IPK_GPG_NAME
  12. # Name of the key to sign with.
  13. # IPK_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. # IPK_GPG_SIGNATURE_TYPE
  18. # Optional variable for specifying the type of gpg signatures, can be:
  19. # 1. Ascii armored (ASC), default if not set
  20. # 2. Binary (BIN)
  21. # GPG_BIN
  22. # Optional variable for specifying the gpg binary/wrapper to use for
  23. # signing.
  24. # GPG_PATH
  25. # Optional variable for specifying the gnupg "home" directory:
  26. #
  27. inherit sanity
  28. IPK_SIGN_PACKAGES = '1'
  29. IPK_GPG_BACKEND ?= 'local'
  30. IPK_GPG_SIGNATURE_TYPE ?= 'ASC'
  31. python () {
  32. # Check configuration
  33. for var in ('IPK_GPG_NAME', 'IPK_GPG_PASSPHRASE_FILE'):
  34. if not d.getVar(var):
  35. raise_sanity_error("You need to define %s in the config" % var, d)
  36. sigtype = d.getVar("IPK_GPG_SIGNATURE_TYPE")
  37. if sigtype.upper() != "ASC" and sigtype.upper() != "BIN":
  38. raise_sanity_error("Bad value for IPK_GPG_SIGNATURE_TYPE (%s), use either ASC or BIN" % sigtype)
  39. }
  40. def sign_ipk(d, ipk_to_sign):
  41. from oe.gpg_sign import get_signer
  42. bb.debug(1, 'Signing ipk: %s' % ipk_to_sign)
  43. signer = get_signer(d, d.getVar('IPK_GPG_BACKEND'))
  44. sig_type = d.getVar('IPK_GPG_SIGNATURE_TYPE')
  45. is_ascii_sig = (sig_type.upper() != "BIN")
  46. signer.detach_sign(ipk_to_sign,
  47. d.getVar('IPK_GPG_NAME'),
  48. d.getVar('IPK_GPG_PASSPHRASE_FILE'),
  49. armor=is_ascii_sig)