Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
6.8 KiB

#!/bin/bash
# Build script for Slackware
# Copyright (C) 2018 Damien Goutte-Gattat
#
# Redistribution and use of this script, with or without modifications,
# is permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Contact: Damien Goutte-Gattat <dgouttegattat@incenp.org>
#
# Latest ring-daemon sourcecode is available at: <https://www.ring.cx/>.
#
# Depends: l/yaml-cpp, l/jsoncpp, xap/ffmpeg, l/argon2, l/restbed
# Depends: l/msgpack-c, l/cryptopp
# Recommends: l/libdbus-c++, l/opus, l/speex, l/libgsm
# Optional: ap/jack, l/libilbc
# Source package infos
NAMESRC=${NAMESRC:-ring-daemon}
VERSION=${VERSION:-4.0.0}
ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION.tar.gz}
WGET=${WGET:-https://github.com/savoirfairelinux/ring-daemon/archive/$VERSION.tar.gz}
# Bundled dependencies
NATPMP_VERSION=${NATPMP_VERSION:-20150609}
NATPMP_ARCHIVE=${NATPMP_ARCHIVE:-libnatpmp-$NATPMP_VERSION.tar.gz}
NATPMP_WGET=${NATPMP_URL:-http://miniupnp.free.fr/files/download.php?file=$NATPMP_ARCHIVE}
PJPROJECT_VERSION=${PJPROJECT_VERSION:-2.6}
PJPROJECT_ARCHIVE=${PJPROJECT_ARCHIVE:-pjproject-$PJPROJECT_VERSION.tar.bz2}
PJPROJECT_WGET=${PJPROJECT_WGET:-http://www.pjsip.org/release/2.6/$PJPROJECT_ARCHIVE}
OPENDHT_VERSION=${OPENDHT_VERSION:-6f3eafc5eea1b456a625bdf473419464eb0b202a}
OPENDHT_ARCHIVE=${OPENDHT_ARCHIVE:-opendht-$OPENDHT_VERSION.tar.gz}
OPENDHT_WGET=${OPENDHT_WGET:-https://github.com/savoirfairelinux/opendht/archive/$OPENDHT_VERSION.tar.gz}
# Build infos
NAMEPKG=${NAMEPKG:-ring-daemon}
BUILD=${BUILD:-1GGD}
ARCH=${ARCH:-$(uname -m | sed 's/^i.86$/i486/;s/^arm.*/arm/')}
JOBS=${JOBS:-1}
EXT=${EXT:-txz}
# Directories
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
PKG=${PKG:-$OUT/$NAMEPKG}
CWD=$(pwd)
set -e # Quit if a command returns non-zero
# Sanity checks
if [ $UID -eq 0 ]; then
echo "You should NOT run this script as ROOT!"
exit 1
fi
if [ ! -d $TMP ]; then
echo "$TMP does not exists or is not a directory!"
exit 1
fi
# Compilation flags
LIBDIRSUFFIX=""
case "$ARCH" in
i?86)
CPUOPT="-O2 -march=$ARCH -mtune=i686"
;;
x86_64)
CPUOPT="-O2 -fPIC"
LIBDIRSUFFIX="64"
;;
*)
CPUOPT="-O2"
;;
esac
# Download source and bundled dependencies
#
# Rationale for bundling those dependencies instead of
# making proper packages for each of them:
#
# - libnatpmp: needs to be statically linked into libring.so,
# otherwise the dring daemon crashes at startup (WTF?)
# - pjproject: heavily patched by the Ring developers, and only
# a subset of its features are used
# - opendht: tightly tied to Ring
for dep in "" NATPMP_ PJPROJECT_ OPENDHT_ ; do
eval archive=\$${dep}ARCHIVE
eval url=\$${dep}WGET
if [ ! -r $archive ]; then
wget -c -O $archive.part $url
mv $archive.part $archive
fi
eval ${dep}NAME=$(tar ft $archive | head -n 1 | cut -d / -f 1)
done
sha256sum -c checksums
# Extract all sources
mkdir -p $TMP/ring-daemon/bundle
cd $TMP/ring-daemon
tar xf $CWD/$ARCHIVE
tar xf $CWD/$NATPMP_ARCHIVE
tar xf $CWD/$PJPROJECT_ARCHIVE
tar xf $CWD/$OPENDHT_ARCHIVE
# Building bundled libnatpmp
cd $NATPMP_NAME
make INSTALLPREFIX=$TMP/ring-daemon/bundle install
rm -f $TMP/ring-daemon/bundle/lib/libnatpmp.so*
# Building bundled pjproject
cd $TMP/ring-daemon/$PJPROJECT_NAME
for patch in gnutls notestsapps ipv6 ice_config multiple_listeners pj_ice_sess fix_turn_fallback fix_ioqueue_ipv6_sendto add_dtls_transport ; do
patch -p 1 < $TMP/ring-daemon/$NAME/contrib/src/pjproject/$patch.patch
done
PJPROJECT_EXTRA_CFLAGS="-DPJ_ICE_MAX_CAND=256 -DPJ_ICE_MAX_CHECKS=150 -DPJ_ICE_COMP_BITS=2 -DPJ_ICE_MAX_STUN=3 -DPJSIP_MAX_PKT_LEN=8000 -DPJ_ICE_ST_MAX_CAND=32"
PJPROJECT_EXTRA_CXXFLAGS="$PJPROJECT_EXTRA_CFLAGS -std=gnu++11"
./configure --prefix=$TMP/ring-daemon/bundle \
--disable-oss \
--disable-sound \
--disable-video \
--enable-ext-sound \
--disable-speex-aec \
--disable-g711-codec \
--disable-l16-codec \
--disable-gsm-codec \
--disable-g722-codec \
--disable-g7221-codec \
--disable-speex-codec \
--disable-ilbc-codec \
--disable-opencore-amr \
--disable-silk \
--disable-sdl \
--disable-ffmpeg \
--disable-v4l2 \
--disable-openh264 \
--disable-resample \
--disable-libwebrtc \
--enable-ssl=gnutls \
--enable-static \
--disable-shared \
--disable-dependency-tracking
CFLAGS="$CPUOPT $PJPROJECT_EXTRA_CFLAGS" \
CXXFLAGS="$CPUOPT $PJPROJECT_EXTRA_CXXFLAGS" \
make -j $JOBS
make install
# Building bundled OpenDHT
cd $TMP/ring-daemon/$OPENDHT_NAME
./autogen.sh
CFLAGS="$CPUOPT" \
CXXFLAGS="$CPUOPT -std=c++11" \
./configure \
--prefix=$TMP/ring-daemon/bundle \
--disable-tools \
--disable-python \
--disable-doc \
--enable-proxy-server \
--enable-proxy-client \
--enable-push-notifications \
--enable-static \
--disable-shared \
--disable-dependency-tracking
make -j $JOBS
make install
# Build ring-daemon itself
cd $TMP/ring-daemon/$NAME
./autogen.sh
CFLAGS="$CPUOPT" \
CXXFLAGS="$CPUOPT -std=c++11" \
./configure \
--prefix=/usr \
--libdir=/usr/lib$LIBDIRSUFFIX \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--enable-ipv6 \
--with-contrib=$TMP/ring-daemon/bundle
make -j $JOBS
# We need to convince Libtool that there's no need to link
# to libnatpmp.so...
sed -i 's,-lnatpmp,,' bin/dring
sed -i 's,-lnatpmp,,' src/libring.la
make install-strip DESTDIR=$PKG
sed -i 's,-lnatpmp,,' $PKG/usr/lib$LIBDIRSUFFIX/libring.la
# Compress man page
gzip -9 $PKG/usr/man/man1/dring.1
# Install the documentation
mkdir -p $PKG/usr/doc/$NAME
install -m 644 AUTHORS CODING COPYING ChangeLog NEWS README $PKG/usr/doc/$NAME
# Copy slack-desc file
install -D -m 644 $CWD/slack-desc $PKG/install/slack-desc
# Add dependency infos
cat <<EOF > $PKG/install/slack-required
argon2
cryptopp
ffmpeg
jsoncpp
libdbus-c++
libgsm
msgpack-c
opus
restbed
speex
yaml-cpp
EOF
# Package the tree
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/$NAMEPKG-$VERSION-$ARCH-$BUILD.$EXT
rm -rf $PKG
rm -rf $TMP/ring-daemon
"
if type -p fakeroot ; then
echo "$PACKAGING" | fakeroot
else
su -c "$PACKAGING"
fi