#!/bin/bash # Slackware build script for tpm2-tools # Written 2026-10-17 for Parted Magic. New: no tpm2-tools has shipped # before, and neither Slackware-current nor SBo carries it. Parted Magic TPM # (pmagic_tpm) reads a TPM 2.0's maker, owner and lockout state with # tpm2_getcap, decodes the firmware's event log with tpm2_eventlog, and # clears a TPM that has no lockout password with tpm2_clear. 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. # # Needs tpm2-tss (built beside it, 4.2.0) installed in the build chroot. # # Pinned explicitly rather than left to configure: # --disable-fapi tpm2-tss is built without FAPI, so no tss2_* tools # --with-efivar efivar is in the image; tpm2_eventlog prints UEFI # device paths with it # --disable-unit no unit tests (they need a simulator and tpm2-abrmd) # bash completion the stock place; build strips usr/share/bash-completion # from the image anyway # The man pages come ready made in the release tarball (no pandoc needed). # Every tool is one program, tpm2, with a tpm2_ link for each. set -e cd "$(dirname "$0")" ; CWD=$(pwd) PRGNAM=tpm2-tools VERSION=${VERSION:-5.8} 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 \ --with-efivar=yes \ --disable-unit \ --with-bashcompdir=/usr/share/bash-completion/completions \ --build=$ARCH-slackware-linux make $NUMJOBS make install DESTDIR="$PKG" 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 docs/LICENSE docs/CHANGELOG.md docs/MAINTAINERS README.md; 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"