Skip to content

Commit f7ee78c

Browse files
committed
tpm2-pkcs11: 1.9.0 -> 1.9.1
- Switch to clang since fuzzing uses clang's libfuzzed - Enable tests - Support optional fuzzing (currently fails)
1 parent b8fa6de commit f7ee78c

File tree

3 files changed

+71
-103
lines changed

3 files changed

+71
-103
lines changed

pkgs/by-name/tp/tpm2-pkcs11/graceful-fapi-fail.patch

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 71 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,76 @@
11
{
2-
stdenv,
3-
lib,
4-
fetchFromGitHub,
5-
pkg-config,
6-
autoreconfHook,
72
autoconf-archive,
3+
autoreconfHook,
4+
clangStdenv,
5+
cmocka,
6+
fetchFromGitHub,
7+
glibc,
8+
lib,
9+
libyaml,
810
makeWrapper,
9-
patchelf,
10-
tpm2-tss,
11-
tpm2-tools,
1211
opensc,
1312
openssl,
14-
sqlite,
13+
patchelf,
14+
pkg-config,
1515
python3,
16-
glibc,
17-
libyaml,
18-
abrmdSupport ? true,
19-
tpm2-abrmd ? null,
16+
stdenv,
17+
sqlite,
18+
tpm2-abrmd,
19+
tpm2-pkcs11, # for passthru abrmd tests
20+
tpm2-tools,
21+
tpm2-tss,
22+
abrmdSupport ? false,
2023
fapiSupport ? true,
24+
enableFuzzing ? false,
2125
}:
2226

23-
stdenv.mkDerivation rec {
27+
let
28+
chosenStdenv = if enableFuzzing then clangStdenv else stdenv;
29+
in
30+
chosenStdenv.mkDerivation (finalAttrs: {
2431
pname = "tpm2-pkcs11";
25-
version = "1.9.0";
32+
version = "1.9.1";
2633

2734
src = fetchFromGitHub {
2835
owner = "tpm2-software";
29-
repo = pname;
30-
rev = version;
31-
sha256 = "sha256-SoHtgZRIYNJg4/w1MIocZAM26mkrM+UOQ+RKCh6nwCk=";
36+
repo = "tpm2-pkcs11";
37+
tag = finalAttrs.version;
38+
hash = "sha256-W74ckrpK7ypny1L3Gn7nNbOVh8zbHavIk/TX3b8XbI8=";
3239
};
3340

34-
patches = [
35-
./version.patch
36-
./graceful-fapi-fail.patch
37-
];
38-
3941
# The preConfigure phase doesn't seem to be working here
4042
# ./bootstrap MUST be executed as the first step, before all
4143
# of the autoreconfHook stuff
4244
postPatch = ''
43-
echo ${version} > VERSION
45+
echo "$version" > VERSION
46+
47+
# Don't run git in the bootstrap
48+
substituteInPlace bootstrap --replace-warn "git" "# git"
49+
50+
# Don't run tests with dbus
51+
substituteInPlace Makefile.am --replace-fail "dbus-run-session" "env"
52+
53+
patchShebangs test
54+
4455
./bootstrap
4556
'';
4657

47-
configureFlags = lib.optionals (!fapiSupport) [
48-
# Note: this will be renamed to with-fapi in next release.
49-
"--enable-fapi=no"
50-
];
58+
configureFlags =
59+
lib.singleton (lib.enableFeature finalAttrs.doCheck "unit")
60+
++ lib.optionals enableFuzzing [
61+
"--enable-fuzzing"
62+
"--disable-hardening"
63+
]
64+
++ lib.optional fapiSupport "--with-fapi";
65+
66+
strictDeps = true;
5167

5268
nativeBuildInputs = [
53-
pkg-config
54-
autoreconfHook
5569
autoconf-archive
70+
autoreconfHook
5671
makeWrapper
5772
patchelf
58-
];
59-
buildInputs = [
60-
tpm2-tss
61-
tpm2-tools
62-
opensc
63-
openssl
64-
sqlite
65-
libyaml
73+
pkg-config
6674
(python3.withPackages (
6775
ps: with ps; [
6876
packaging
@@ -73,13 +81,28 @@ stdenv.mkDerivation rec {
7381
]
7482
))
7583
];
84+
buildInputs = [
85+
libyaml
86+
opensc
87+
openssl
88+
sqlite
89+
tpm2-tools
90+
tpm2-tss
91+
];
92+
checkInputs = [
93+
cmocka
94+
];
95+
96+
enableParallelBuilding = true;
97+
hardeningDisable = lib.optional enableFuzzing "all";
7698

7799
outputs = [
78100
"out"
79101
"bin"
80102
"dev"
81103
];
82104

105+
doCheck = true;
83106
dontStrip = true;
84107
dontPatchELF = true;
85108

@@ -90,11 +113,11 @@ stdenv.mkDerivation rec {
90113
rpath = lib.makeLibraryPath (
91114
(lib.optional abrmdSupport tpm2-abrmd)
92115
++ [
93-
tpm2-tss
94-
sqlite
95-
openssl
96116
glibc
97117
libyaml
118+
openssl
119+
sqlite
120+
tpm2-tss
98121
]
99122
);
100123
in
@@ -113,6 +136,12 @@ stdenv.mkDerivation rec {
113136
--prefix PATH : ${lib.makeBinPath [ tpm2-tools ]}
114137
'';
115138

139+
passthru = {
140+
tests.tpm2-pkcs11-abrmd = tpm2-pkcs11.override {
141+
abrmdSupport = true;
142+
};
143+
};
144+
116145
meta = with lib; {
117146
description = "PKCS#11 interface for TPM2 hardware";
118147
homepage = "https://github.com/tpm2-software/tpm2-pkcs11";
@@ -121,4 +150,4 @@ stdenv.mkDerivation rec {
121150
maintainers = [ ];
122151
mainProgram = "tpm2_ptool";
123152
};
124-
}
153+
})

pkgs/by-name/tp/tpm2-pkcs11/version.patch

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)