Created
March 13, 2022 07:10
-
-
Save Jacobboogiebear/2af9a49f8e9fdc2641ae019be58c4acd to your computer and use it in GitHub Desktop.
A quick script to build swtpm and libtpm on Ubuntu 20.04 (created for WSL2 and WSLg)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install git g++ gcc automake autoconf libtool make gcc libc-dev libssl-dev pkg-config libtasn1-6-dev libjson-glib-dev expect gawk socat libseccomp-dev -y | |
cd ~ | |
git clone https://github.com/stefanberger/swtpm.git | |
git clone https://github.com/stefanberger/libtpms.git | |
cd libtpms | |
./autogen.sh --prefix=/usr --with-tpm2 --with-openssl | |
make | |
sudo make install | |
cd ../swtpm | |
./autogen.sh --prefix=/usr | |
make | |
sudo make install | |
cd .. | |
rm -rf swtpm/ libtpms/ |
I found that just installing gnutls-bin
was not enough. I also needed to install libgnutls28-dev
before building swtpm
. Only after that did it successfully work with virt-manager
.
It works fine for me with above aggregation comments, btw, ensure current user in sudoers.
cat <<EOF > build-swtpm.sh
> sudo apt-get install -y git g++ gcc automake autoconf libtool make gcc libc-dev libssl-dev pkg-config libtasn1-6-dev libjson-glib-dev expect gawk socat libseccomp-dev \
> gnutls-bin libgnutls28-dev
> cd ~
> git clone https://github.com/stefanberger/swtpm.git
> git clone https://github.com/stefanberger/libtpms.git
> cd libtpms
> ./autogen.sh --prefix=/usr --with-tpm2 --with-openssl
> make -j || make
> sudo make install
> cd ../swtpm
> ./autogen.sh --prefix=/usr
> make -j || make
> sudo make install
> cd ..
> rm -rf swtpm/ libtpms/
> EOF
chmod +x build-swtpm.sh
./build-swtpm.sh
swtpm -v
TPM emulator version 0.9.0, Copyright (c) 2014-2022 IBM Corp. and others
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To make this work with virt-manager, one also needs to install
certtool
before building. On Ubuntu you can do this via this command:If not swtpm_cert will not be build, and virt-manager will fail to create a swtpm device.