openssl-module.mk 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. #
  3. # Copyright (C) 2022-2023 Enéas Ulir de Queiroz
  4. ENGINES_DIR=engines-3
  5. define Package/openssl/module/Default
  6. SECTION:=libs
  7. CATEGORY:=Libraries
  8. SUBMENU:=SSL
  9. DEPENDS:=libopenssl +libopenssl-conf
  10. endef
  11. define Package/openssl/engine/Default
  12. $(Package/openssl/module/Default)
  13. DEPENDS+=@OPENSSL_ENGINE
  14. endef
  15. # 1 = moudule type (engine|provider)
  16. # 2 = module name
  17. # 3 = directory to save .so file
  18. # 4 = [ package name, defaults to libopenssl-$(2) ]
  19. define Package/openssl/add-module
  20. $(eval MOD_TYPE:=$(1))
  21. $(eval MOD_NAME:=$(2))
  22. $(eval MOD_DIR:=$(3))
  23. $(eval OSSL_PKG:=$(if $(4),$(4),libopenssl-$(MOD_NAME)))
  24. $(info Package/openssl/add-module 1='$(1)'; 2='$(2)'; 3='$(3)' 4='$(4)')
  25. $(info MOD_TYPE='$(MOD_TYPE)'; MOD_NAME='$(MOD_NAME)'; MOD_DIR='$(MOD_DIR)' OSSL_PKG='$(OSSL_PKG)')
  26. Package/$(OSSL_PKG)/conffiles:=/etc/ssl/modules.cnf.d/$(MOD_NAME).cnf
  27. define Package/$(OSSL_PKG)/install
  28. $$(INSTALL_DIR) $$(1)/$(MOD_DIR)
  29. $$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/$(MOD_DIR)/$(MOD_NAME).so \
  30. $$(1)/$(MOD_DIR)
  31. $$(INSTALL_DIR) $$(1)/etc/ssl/modules.cnf.d
  32. $$(INSTALL_DATA) ./files/$(MOD_NAME).cnf $$(1)/etc/ssl/modules.cnf.d/
  33. endef
  34. define Package/$(OSSL_PKG)/postinst
  35. #!/bin/sh
  36. OPENSSL_UCI="$$$${IPKG_INSTROOT}/etc/config/openssl"
  37. [ -z "$$$${IPKG_INSTROOT}" ] \
  38. && uci -q get openssl.$(MOD_NAME) >/dev/null \
  39. && exit 0
  40. cat << EOF >> "$$$${OPENSSL_UCI}"
  41. config $(MOD_TYPE) '$(MOD_NAME)'
  42. option enabled '1'
  43. EOF
  44. [ -n "$$$${IPKG_INSTROOT}" ] || /etc/init.d/openssl reload
  45. exit 0
  46. endef
  47. define Package/$(OSSL_PKG)/postrm
  48. #!/bin/sh
  49. [ -n "$$$${IPKG_INSTROOT}" ] && exit 0
  50. uci -q delete openssl.$(MOD_NAME) && uci commit openssl
  51. /etc/init.d/openssl reload
  52. exit 0
  53. endef
  54. endef
  55. # 1 = engine name
  56. # 2 - package name, defaults to libopenssl-$(1)
  57. define Package/openssl/add-engine
  58. $(call Package/openssl/add-module,engine,$(1),/usr/lib/$(ENGINES_DIR),$(2))
  59. endef
  60. # 1 = provider name
  61. # 2 = [ package name, defaults to libopenssl-$(1) ]
  62. define Package/openssl/add-provider
  63. $(call Package/openssl/add-module,provider,$(1),/usr/lib/ossl-modules,$(2))
  64. endef