Created
May 28, 2020 17:47
-
-
Save asmod3us/dfe6b795da4c09329d0482da92570df2 to your computer and use it in GitHub Desktop.
forked-daapd build on freenas 11.3 with recent ffmpeg
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
#!/usr/bin/env bash | |
set -o errexit # Exit on most errors | |
set -o errtrace # Make sure any error trap is inherited | |
set -o nounset # Disallow expansion of unset variables | |
set -o pipefail # Use last non-zero exit code in a pipeline | |
trap "ERR during daapd build" ERR | |
# see config.yml for packages | |
# this does not work in a jail. is there an alternative? | |
# sh -c 'echo "fdesc /dev/fd fdescfs rw 0 0" >> /etc/fstab' | |
# sh -c 'echo "proc /proc procfs rw 0 0" >> /etc/fstab' | |
# mount /dev/fd | |
# mount /proc | |
WORKDIR=$(mktemp -d -t daapd) | |
CONFIG=/usr/local/etc/forked-daapd.conf | |
cd "$WORKDIR" | |
ENABLE64BIT="--enable-64bit" | |
PKG_CONFIG_PATH=/usr/local/lib:/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/ffmpeg/lib/pkgconfig | |
export PKG_CONFIG_PATH | |
wget -c --no-check-certificate https://github.com/antlr/website-antlr3/raw/gh-pages/download/antlr-3.4-complete.jar | |
wget -c --no-check-certificate https://github.com/antlr/website-antlr3/raw/gh-pages/download/C/libantlr3c-3.4.tar.gz | |
install antlr-3.4-complete.jar /usr/local/share/java | |
printf "#!/bin/sh | |
export CLASSPATH | |
CLASSPATH=\$CLASSPATH:/usr/local/share/java/antlr-3.4-complete.jar:/usr/local/share/java | |
/usr/local/bin/java org.antlr.Tool \$* | |
" > antlr3 | |
install -m 755 antlr3 /usr/local/bin | |
tar xzf libantlr3c-3.4.tar.gz | |
cd libantlr3c-3.4 | |
./configure $ENABLE64BIT && gmake -j8 && gmake install | |
cd "$WORKDIR" | |
git clone --depth 1 https://github.com/ejurgensen/forked-daapd.git | |
cd forked-daapd | |
autoreconf -vi | |
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/ffmpeg/lib/pkgconfig" | |
export PKG_CONFIG_PATH | |
GEN_CFLAGS="-I/usr/include" | |
LOCAL_CFLAGS="-I/usr/local/include" | |
ZLIB_CFLAGS=$GEN_CFLAGS | |
ZLIB_LIBS="-lz" | |
export ZLIB_CFLAGS ZLIB_LIBS | |
CONFUSE_CFLAGS=$LOCAL_CFLAGS | |
CONFUSE_LIBS="-L/usr/local/lib -lconfuse" | |
export CONFUSE_CFLAGS | |
export CONFUSE_LIBS | |
MINIXML_CFLAGS=$LOCAL_CFLAGS | |
MINIXML_LIBS="-L/usr/local/lib -lmxml" | |
export MINIXML_CFLAGS MINIXML_LIBS | |
SQLITE3_CFLAGS=$LOCAL_CFLAGS | |
SQLITE3_LIBS="-L/usr/local/lib -lsqlite3" | |
export SQLITE3_CFLAGS SQLITE3_LIBS | |
LIBEVENT_CFLAGS=$LOCAL_CFLAGS | |
LIBEVENT_LIBS="-L/usr/local/lib -levent" | |
export LIBEVENT_CFLAGS LIBEVENT_LIBS | |
JSON_C_CFLAGS="-I/usr/local/include/json-c" | |
JSON_C_LIBS="-L/usr/local/lib -ljson-c" | |
export JSON_C_CFLAGS JSON_C_LIBS | |
LIBAV_CFLAGS="-I/usr/local/ffmpeg/include" | |
LIBAV_LIBS="-L/usr/local/ffmpeg/lib -aac -lasound -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lfdk-aac -lpostproc -lswresample -lswscale -lx264 -lx265 -L/usr/local/lib -drm -lX11 -lXau -lXdmcp -lao -lbz2 -lc++ -ldl -lexpat -lfontconfig -lfreetype -lfribidi -lgcc -lgcc_s -liconv -llzma -lm -lpthread -lrt -lva -lvdpau -lxcb -lz -pthread -render -shape -shm -xfixes" | |
AVAHI_CFLAGS=$LOCAL_CFLAGS | |
AVAHI_LIBS="-L/usr/local/lib -lavahi-common -lavahi-client" | |
export AVAHI_CFLAGS AVAHI_LIBS | |
LIBPLIST_CFLAGS=$LOCAL_CFLAGS | |
LIBPLIST_LIBS="-L/usr/local/lib -lplist" | |
export LIBPLIST_CFLAGS LIBPLIST_LIBS | |
LIBSODIUM_CFLAGS=$LOCAL_CFLAGS | |
LIBSODIUM_LIBS="-L/usr/local/lib -lsodium" | |
export LIBSODIUM_CFLAGS LIBSODIUM_LIBS | |
LIBWEBSOCKETS_CFLAGS=$LOCAL_CFLAGS | |
LIBWEBSOCKETS_LIBS="-L/usr/local/lib -lwebsockets" | |
export LIBWEBSOCKETS_CFLAGS LIBWEBSOCKETS_LIBS | |
CFLAGS="-I/usr/local/include" | |
LDFLAGS="-L/usr/local/lib -lz -lmxml -ldns_sd -L/usr/local/ffmpeg/lib -lasound -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lfdk-aac -lpostproc -lswresample -lswscale -lx264 -lx265" | |
export CFLAGS LDFLAGS | |
./configure && gmake -j8 | |
if [ -f $CONFIG ]; then | |
echo "Backing up old config file to $CONFIG.bak" | |
cp "$CONFIG" "$CONFIG.bak" | |
fi | |
gmake install | |
sed -i -- 's/\/var\/cache/\/usr\/local\/var\/cache/g' $CONFIG | |
# Setup user and startup scripts | |
echo "daapd::::::forked-daapd:/nonexistent:/usr/sbin/nologin:" | adduser -w no -D -f - | |
chown -R daapd:daapd /usr/local/var/cache/forked-daapd | |
if [ ! -f scripts/freebsd_start_10.1.sh ]; then | |
echo "Could not find FreeBSD startup script" | |
exit | |
fi | |
install -m 755 scripts/freebsd_start_10.1.sh /usr/local/etc/rc.d/forked-daapd |
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
#!/usr/bin/env bash | |
# This is based on a script by Glorious1 and HJD from | |
# https://www.ixsystems.com/community/threads/how-to-install-ffmpeg-in-a-jail.39818/ | |
# It was modified to build on 11.3 and run without user input by asmod3us. | |
set -o errexit # Exit on most errors | |
set -o errtrace # Make sure any error trap is inherited | |
set -o nounset # Disallow expansion of unset variables | |
set -o pipefail # Use last non-zero exit code in a pipeline | |
trap "ERR during ffmpeg build" ERR | |
CORES=$(sysctl -n hw.ncpu) | |
# see config.yml for packages | |
export CC=/usr/bin/clang | |
export CXX=/usr/bin/clang++ | |
export PATH=$PATH:/usr/local/share | |
export PKG_CONFIG_PATH=/usr/local/lib:/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig | |
BUILD=$(mktemp -d -t ffmpeg) | |
TARGET=/usr/local/ffmpeg | |
export PATH=$PATH:${TARGET}/bin | |
rm -f /usr/local/lib/libavcodec* /usr/local/lib/libx2* | |
mkdir -p "${BUILD}" ${TARGET} | |
git clone --depth 1 https://github.com/mstorsjo/fdk-aac "$BUILD"/fdk-aac/ | |
git clone --depth 1 https://anongit.freedesktop.org/git/pkg-config "$BUILD"/pkg-config/ | |
git clone --depth 1 http://git.videolan.org/git/x264.git "$BUILD"/x264/ | |
hg clone http://hg.videolan.org/x265 "$BUILD"/x265/ | |
git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git "$BUILD"/ffmpeg/ | |
cd "$BUILD"/fdk-aac | |
# There is no configure file anymore so have to make it with autoreconf | |
autoreconf -fiv && \ | |
./configure --prefix="$TARGET" --disable-shared && \ | |
make -j"$CORES" && \ | |
make install | |
cd "$BUILD"/pkg-config | |
sed -i '' -e 's/m4_copy(/m4_copy_force(/' glib/m4macros/glib-gettext.m4 | |
./autogen.sh --with-internal-glib --prefix="$TARGET" --exec-prefix="$TARGET" | |
make -j"$CORES" install clean | |
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$TARGET/lib/pkgconfig | |
cd "$BUILD"/x264 | |
sed -i '' -e 's|#\!/bin/bash|#\!/usr/bin/env bash|' configure | |
./configure --prefix=$TARGET --enable-static --enable-pic | |
gmake -j"$CORES" | |
gmake install clean | |
cd "$BUILD"/x265/build/linux | |
# shellcheck disable=SC2016 | |
sed -i '' -E \ | |
-e '/cd 12bit/,/cmake/ s|^cmake|cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++|' \ | |
-e '/cd \.\.\/8bit/,/cmake/ s|^cmake \.\./\.\./\.\./source|cmake -DCMAKE_INSTALL_PREFIX=/usr/local/ffmpeg/ ../../../source -DENABLE_SHARED=OFF|' \ | |
-e 's/cmake/cmake -j'"$CORES"'/' \ | |
-e 's/(if \[ "\$uname" = "Linux" \])/\1 | [ "$uname" = "FreeBSD" ]/' multilib.sh | |
./multilib.sh | |
cd 8bit | |
make -j"$CORES" install | |
cp -v ${TARGET}/lib/libx265* /usr/local/lib | |
cd "$BUILD"/ffmpeg | |
export CFLAGS="-I${TARGET}/include -I/usr/local/include -I/usr/include" | |
export LDFLAGS="-L${TARGET}/lib -L/usr/local/lib -L/usr/lib" | |
export PKG_CONFIG_PATH=${TARGET}/lib:$TARGET/lib/pkgconfig:${PKG_CONFIG_PATH} | |
./configure prefix=$TARGET --cc=/usr/bin/clang \ | |
--extra-cflags="-I$TARGET/include" --extra-ldflags="-L$TARGET/lib" \ | |
--extra-libs=-lpthread \ | |
--pkg-config-flags="--static" \ | |
--enable-static --disable-shared --enable-libfdk-aac --enable-libx264 \ | |
--enable-libx265 --enable-libfreetype --enable-libfontconfig \ | |
--enable-libfribidi --enable-nonfree --enable-gpl --enable-version3 \ | |
--enable-hardcoded-tables --enable-avfilter --enable-filters --disable-outdevs \ | |
--disable-network --enable-libopus --enable-libsoxr | |
gmake -j"$CORES" | |
gmake install |
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
#!/usr/bin/env sh | |
# deps | |
DEPS=curl alsa-lib avahi avahi-libdns fontconfig fribidi gettext json-c libconfuse libevent libgcrypt libiconv libinotify libplist libsodium libsoxr libunistring libwebsockets nss_mdns openjdk8-jre pkgconf sqlite sqlite3 | |
pkg install -y $DEPS | |
# build deps | |
BUILDDEPS=bash autoconf automake autotools cmake git glib gmake gperf iconv libtool mercurial mxml nasm opus rsync wget yasm | |
pkg install -y $BUILDDEPS | |
./build-ffmpeg.sh | |
./build-daapd.sh | |
pkg delete -f $BUILDDEPS | |
if ! service forked-daapd enabled; then | |
sh -c 'echo "forked_daapd_enable=\"YES\"" >> /etc/rc.conf' | |
fi | |
if ! service dbus enabled; then | |
sh -c 'echo "dbus_enable=\"YES\"" >> /etc/rc.conf' | |
fi | |
service dbus start | |
if ! service avahi-daemon enabled; then | |
sh -c 'echo "avahi_daemon_enable=\"YES\"" >> /etc/rc.conf' | |
fi | |
service dbus restart | |
service avahi-daemon restart | |
service forked-daapd restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment