bigbluebutton-Github/build/packages-template/bbb-freeswitch-core/build.sh

169 lines
4.0 KiB
Bash
Raw Normal View History

2021-08-13 18:53:18 +08:00
#!/bin/bash -ex
TARGET=`basename $(pwd)`
PACKAGE=$(echo $TARGET | cut -d'_' -f1)
VERSION=$(echo $TARGET | cut -d'_' -f2)
DISTRO=$(echo $TARGET | cut -d'_' -f3)
#
# Clear staging directory for build
rm -rf staging
#
# Create directory for fpm to process
#DIRS="/opt/freeswitch \
# /var/freeswitch/meetings"
#for dir in $DIRS; do
# mkdir -p staging$dir
# DIRECTORIES="$DIRECTORIES --directories $dir"
#done
##
. ./opts-$DISTRO.sh
#cp modules.conf freeswitch
#cd freeswitch
#
# Need to figure out how to build with mod_av
if [ $DISTRO == "centos7" ] || [ $DISTRO == "amzn2" ]; then
sed -i 's/applications\/mod_av/#applications\/mod_av/g' modules.conf
else
apt-get update
apt-get install -y software-properties-common
add-apt-repository -y ppa:bigbluebutton/support
fi
if [ "$DISTRO" == "bionic" ]; then
add-apt-repository ppa:bigbluebutton/support -y
2021-08-13 18:53:18 +08:00
apt-get update
apt-get install -y libopusfile-dev opus-tools libopusenc-dev
fi
mkdir -p staging
pushd .
# sofia-sip start
2021-08-13 18:53:18 +08:00
if [ ! -d sofia-sip ]; then
git clone https://github.com/freeswitch/sofia-sip.git
fi
cd sofia-sip/
git pull
./bootstrap.sh
./configure
2021-08-13 18:53:18 +08:00
make -j $(nproc)
make install
cd ..
# sofia-sip end
2021-08-13 18:53:18 +08:00
# spandsp start
2021-08-13 18:53:18 +08:00
if [ ! -d spandsp ]; then
git clone https://github.com/freeswitch/spandsp.git
fi
cd spandsp/
git pull
./bootstrap.sh
./configure
make -j $(nproc)
make install
if [ $DISTRO == "centos7" ] || [ $DISTRO == "amzn2" ]; then
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
yum install -y opusfile-devel
git clone https://github.com/xiph/libopusenc.git
cd libopusenc/
./autogen.sh
./configure
make -j $(nproc)
make install
fi
popd
# spandsp end
2021-08-13 18:53:18 +08:00
ldconfig
# we already cloned the FS repo in freeswitch.placeholder.sh
2021-08-13 18:53:18 +08:00
patch -p0 < floor.patch
2021-08-13 18:53:18 +08:00
./bootstrap.sh
2021-08-13 18:53:18 +08:00
./configure --disable-core-odbc-support --disable-core-pgsql-support \
--without-python --without-erlang --without-java \
--prefix=/opt/freeswitch CFLAGS="-Wno-error -Og -ggdb" CXXFLAGS="-Wno-error -Og -ggdb"
make -j $(nproc)
make install
DESTDIR=staging
CONFDIR=$DESTDIR/opt/freeswitch/etc/freeswitch
mkdir -p $DESTDIR/opt
cp -r /opt/freeswitch staging/opt
mkdir -p $DESTDIR/lib/systemd/system
cp freeswitch.service.${DISTRO} $DESTDIR/lib/systemd/system/freeswitch.service
mkdir -p $DESTDIR/lib/systemd/system
cp freeswitch.conf $DESTDIR/lib/systemd/system
mkdir -p $DESTDIR/var/freeswitch/meetings
echo "This directory holds *.wav files for FreeSWITCH" > $DESTDIR/var/freeswitch/meetings/readme.txt
rm -rf $CONFDIR/*
cp -r config/freeswitch/conf/* $CONFDIR
pushd $DESTDIR/opt/freeswitch
ln -s ./etc/freeswitch conf
ln -s ./var/log/freeswitch log
popd
# Install libraries for sofia-sip and spandsp
mkdir -p $DESTDIR/etc/ld.so.conf.d
cat > $DESTDIR/etc/ld.so.conf.d/freeswitch.conf << HERE
/opt/freeswitch/lib
HERE
files="sip-date sip-dig sip-options stunc addrinfo localinfo"
for file in $files; do
cp /usr/local/bin/$file $DESTDIR/opt/freeswitch/bin
done
cp -P /usr/local/lib/lib* $DESTDIR/opt/freeswitch/lib
if [ -f /etc/system-release ]; then
cp /usr/lib64/libopusfile.so.0.4.4 $DESTDIR/opt/freeswitch/lib
cp /usr/lib64/libopusurl.so.0.4.4 $DESTDIR/opt/freeswitch/lib
pushd $DESTDIR/opt/freeswitch/lib
ln -s libopusfile.so.0.4.4 libopusfile.so
ln -s libopusurl.so.0.4.4 libopusurl.so
popd
fi
mkdir -p $DESTDIR/usr/local/bin
cp fs_clibbb $DESTDIR/usr/local/bin
chmod +x $DESTDIR/usr/local/bin/fs_clibbb
rm -rf $DESTDIR/usr/lib/tmpfiles.d
# Needed for Edge
# find $DESTDIR/etc/freeswitch -name "*.xml" -exec sed -i 's/ <param name="nonce-ttl" value="60"\/>/ <!--<param name="nonce-ttl" value="60"\/>-->/g' '{}' \;
fpm -s dir -C $DESTDIR -n $PACKAGE \
--version $VERSION --epoch 2 \
--before-install before-install.sh \
--after-install after-install.sh \
--before-remove before-remove.sh \
--after-remove after-remove.sh \
--description "BigBlueButton build of FreeSWITCH" \
$DIRECTORIES \
$OPTS