Gentoo Archives: gentoo-commits

From: Ronny Gutbrod <gentoo@××××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:master commit in: app-crypt/tpm2-openssl/
Date: Wed, 28 Sep 2022 16:05:05
Message-Id: 1664316552.f967da3dc0d646f757b7a7807ee89f7e0181dbc7.tastytea@gentoo
1 commit: f967da3dc0d646f757b7a7807ee89f7e0181dbc7
2 Author: Christopher Byrne <salah.coronya <AT> gmail <DOT> com>
3 AuthorDate: Tue Sep 27 22:05:33 2022 +0000
4 Commit: Ronny Gutbrod <gentoo <AT> tastytea <DOT> de>
5 CommitDate: Tue Sep 27 22:09:12 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=f967da3d
7
8 app-crypt/tpm2-openssl: Enable tests
9
10 Signed-off-by: Christopher Byrne <salah.coronya <AT> gmail.com>
11
12 app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild | 76 ++++++++++++++++++++++--
13 1 file changed, 72 insertions(+), 4 deletions(-)
14
15 diff --git a/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild b/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild
16 index bce9e94a4..2cb119589 100644
17 --- a/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild
18 +++ b/app-crypt/tpm2-openssl/tpm2-openssl-1.1.0.ebuild
19 @@ -13,18 +13,82 @@ LICENSE="BSD"
20
21 SLOT="0/${PV}"
22 KEYWORDS="~amd64"
23 -
24 -# Needs IBM's software TPM simulator, which isn't in Portage
25 -RESTRICT="test"
26 +IUSE="test"
27
28 RDEPEND=">=app-crypt/tpm2-tss-3.2.0:=
29 =dev-libs/openssl-3.0*:0="
30
31 -DEPEND="${RDEPEND}"
32 +DEPEND="${RDEPEND}
33 + test? ( app-crypt/swtpm
34 + app-crypt/tpm2-abrmd
35 + app-crypt/tpm2-tools )"
36
37 BDEPEND="sys-devel/autoconf-archive
38 virtual/pkgconfig"
39
40 +RESTRICT="!test? ( test )"
41 +
42 +dbus_run() {
43 + (
44 + # start isolated dbus session bus
45 + dbus_data=$(dbus-launch --sh-syntax) || exit
46 + eval "${dbus_data}"
47 +
48 + $@
49 + ret=${?}
50 +
51 + kill "${DBUS_SESSION_BUS_PID}"
52 + exit "${ret}"
53 + ) || die
54 +}
55 +
56 +tpm2_run_with_emulator() {
57 + export XDG_CONFIG_HOME=${T}/.config/swtpm
58 + "${BROOT}"/usr/share/swtpm/swtpm-create-user-config-files || die
59 +
60 + mkdir -p ${XDG_CONFIG_HOME}/mytpm1 || die
61 + swtpm_setup_args=(
62 + --tpm2
63 + --tpmstate ${XDG_CONFIG_HOME}/mytpm1
64 + --createek
65 + --allow-signing
66 + --decryption
67 + --create-ek-cert
68 + --create-platform-cert
69 + --lock-nvram
70 + --overwrite
71 + --display
72 + )
73 + swtpm_setup "${swtpm_setup_args[@]}" || die
74 +
75 + swtpm_socket_args=(
76 + --tpm2
77 + --tpmstate dir=${XDG_CONFIG_HOME}/mytpm1
78 + --flags startup-clear
79 + --ctrl type=unixio,path=${XDG_CONFIG_HOME}/mytpm1/swtpm.socket.ctrl
80 + --server type=unixio,path=${XDG_CONFIG_HOME}/mytpm1/swtpm.socket
81 + --pid file=${XDG_CONFIG_HOME}/mytpm1/swtpm.pid
82 + --daemon
83 + )
84 + swtpm socket "${swtpm_socket_args[@]}" || die
85 +
86 + tpm2_abrmd_args=(
87 + --logger=stdout
88 + --tcti=swtpm:path=${XDG_CONFIG_HOME}/mytpm1/swtpm.socket
89 + --session
90 + --flush-all
91 + )
92 + tpm2-abrmd "${tpm2_abrmd_args[@]}" &
93 +
94 + export TPM2OPENSSL_TCTI="tabrmd:bus_type=session"
95 + export TPM2TOOLS_TCTI="tabrmd:bus_type=session"
96 +
97 + $@ || die
98 +
99 + # When swtpm dies, tmp2-abrmd will exit
100 + kill $(< ${XDG_CONFIG_HOME}/mytpm1/swtpm.pid) || die
101 +}
102 +
103 src_prepare() {
104 # See bug #833887 (and similar); eautoreconf means version information
105 # could be incorrectly embedded
106 @@ -42,3 +106,7 @@ src_install() {
107
108 # No libtool files are install, so nothing to check for bug #833887
109 }
110 +
111 +src_test() {
112 + dbus_run tpm2_run_with_emulator make check
113 +}