#!/bin/bash # Slackware build script for tpm2-tss # Written 2026-10-17 for Parted Magic. New: no tpm2-tss has shipped before, # and neither Slackware-current nor SBo carries it. It is the TPM 2.0 # software stack that tpm2-tools is built on, for Parted Magic TPM # (pmagic_tpm). The release tarball is signed by Andreas Fuchs (Infineon), # key D533275B0123D0A679F51FF48F4F9A45D7FFEE74, the key his GitHub account # (AndreasFuchsTPM) publishes; the key is kept beside this script. # # Pinned explicitly rather than left to configure: # --disable-fapi --disable-policy the JSON key store layer and the policy # library. Nothing in the image uses them, and FAPI # wants a key store under /var/lib and a tss user. # --with-crypto=ossl OpenSSL 3, already in the image. # TCTI modules device (the kernel's /dev/tpm0 and /dev/tpmrm0), # mssim and swtpm (simulators), cmd, pcap, null, # spi-helper, i2c-helper, spidev, and spi-ltt2go (a # USB TPM; libusb is in the image). Not libtpms, # spi-ftdi or i2c-ftdi: neither library is in the image. # no doxygen, no unit or integration tests. # # Taken out of the package afterwards: # the two udev rules. They hand /dev/tpm* to a tss user and group that # the image does not have (Parted Magic runs as root), so udev would only # complain at every boot. # the empty FAPI folders under /run and /var/lib, which the install-dirs # hook makes even with FAPI off. /run is a tmpfs. set -e cd "$(dirname "$0")" ; CWD=$(pwd) PRGNAM=tpm2-tss VERSION=${VERSION:-4.2.0} BUILD=${BUILD:-1} TAG=${TAG:-_pmagic} PKGTYPE=${PKGTYPE:-txz} ARCH=${ARCH:-x86_64} if [ -n "${PRINT_PACKAGE_NAME:-}" ]; then echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"; exit 0 fi TMP=${TMP:-/tmp/pm-build} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-$TMP} NUMJOBS=${NUMJOBS:--j12} SLKCFLAGS="-O2 -fPIC" rm -rf "$PKG" "$TMP/$PRGNAM-$VERSION" mkdir -p "$TMP" "$PKG" "$OUTPUT" cd "$TMP" tar xzf "$CWD/$PRGNAM-$VERSION.tar.gz" cd "$PRGNAM-$VERSION" chown -R root:root . find . -perm /111 -a \! -perm 755 -exec chmod 755 {} \+ -o \ \! -perm /111 -a \! -perm 644 -exec chmod 644 {} \+ CFLAGS="$SLKCFLAGS" \ ./configure \ --prefix=/usr \ --libdir=/usr/lib64 \ --sysconfdir=/etc \ --localstatedir=/var \ --mandir=/usr/man \ --docdir=/usr/doc/$PRGNAM-$VERSION \ --disable-static \ --disable-fapi \ --disable-policy \ --with-crypto=ossl \ --enable-tcti-device \ --enable-tcti-mssim \ --enable-tcti-swtpm \ --enable-tcti-cmd \ --enable-tcti-pcap \ --enable-tcti-null \ --enable-tcti-spi-helper \ --enable-tcti-i2c-helper \ --enable-tcti-spidev \ --enable-tcti-spi-ltt2go \ --disable-tcti-libtpms \ --disable-tcti-spi-ftdi \ --disable-tcti-i2c-ftdi \ --disable-doxygen-doc \ --disable-unit \ --disable-integration \ --with-udevrulesdir=/lib/udev/rules.d \ --build=$ARCH-slackware-linux make $NUMJOBS make install DESTDIR="$PKG" # Not shipped: see the header. rm -f "$PKG"/lib/udev/rules.d/tpm-udev.rules \ "$PKG"/lib/udev/rules.d/ltt2go-udev.rules rmdir -p "$PKG"/lib/udev/rules.d 2>/dev/null || true rm -rf "$PKG"/run "$PKG"/var/run "$PKG"/var/lib/tpm2-tss rmdir "$PKG"/var/lib "$PKG"/var 2>/dev/null || true # Don't ship .la files. rm -f "$PKG"/usr/lib64/*.la find "$PKG" -print0 | xargs -0 file | grep -e "executable" -e "shared object" | \ grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2>/dev/null || true if [ -d "$PKG/usr/man" ]; then find "$PKG/usr/man" -type f -exec gzip -9 {} \; for i in $(find "$PKG/usr/man" -type l); do ln -s "$(readlink "$i").gz" "$i.gz"; rm "$i" done fi mkdir -p "$PKG/usr/doc/$PRGNAM-$VERSION" for f in LICENSE README.md CHANGELOG.md MAINTAINERS AUTHORS; do [ -s "$f" ] && cp -a "$f" "$PKG/usr/doc/$PRGNAM-$VERSION/" done cp -a "$CWD/$PRGNAM.SlackBuild" "$CWD/$PRGNAM.info" "$PKG/usr/doc/$PRGNAM-$VERSION/" mkdir -p "$PKG/install" cat "$CWD/slack-desc" > "$PKG/install/slack-desc" cd "$PKG" /sbin/makepkg -l y -c n "$OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"