package/tpm2-pkcs11: install tpm2_ptool utility

The tpm2_ptool script appears on several TPM2 tutorials and it's
packaged as the "tpm2-pkcs11-tools" package in several Linux
distribution.

Add a new tpm2-pkcs11 option to install tpm2_ptool script along with
its dependencies.

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Romain Naour 2024-06-27 09:54:41 +02:00 committed by Thomas Petazzoni
parent c72c6f26ed
commit 89e3b2fb84
2 changed files with 42 additions and 0 deletions

View file

@ -11,5 +11,27 @@ config BR2_PACKAGE_TPM2_PKCS11
https://github.com/tpm2-software/tpm2-pkcs11
if BR2_PACKAGE_TPM2_PKCS11
config BR2_PACKAGE_TPM2_PKCS11_PYTHON_TOOLS
bool "Install python tools (tpm2_ptool)"
depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS # python-bcrypt, python-cryptography
depends on BR2_PACKAGE_PYTHON3
select BR2_PACKAGE_PYTHON_BCRYPT # runtime
select BR2_PACKAGE_PYTHON_CRYPTOGRAPHY # runtime
select BR2_PACKAGE_PYTHON_PYASN1 # runtime
select BR2_PACKAGE_PYTHON_PYASN1_MODULES # runtime
select BR2_PACKAGE_PYTHON_PYYAML # runtime
select BR2_PACKAGE_PYTHON_TPM2_PYTSS # runtime
select BR2_PACKAGE_PYTHON3_SQLITE # runtime
help
Enable Python-related tools (tpm2_ptool)
comment "python tools needs python3"
depends on !BR2_PACKAGE_PYTHON3
depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
endif
comment "tpm2-pkcs11 needs a toolchain w/ dynamic library, threads"
depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS

View file

@ -44,4 +44,24 @@ TPM2_PKCS11_CONF_OPTS += \
--with-p11kitconfigdir=/usr/share/p11-kit/modules
endif
ifeq ($(BR2_PACKAGE_TPM2_PKCS11_PYTHON_TOOLS),y)
TPM2_PKCS11_DEPENDENCIES += python-tpm2-pytss
define TPM2_PKCS11_BUILD_TOOLS
(cd $(@D)/tools; \
$(PKG_PYTHON_SETUPTOOLS_ENV) \
$(HOST_DIR)/bin/python setup.py build)
endef
TPM2_PKCS11_POST_BUILD_HOOKS += TPM2_PKCS11_BUILD_TOOLS
define TPM2_PKCS11_INSTALL_TARGET_TOOLS
(cd $(@D)/tools; \
$(PKG_PYTHON_SETUPTOOLS_ENV) \
$(HOST_DIR)/bin/python setup.py install \
$(PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS) \
--root=$(TARGET_DIR))
endef
TPM2_PKCS11_POST_INSTALL_TARGET_HOOKS += TPM2_PKCS11_INSTALL_TARGET_TOOLS
endif
$(eval $(autotools-package))