Skip to content

Instantly share code, notes, and snippets.

@thehunmonkgroup
Created March 4, 2024 21:27
Show Gist options
  • Select an option

  • Save thehunmonkgroup/34ac6e1dd0812a11bc1b702ef3b78adb to your computer and use it in GitHub Desktop.

Select an option

Save thehunmonkgroup/34ac6e1dd0812a11bc1b702ef3b78adb to your computer and use it in GitHub Desktop.
Bash script to build FreeSWITCH libstirshaken Debian packages
#!/usr/bin/env bash
DISTRO="bookworm"
VERSION="1.0.0"
GIT_COMMIT="6d99ee01ecb3d2930d5440b0e78e2cb3b1f3f326"
BUILD_DIR="/tmp/build"
function install_freeswitch_repo() {
local signalwire_access_token="${1}"
if [[ ! -r /usr/share/keyrings/signalwire-freeswitch-repo.gpg ]]; then
echo "Installing freeswitch repo key..."
wget --http-user=signalwire --http-password=${signalwire_access_token} -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg https://freeswitch.signalwire.com/repo/deb/debian-release/signalwire-freeswitch-repo.gpg
fi
if [[ ! -r /etc/apt/sources.list.d/99-freeswitch.list ]]; then
echo "Installing freeswitch repo..."
cat <<EOF > /etc/apt/sources.list.d/99-freeswitch.list
deb [signed-by=/usr/share/keyrings/signalwire-freeswitch-repo.gpg] https://signalwire:${signalwire_access_token}@freeswitch.signalwire.com/repo/deb/debian-release/ ${DISTRO} main
EOF
fi
apt-get update
}
function install_deps() {
echo "Installing libstirshaken deps..."
# Debian build deps.
apt-get install -y build-essential devscripts debhelper
# libstirshaken build deps.
apt-get install -y libcurl4-openssl-dev libjwt-dev libks2 libssl-dev pkgconf uuid-dev
# libstirshaken runtime deps.
apt-get install -y libc6 libcurl4 libjwt0 libks2 libssl3
}
function build() {
echo "Building libstirshaken..."
rm -rf ${BUILD_DIR} && mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
git clone https://github.com/signalwire/libstirshaken.git libstirshaken1-${VERSION}
mv libstirshaken1-${VERSION}/.git .
tar -czvf libstirshaken1_${VERSION}.orig.tar.gz libstirshaken1-${VERSION}
mv .git libstirshaken1-${VERSION}/
cd libstirshaken1-${VERSION}
git checkout v${GIT_COMMIT}
DEB_CFLAGS_MAINT_APPEND="-Wno-error" DEB_BUILD_OPTIONS=nocheck debuild -us -uc -b
}
usage() {
echo "Usage: $0 <signalwire_access_token>"
echo
echo "Required argument:"
echo " signalwire_access_token: Personal SignalWire access token for the FreeSWITCh repository."
echo
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
install_freeswitch_repo "${1}"
install_deps
build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment