Remove FreeBSD/OSS4 hacks and add FreeBSD 10.1 install and startup helper scripts (issue #94)

This commit is contained in:
ejurgensen 2015-02-11 22:58:54 +01:00
parent d542ab9c98
commit 3cd7b27bac
6 changed files with 212 additions and 65 deletions

View File

@ -50,6 +50,15 @@ Finally, read the bit in the bottom of this document about init scripts, read
the README, edit the configuration file and restart the server.
Quick version for FreeBSD 10+
-----------------------------
The build process for FreeBSD is rather complicated, but the good news is that
there is a script in the 'scripts' folder that will at least attempt to do all
the work for you. And should the script not work for you, you can still look
through it and use it as an installation guide.
Long version - requirements
---------------------------

View File

@ -71,45 +71,30 @@ AC_ARG_ENABLE(lastfm, AS_HELP_STRING([--enable-lastfm], [enable LastFM support (
use_lastfm=true;
CPPFLAGS="${CPPFLAGS} -DLASTFM")
case "$host" in
*-*-linux-*)
use_oss4=false
;;
*-*-kfreebsd*-*|*-*-freebsd*)
use_oss4=true
;;
esac
AC_ARG_WITH(oss4, AS_HELP_STRING([--with-oss4], [use OSS4 (default Linux=no, FreeBSD=yes)]),
use_oss4=true;
)
AC_ARG_WITH(alsa, AS_HELP_STRING([--with-alsa], [use ALSA (default Linux=yes, FreeBSD=no)]),
use_oss4=false;
)
AM_CONDITIONAL(COND_FLAC, test x$use_flac = xtrue)
AM_CONDITIONAL(COND_MUSEPACK, test x$use_musepack = xtrue)
AM_CONDITIONAL(COND_ITUNES, test x$use_itunes = xtrue)
AM_CONDITIONAL(COND_SPOTIFY, test x$use_spotify = xtrue)
AM_CONDITIONAL(COND_LASTFM, test x$use_lastfm = xtrue)
AC_ARG_WITH(oss4, AS_HELP_STRING([--with-oss4=includedir], [use OSS4 with soundcard.h in includedir (default /usr/lib/oss/include/sys)]),
[ case "$withval" in
no)
case "$host" in
*-*-linux-*)
use_oss4=false
;;
*-*-kfreebsd*-*|*-*-freebsd-*)
AC_MSG_ERROR([OSS4 must be enabled on FreeBSD systems])
;;
esac
;;
yes)
use_oss4=true
oss4_includedir=/usr/lib/oss/include/sys
;;
[[\\/$]]* | ?:[[\\/]]* )
use_oss4=true
oss4_includedir="$withval"
;;
*)
AC_MSG_ERROR([expected an absolute directory name for --with-oss4: $withval])
;;
esac ],
[ case "$host" in
*-*-linux-*)
use_oss4=false
;;
*-*-kfreebsd*-*|*-*-freebsd-*)
use_oss4=true
oss4_includedir=/usr/lib/oss/include/sys
;;
esac ])
AM_CONDITIONAL(COND_OSS4, test x$use_oss4 = xtrue)
AM_CONDITIONAL(COND_ALSA, test x$use_oss4 != xtrue)
dnl Checks for libraries.
gl_LIBUNISTRING
@ -240,38 +225,24 @@ if test x$use_lastfm = xtrue; then
AC_DEFINE(HAVE_MXML_GETOPAQUE, 1, [Define to 1 if your mxml has mxmlGetOpaque.]))
fi
case "$host" in
*-*-linux-*)
if test x$use_oss4 != xtrue; then
use_alsa=true
if test x$use_oss4 != xtrue; then
PKG_CHECK_MODULES(ALSA, [ alsa ])
AC_DEFINE(LAUDIO_USE_ALSA, 1, [define if local audio output uses ALSA])
fi
AC_CHECK_HEADERS([sys/eventfd.h])
AC_CHECK_FUNC(eventfd_write, AC_DEFINE(HAVE_EVENTFD, 1, [Define to 1 if you have eventfd]))
AC_CHECK_HEADER(sys/signalfd.h, , AC_MSG_ERROR([signalfd required; glibc 2.9+ recommended]))
AC_CHECK_HEADER(sys/timerfd.h, , AC_MSG_ERROR([timerfd required; glibc 2.8+ recommended]))
AC_CHECK_FUNC(timerfd_create, , AC_MSG_ERROR([timerfd required; glibc 2.8+ recommended]))
;;
esac
if test x$use_oss4 = xtrue; then
OSS4CPPFLAGS="-I$oss4_includedir"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$OSS4CPPFLAGS"
AC_CHECK_HEADER(soundcard.h, , AC_MSG_ERROR([soundcard.h not found in $oss4_includedir]))
CPPFLAGS="$save_CPPFLAGS"
else
AC_CHECK_HEADER(sys/soundcard.h, , AC_MSG_ERROR([sys/soundcard.h not found]))
fi
AM_CONDITIONAL(COND_ALSA, test x$use_alsa = xtrue)
AM_CONDITIONAL(COND_OSS4, test x$use_oss4 = xtrue)
AC_SUBST(OSS4CPPFLAGS)
case "$host" in
*-*-linux-*)
AC_CHECK_HEADERS([sys/eventfd.h])
AC_CHECK_FUNC(eventfd_write, AC_DEFINE(HAVE_EVENTFD, 1, [Define to 1 if you have eventfd]))
AC_CHECK_HEADER(sys/signalfd.h, , AC_MSG_ERROR([signalfd required; glibc 2.9+ recommended]))
AC_CHECK_HEADER(sys/timerfd.h, , AC_MSG_ERROR([timerfd required; glibc 2.8+ recommended]))
AC_CHECK_FUNC(timerfd_create, , AC_MSG_ERROR([timerfd required; glibc 2.8+ recommended]))
;;
esac
AC_CHECK_SIZEOF(void *)

143
scripts/freebsd_install_10.1.sh Executable file
View File

@ -0,0 +1,143 @@
#!/bin/sh
# Credit thorsteneckel who made the how-to that is the basis for this
# script, see https://gist.github.com/thorsteneckel/c0610fb415c8d0486bce
echo "This script will install forked-daapd in FreeBSD 10.1. The script is not"
echo "very polished, so you might want to look through it before running it."
read -p "Continue? [y/N] " yn
if [ "$yn" != "y" ]; then
exit
fi
DEPS="gmake autoconf automake libtool gettext gperf glib pkgconf wget git \
ffmpeg libconfuse libevent2 mxml libgcrypt libunistring libiconv \
libplist avahi sqlite3"
echo "The script can install the following dependency packages for you:"
echo $DEPS
read -p "Should the script install these packages? [y/N] " yn
if [ "$yn" == "y" ]; then
sudo pkg install $DEPS;
fi
JRE="openjdk8-jre"
read -p "Should the script install $JRE for you? [y/N] " yn
if [ "$yn" == "y" ]; then
sudo pkg install $JRE;
read -p "Should the script add the mount points to /etc/fstab that $JRE requests? [y/N] " yn
if [ "$yn" == "y" ]; then
sudo sh -c 'echo "fdesc /dev/fd fdescfs rw 0 0" >> /etc/fstab'
sudo sh -c 'echo "proc /proc procfs rw 0 0" >> /etc/fstab'
sudo mount /dev/fd
sudo mount /proc
fi
fi
WORKDIR=~/forked-daapd_build
CONFIG=/usr/local/etc/forked-daapd.conf
read -p "Should the script create $WORKDIR and use it for building? [Y/n] " yn
if [ "$yn" == "n" ]; then
exit
fi
mkdir -p $WORKDIR
if [ ! -d $WORKDIR ]; then
echo "Error creating $WORKDIR"
exit
fi
cd $WORKDIR
read -p "Should the script install libavl, antlr and libantlr3c? [y/N] " yn
if [ "$yn" == "y" ]; then
wget http://ftp.debian.org/debian/pool/main/liba/libavl/libavl_0.3.5.orig.tar.gz
wget --no-check-certificate https://github.com/antlr/website-antlr3/raw/gh-pages/download/antlr-3.4-complete.jar
wget --no-check-certificate https://github.com/antlr/website-antlr3/raw/gh-pages/download/C/libantlr3c-3.4.tar.gz
sudo mv 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/share/java
/usr/local/openjdk8-jre/bin/java org.antlr.Tool \$*
" > antlr3
chmod a+x antlr3
sudo mv antlr3 /usr/local/bin
tar xzf libantlr3c-3.4.tar.gz
cd libantlr3c-3.4
./configure && gmake && sudo gmake install
cd $WORKDIR
tar xzf libavl_0.3.5.orig.tar.gz
cd avl-0.3.5
sed -i -- 's/LIBRARIES/LIBRARY/g' GNUmakefile
gmake && sudo gmake install
cd $WORKDIR
fi
read -p "Should the script build forked-daapd? [y/N] " yn
if [ "$yn" == "y" ]; then
git clone https://github.com/ejurgensen/forked-daapd.git
cd forked-daapd
#Cleanup in case this is a re-run
gmake clean
git clean -f
autoreconf -vi
#These should no longer be required, but if you run into trouble you can try enabling them
#export CC=cc
#export LIBUNISTRING_CFLAGS=-I/usr/include
#export LIBUNISTRING_LIBS=-L/usr/lib
#export ZLIB_CFLAGS=-I/usr/include
#export ZLIB_LIBS=-L/usr/lib
export CFLAGS="-march=native -g -Ofast -pipe -I/usr/local/include -I/usr/include"
export LDFLAGS="-L/usr/local/lib -L/usr/lib"
./configure --build=i386-portbld-freebsd10.1 && gmake
read -p "Should the script install forked-daapd and add service startup scripts? [y/N] " yn
if [ "$yn" == "y" ]; then
if [ -f $CONFIG ]; then
echo "Backing up old config file to $CONFIG.bak"
sudo cp "$CONFIG" "$CONFIG.bak"
fi
sudo gmake install
sudo sed -i -- 's/\/var\/cache/\/usr\/local\/var\/cache/g' $CONFIG
# Setup user and startup scripts
echo "daapd::::::forked-daapd:/nonexistent:/usr/sbin/nologin:" | sudo adduser -w no -D -f -
sudo 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
sudo cp scripts/freebsd_start_10.1.sh /usr/local/etc/rc.d/forked-daapd
sudo chmod a+x /usr/local/etc/rc.d/forked-daapd
service forked-daapd enabled
if [ $? -ne 0 ]; then
sudo sh -c 'echo "forked_daapd_enable=\"YES\"" >> /etc/rc.conf'
fi
fi
cd $WORKDIR
fi
read -p "Should the script enable and start dbus and avahi-daemon? [y/N] " yn
if [ "$yn" == "y" ]; then
service dbus enabled
if [ $? -ne 0 ]; then
sudo sh -c 'echo "dbus_enable=\"YES\"" >> /etc/rc.conf'
fi
sudo service dbus start
service avahi-daemon enabled
if [ $? -ne 0 ]; then
sudo sh -c 'echo "avahi_daemon_enable=\"YES\"" >> /etc/rc.conf'
fi
sudo service avahi-daemon start
fi
read -p "Should the script (re)start forked-daapd and display the log output? [y/N] " yn
if [ "$yn" == "y" ]; then
sudo service forked-daapd restart
tail -f /var/log/forked-daapd.log
fi

View File

@ -0,0 +1,25 @@
#!/bin/sh
# PROVIDE: forked-daapd
# REQUIRE: avahi_daemon dbus
# Add the following lines to /etc/rc.conf to enable `forked-daapd':
#
# forked_daapd_enable="YES"
# forked_daapd_flags="<set as needed>"
. /etc/rc.subr
name="forked_daapd"
rcvar=`set_rcvar`
command="/usr/local/sbin/forked-daapd"
command_args="-P /var/run/forked-daapd.pid"
pidfile="/var/run/forked-daapd.pid"
required_files="/usr/local/etc/forked-daapd.conf"
# read configuration and set defaults
load_rc_config "$name"
: ${forked_daapd_enable="NO"}
run_rc_command "$1"

View File

@ -76,8 +76,7 @@ ANTLR_PRODUCTS =
forked_daapd_CPPFLAGS = -D_GNU_SOURCE \
-DDATADIR="\"$(pkgdatadir)\"" -DCONFDIR="\"$(sysconfdir)\"" \
-DSTATEDIR="\"$(localstatedir)\"" -DPKGLIBDIR="\"$(pkglibdir)\"" \
@OSS4CPPFLAGS@
-DSTATEDIR="\"$(localstatedir)\"" -DPKGLIBDIR="\"$(pkglibdir)\""
forked_daapd_CFLAGS = \
@ZLIB_CFLAGS@ @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @LIBAV_CFLAGS@ \

View File

@ -32,7 +32,7 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <soundcard.h>
#include <sys/soundcard.h>
#include "conffile.h"
#include "logger.h"