Skip to content

Instantly share code, notes, and snippets.

@vbatts
Last active June 2, 2021 15:28
Show Gist options
  • Save vbatts/184a570663d3a24881741007be0784cb to your computer and use it in GitHub Desktop.
Save vbatts/184a570663d3a24881741007be0784cb to your computer and use it in GitHub Desktop.
Build https://launchpad.net/~smoser/+archive/ubuntu/swtpm for ubuntu-20.10 with the python scripts included
#!/bin/bash
set -eux
# FROM ubuntu:20.10
export DEBIAN_FRONTEND=noninteractive
ln -sf /usr/share/zoneinfo/GMT /etc/localtime
sed -i -e 's/^# deb/deb/' /etc/apt/sources.list
apt update
apt install -y build-essential vim-tiny git wget curl devscripts dh-python
apt build-dep -y libtpms
apt install -y libfuse-dev libglib2.0-dev libgmp-dev expect libtasn1-dev socat python3-cryptography python3-setuptools python3-twisted gnutls-dev gnutls-bin net-tools softhsm2 libseccomp-dev
dpkg-reconfigure --frontend noninteractive tzdata
EMAIL="${EMAIL:[email protected]}"
NAME="${NAME:-Vincent Batts}"
git config --global user.email "${EMAIL}"
git config --global user.name "${NAME}"
OUTPUT=${OUTPUT:-/tmp}
#PPA="ppa:smoser/swtpm"
libtpms_ver="0.7.7"
swtpm_ver="0.5.2"
swtpm_url="${SWTPM_URL:-https://github.com/stefanberger/swtpm}"
ubuntu_release="groovy"
notnative() {
# these are not native, but debian/source/fromat says so
local dsf="debian/source/format"
grep -q "native" "$dsf" || return 0
echo "3.0 (quilt)" > "$dsf"
git commit -m "not native package" "$dsf"
}
setrel() {
local rel="$1"
sed -i "1s/\([^ ]\+\) \([^ ]\+\) \([^;]\+\);/\1 \2 $rel;/g" debian/changelog
}
wget -O libtpms_${libtpms_ver}.orig.tar.gz \
https://github.com/stefanberger/libtpms/archive/v${libtpms_ver}.tar.gz
# build libtpms
git clone https://github.com/stefanberger/libtpms.git
cd libtpms
git checkout v${libtpms_ver}
notnative
setrel "${ubuntu_release}"
debuild --no-sign -nc
#dput $PPA ../libtpms_${libtpms_ver}-1_source.changes
cd ..
apt install -y ./libtpms*_${libtpms_ver}_*.deb
# build swtpm
wget -O swtpm_${swtpm_ver}.orig.tar.gz \
${swtpm_url}/archive/v${swtpm_ver}.tar.gz
git clone ${swtpm_url}
cd swtpm
git checkout v${swtpm_ver}
notnative
setrel "${ubuntu_release}"
debuild --no-sign -nc
#dput $PPA ../libtpms_${libtpms_ver}-1_source.changes
cd ..
cp *deb "${OUTPUT}"/
# vim:set sts=2 sw=2 et:
IMAGE := ubuntu:20.10
CWD := $(shell pwd)
NAME := $(shell git config user.name)
EMAIL := $(shell git config user.email)
SWTPM_URL := https://github.com/stefanberger/swtpm
build: build.sh output
docker run \
-it \
--rm \
-v $(CWD):/build \
--env NAME="$(NAME)" \
--env EMAIL="$(EMAIL)" \
--env SWTPM_URL="$(SWTPM_URL)" \
--env OUTPUT="/build/output/" \
$(IMAGE) \
bash /build/build.sh
output:
mkdir -p output
@dongsupark
Copy link

To build rpm packages doing the same thing, please have a look: https://gist.github.com/dongsupark/5716f464cf04b977faa15d3056504cbf

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