Skip to content

Instantly share code, notes, and snippets.

@smoser
Last active November 17, 2021 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoser/ef279e77b068cc081d2f63c10f809db0 to your computer and use it in GitHub Desktop.
Save smoser/ef279e77b068cc081d2f63c10f809db0 to your computer and use it in GitHub Desktop.
swtpm / libtpms notes

swtpm notes

Info on how to build/use swtpm and libtpms. Pretty good doc at swtpm wiki. Qemu page has good info also, including qemu command lines. Qemu tpm.

I have been maintaining a "swtpm ppa" at ppa:smoser/swtpm.

Debian/Ubuntu

libtpms and swtpm seem to be working their way into debian/ubuntu.

build / upload

the 'build.sh' below is no longer necessary. I'm building with Ubuntu versions of the packages and just doing 'no source-change backports'.

#!/bin/bash
libtpmsv="0.8.4"
swtpmv="0.6.0"
PPA="${PPA:-ppa:smoser/swtpm}"
REL=${REL:-focal}
VERSION_SUFFIX="~smoserppa1"
set -ex
notnative() {
# these are not native, but debian/source/format says they are.
local dsf="debian/source/format" dc="debian/changelog"
# change
sed -i "1s/\(([0-9]\+[.][0-9]\+[.][0-9]\+\))/\1-1)/" "$dc"
echo "3.0 (quilt)" > "$dsf"
git diff "$dc" "$dsf" >/dev/null || return 0
git commit -m "not native package" "$dc" "$dsf"
}
setrel() {
local rel="$1" suffix="$2"
sed -i "1s/\([^ ]\+\) \([^ ]\+\) \([^;]\+\);/\1 \2 $rel;/g" debian/changelog
[ -z "$suffix" ] ||
sed -i "1s/\(-[0-9]\+[^-]*\))/\1$suffix)/" debian/changelog
}
dl() {
local url="$1" out="$2"
[ -f "$out" ] && return 0
wget -O "$out.tmp.$$" "$url" && mv "$out.tmp.$$" "$out"
}
dl "https://github.com/stefanberger/libtpms/archive/v${libtpmsv}.tar.gz" \
"libtpms_${libtpmsv}.orig.tar.gz"
[ -d libtpms ] ||
git clone https://github.com/stefanberger/libtpms.git
dl https://github.com/stefanberger/swtpm/archive/v${swtpmv}.tar.gz \
"swtpm_${swtpmv}.orig.tar.gz"
[ -d swtpm ] ||
git clone https://github.com/stefanberger/swtpm.git
# build libtpms
cd libtpms
git clean -fd
git checkout --force v${libtpmsv}
notnative
setrel "$REL" "$VERSION_SUFFIX"
debuild -S -nc
libtpms_pkgver=$(dpkg-parsechangelog --show-field=version)
cd ..
# build swtpm
cd swtpm
git clean -fd
git checkout --force v${swtpmv}
notnative
setrel "$REL" "$VERSION_SUFFIX"
debuild -S -nc
swtpm_pkgver=$(dpkg-parsechangelog --show-field=version)
cd ..
# upload stuff
if [ -n "$PPA" ]; then
dput "$PPA" swtpm_${swtpm_pkgver}_source.changes
dput "$PPA" libtpms_${libtpms_pkgver}_source.changes
fi
@mhalano
Copy link

mhalano commented Nov 17, 2021

Hi! I use your PPA and it's great, but I found a little problem: the release versions for Ubuntu versions have a typo. I think should be "21" instead of "22" for poth hirsute and impish releases.

@smoser
Copy link
Author

smoser commented Nov 17, 2021

Hi! I use your PPA and it's great, but I found a little problem: the release versions for Ubuntu versions have a typo. I think should be "21" instead of "22" for poth hirsute and impish releases.

Good catch. It kind of stinks that to go "backwards", I'll have to delete the files and add new ones. I'll just do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment