about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix')
-rw-r--r--nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix28
1 files changed, 25 insertions, 3 deletions
diff --git a/nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix b/nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix
index fa506733c16e..a272cf8b9340 100644
--- a/nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix
+++ b/nixpkgs/pkgs/development/libraries/tpm2-tss/default.nix
@@ -1,7 +1,7 @@
 { stdenv, lib, fetchFromGitHub
 , autoreconfHook, autoconf-archive, pkg-config, doxygen, perl
 , openssl, json_c, curl, libgcrypt
-, cmocka, uthash, ibm-sw-tpm2, iproute, procps, which
+, cmocka, uthash, ibm-sw-tpm2, iproute2, procps, which
 }:
 
 stdenv.mkDerivation rec {
@@ -20,14 +20,28 @@ stdenv.mkDerivation rec {
   ];
   buildInputs = [ openssl json_c curl libgcrypt ];
   checkInputs = [
-    cmocka uthash ibm-sw-tpm2 iproute procps which
+    cmocka uthash ibm-sw-tpm2 iproute2 procps which
   ];
 
   preAutoreconf = "./bootstrap";
 
   enableParallelBuilding = true;
 
-  postPatch = "patchShebangs script";
+  patches = [
+    # Do not rely on dynamic loader path
+    # TCTI loader relies on dlopen(), this patch prefixes all calls with the output directory
+    ./no-dynamic-loader-path.patch
+  ];
+
+  postPatch = ''
+    patchShebangs script
+    substituteInPlace src/tss2-tcti/tctildr-dl.c \
+      --replace '@PREFIX@' $out/lib/
+    substituteInPlace ./test/unit/tctildr-dl.c \
+      --replace ', "libtss2' ", \"$out/lib/libtss2" \
+      --replace ', "foo' ", \"$out/lib/foo" \
+      --replace ', TEST_TCTI_NAME' ", \"$out/lib/\"TEST_TCTI_NAME"
+  '';
 
   configureFlags = [
     "--enable-unit"
@@ -35,6 +49,14 @@ stdenv.mkDerivation rec {
   ];
 
   doCheck = true;
+  preCheck = ''
+    # Since we rewrote the load path in the dynamic loader for the TCTI
+    # The various tcti implementation should be placed in their target directory
+    # before we could run tests
+    installPhase
+    # install already done, dont need another one
+    dontInstall=1
+  '';
 
   postInstall = ''
     # Do not install the upstream udev rules, they rely on specific