about summary refs log tree commit diff
path: root/pkgs/development/python-modules
diff options
context:
space:
mode:
authorLassulus <github@lassul.us>2023-07-31 07:13:18 +0200
committerGitHub <noreply@github.com>2023-07-31 07:13:18 +0200
commitfbacd47118ce596c24cc8bf9c5759a989c7b6799 (patch)
tree580a454f74ac960cfca36aecdb6b343b54ef4a33 /pkgs/development/python-modules
parentb0f41a7c3af0ffaccc68ee1c6bda54f75f7674b8 (diff)
parent108c1d886668fd66c05176cf505ef5bdeadffbde (diff)
Merge pull request #245962 from baloo/baloo/tpm2-pytss/enable-tests
python3Packages.tpm2-pytss: enable tests
Diffstat (limited to 'pkgs/development/python-modules')
-rw-r--r--pkgs/development/python-modules/tpm2-pytss/default.nix23
-rw-r--r--pkgs/development/python-modules/tpm2-pytss/fapi-config.patch12
2 files changed, 31 insertions, 4 deletions
diff --git a/pkgs/development/python-modules/tpm2-pytss/default.nix b/pkgs/development/python-modules/tpm2-pytss/default.nix
index 3c18e7cbdc035..b732988db39df 100644
--- a/pkgs/development/python-modules/tpm2-pytss/default.nix
+++ b/pkgs/development/python-modules/tpm2-pytss/default.nix
@@ -6,7 +6,6 @@
 , asn1crypto
 , cffi
 , cryptography
-, ibm-sw-tpm2
 , pkgconfig # see nativeBuildInputs
 , pkg-config # see nativeBuildInputs
 , pycparser
@@ -15,6 +14,8 @@
 , pyyaml
 , setuptools-scm
 , tpm2-tss
+, tpm2-tools
+, swtpm
 }:
 
 buildPythonPackage rec {
@@ -40,8 +41,22 @@ buildPythonPackage rec {
       url = "https://github.com/baloo/tpm2-pytss/commit/099c069f28cfcd0a3019adebfeafa976f9395221.patch";
       sha256 = "sha256-wU2WfLYFDmkhGzYornZ386tB3zb3GYfGOTc+/QOFb1o=";
     })
+
+    # Lookup tcti via getinfo not system's ld_library_path
+    # https://github.com/tpm2-software/tpm2-pytss/pull/525
+    (fetchpatch {
+      url = "https://github.com/tpm2-software/tpm2-pytss/commit/97289a08ddf44f7bdccdd122d6055c69e12dc584.patch";
+      sha256 = "sha256-VFq3Hv4I8U8ifP/aSjyu0BiW/4jfPlRDKqRcqUGw6UQ=";
+    })
+
+    # Fix hardcoded `fapi-config.json` configuration path
+    ./fapi-config.patch
   ];
 
+  postPatch = ''
+    sed -i "s#@TPM2_TSS@#${tpm2-tss.out}#" src/tpm2_pytss/FAPI.py
+  '';
+
   nativeBuildInputs = [
     cffi
     pkgconfig # this is the Python module
@@ -60,12 +75,12 @@ buildPythonPackage rec {
     pyyaml
   ];
 
-  # https://github.com/tpm2-software/tpm2-pytss/issues/341
-  doCheck = false;
+  doCheck = true;
 
   nativeCheckInputs = [
-    ibm-sw-tpm2
     pytestCheckHook
+    tpm2-tools
+    swtpm
   ];
 
   pythonImportsCheck = [
diff --git a/pkgs/development/python-modules/tpm2-pytss/fapi-config.patch b/pkgs/development/python-modules/tpm2-pytss/fapi-config.patch
new file mode 100644
index 0000000000000..f6245ef304674
--- /dev/null
+++ b/pkgs/development/python-modules/tpm2-pytss/fapi-config.patch
@@ -0,0 +1,12 @@
+diff --git a/src/tpm2_pytss/FAPI.py b/src/tpm2_pytss/FAPI.py
+index 916eda6..1afba3f 100644
+--- a/src/tpm2_pytss/FAPI.py
++++ b/src/tpm2_pytss/FAPI.py
+@@ -23,6 +23,7 @@ logger = logging.getLogger(__name__)
+ 
+ FAPI_CONFIG_ENV = "TSS2_FAPICONF"
+ FAPI_CONFIG_PATHS = [
++    "@TPM2_TSS@/etc/tpm2-tss/fapi-config.json",
+     "/etc/tpm2-tss/fapi-config.json",
+     "/usr/local/etc/tpm2-tss/fapi-config.json",
+ ]