blob: 8e8710119de9d070b2644337f84d77d41f7c9cfe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/bin/bash
LIBVIRT_STPM_GRP="libvirt-tpm"
module_init() {
groupadd --system "${LIBVIRT_STPM_GRP}"
}
fetch_source() {
autoclone
}
build() {
local SRCDIR_LIB="${MODULE_WORK_DIR}/src/libtpms"
local SRCDIR_BIN="${MODULE_WORK_DIR}/src/swtpm"
local DSTDIR="${MODULE_BUILD_DIR}"
cde "${SRCDIR_LIB}"
autoreconf --install --force
./configure \
--prefix="/usr" \
--with-openssl \
--with-tpm2 || perror "'configure' failed."
make || perror "'make' failed."
DESTDIR="${DSTDIR}" make install || perror "'make install' failed."
cde "${SRCDIR_BIN}"
# save original path content before modifying path variable
local PATH_OLD="${PATH}"
# set config paths for additional pkg-config files
export PKG_CONFIG_PATH="${DSTDIR}/usr/lib/pkgconfig"
# set system root directory for prebuilt headers and libraries, e.g. libvirt-glib
export PKG_CONFIG_SYSROOT_DIR="${DSTDIR}"
# enable output of all system include directories
export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
# enable output of all system library directories
export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
# create custom pkg-config program to patch paths from pkg-build config files in our build directory
cat > "${SRCDIR_BIN}/pkg-config" <<-EOF
#!/bin/bash
# unset custom path to avoid call recursion of this custom pkg-config script
unset PATH
# call patched pkg-config wrapper from mltk bin directory
exec "${ROOT_DIR}/core/bin/pkg-config.sh" "\${@}"
EOF
chmod +x "${SRCDIR_BIN}/pkg-config"
# Remove usage of /usr/bin/env to avoid PATH manipulation attacks
sed -i 's/env //' samples/swtpm-create-tpmca samples/swtpm-create-user-config-files.in
PATH="${SRCDIR}:${PATH}" \
autoreconf --install --force
# overwrite search path to inject custom pkg-config program
PATH="${SRCDIR}:${PATH}" \
./configure \
--prefix="/usr" \
--with-cuse \
--with-gnutls \
--with-seccomp || perror "'configure' failed."
make || perror "'make' failed."
DESTDIR="${DSTDIR}" make install || perror "'make install' failed."
# change group and permissions for libvirt-tpm members
chgrp "${LIBVIRT_STPM_GRP}" "${DSTDIR}/var/lib/swtpm-localca"
chmod 775 "${DSTDIR}/var/lib/swtpm-localca"
rm "${SRCDIR_BIN}/pkg-config"
# restore old environment so that following pkg-config calls are not modified
unset PKG_CONFIG_PATH
unset PKG_CONFIG_SYSROOT_DIR
unset PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
unset PKG_CONFIG_ALLOW_SYSTEM_LIBS
# restore original path variable
export PATH="${PATH_OLD}"
}
post_copy() {
:
}
|