# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils DESCRIPTION="Music streaming server for SLIMP3/Squeezebox devices or software players." HOMEPAGE="http://www.slimdevices.com" MY_P="SlimServer_v${PV}" SRC_URI="http://www.slimdevices.com/downloads/${MY_P}/${MY_P}.no-cpan-arch.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86 ~amd64" IUSE="encode ffmpeg aac flac mp3 musepack shorten vorbis wma" # # NOTE: I changed this: shorten is now a global USE flag, and there's # another package that uses "musepack" instead of "mpc". Going for # some consistency that is the insanity of USE flags. # # For profiles/use.local.desc: # media-sound/slimserver:musepack - Adds support for Musepack files # media-sound/slimserver:wma - Configures support for WMA files # # NOTE: Flags "musepack" and "shorten" should be use.masked on archs which # don't have media-sound/musepack-tools and media-sound/shorten # packages yet. # Currently no depends for aac? or shorten? when using FFmpeg DEPEND=">=dev-lang/perl-5.8.1 >=sys-apps/sed-4 >=media-sound/sox-12.17.8 encode? ( >=media-sound/lame-3.96 ) aac? ( media-libs/faad2 ) flac? ( >=media-libs/flac-1.1) mp3? ( >=media-sound/lame-3.96 ) musepack? ( media-sound/musepack-tools ) shorten? ( media-sound/shorten ) vorbis? ( media-sound/sox ) ffmpeg? ( media-video/ffmpeg )" S="${WORKDIR}/${MY_P}" # # Remember our old configuration values, or new user-defined ones, much # like apache does for modules in its ebuild. # [ -f "/etc/conf.d/slimserver" ] && source "/etc/conf.d/slimserver" # # User-configurable variables # SLIM_MUSIC_DIR="${SLIM_MUSIC_DIR:-/srv/music/library}" SLIM_PLAYLISTS_DIR="${SLIM_PLAYLISTS_DIR:-/srv/music/playlists}" SLIM_ITUNES_DIR="${SLIM_ITUNES_DIR:-/srv/music/itunes/iTunes Music}" SLIM_ITUNES_XML="${SLIM_ITUNES_XML:-/srv/music/itunes/iTunes Music Library.xml}" SLIM_ART_DIR="${SLIM_ART_DIR:-/srv/music/artwork}" SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS:-NONE}" SLIM_OUTPUT_FORMATS="${SLIM_OUTPUT_FORMATS:-NONE}" SLIM_DISABLE_SETUP="${SLIM_DISABLE_SETUP:-no}" SLIM_DISABLE_SERVER_SETUP="${SLIM_DISABLE_SERVER_SETUP:-no}" SLIM_HTTP_PORT="${SLIM_HTTP_PORT:-9000}" SLIM_HTTP_ADDR="${SLIM_HTTP_ADDR:-}" SLIM_CLI_PORT="${SLIM_CLI_PORT:-9090}" SLIM_CLI_ADDR="${SLIM_CLI_ADDR:-}" SLIM_PLAYER_ADDR="${SLIM_PLAYER_ADDR:-}" SLIM_STREAM_ADDR="${SLIM_STREAM_ADDR:-}" SLIM_DEBUG="${SLIM_DEBUG:-no}" SLIM_QUIET="${SLIM_QUIET:-yes}" SLIM_PRIORITY="${SLIM_PRIORITY:-0}" SLIM_OPTIONS="${SLIM_OPTIONS:-}" # # List of variables to export to /etc/conf.d/slimserver later # SLIM_CONFIG_VARS="SLIM_MUSIC_DIR SLIM_PLAYLISTS_DIR SLIM_ITUNES_DIR SLIM_ITUNES_XML SLIM_ART_DIR SLIM_INPUT_FORMATS SLIM_OUTPUT_FORMATS SLIM_DISABLE_SETUP SLIM_DISABLE_SERVER_SETUP SLIM_HTTP_PORT SLIM_HTTP_ADDR SLIM_CLI_PORT SLIM_CLI_ADDR SLIM_PLAYER_ADDR SLIM_STREAM_ADDR SLIM_DEBUG SLIM_QUIET SLIM_PRIORITY SLIM_OPTIONS" function configure_default_formats() { if [ "${SLIM_INPUT_FORMATS}" = "NONE" ] then SLIM_INPUT_FORMATS="wav aif" use mp3 && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} mp3" use vorbis && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} ogg" use flac && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} flc" use shorten && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} shn" use musepack && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} mpc" use aac && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} mov" use ffmpeg && \ use wma && SLIM_INPUT_FORMATS="${SLIM_INPUT_FORMATS} wma" fi if [ "${SLIM_OUTPUT_FORMATS}" = "NONE" ] then SLIM_OUTPUT_FORMATS="wav aif" use encode && SLIM_OUTPUT_FORMATS="${SLIM_OUTPUT_FORMATS} mp3" use flac && SLIM_OUTPUT_FORMATS="${SLIM_OUTPUT_FORMATS} flc" fi } # # This function set default settings values in init.d and conf.d files. # # USAGE: replace_env_vars [src_file] [dest_file] # # For each var_name in SLIM_CONFIG_VARS, this function # replaces instances of <> in [src_file] # with the actual value of the environment variable, # and writes the results to [dest_file]. # function replace_env_vars() { local SED_CMD="sed" local VAR_NAME VAR_VALUE # # We require that SLIM_CONFIG_VARS be set, and that we are passed # a valid filename. # if [ ! -f "$1" -o -z "$2" -o -z "${SLIM_CONFIG_VARS}" ] then return 2 fi # Build a sed command to do something like this: # sed -e s:<>:slimserver: ... for VAR_NAME in ${SLIM_CONFIG_VARS} do eval VAR_VALUE="\${${VAR_NAME}}" SED_CMD="${SED_CMD} -e 's:<<${VAR_NAME}>>:${VAR_VALUE}:g'" done # Apply the sed command. Output to stdout. cat "$1" | eval ${SED_CMD} > "$2" } pkg_setup() { if use !encode || use !flac then ewarn "WARNING! You are about to build media-sound/slimserver without" ewarn "either MP3 or FLAC support. Most commonly a Squeezebox or" ewarn "SliMP3 streams in MP3, and newer Squeezebox models are capable" ewarn "of streaming FLAC files directly. You probably do not want to" ewarn "disable these. Here is what you have disabled, and how to" ewarn "fix it:" ewarn "" use !encode && ewarn " MP3 encoding support (USE='encode')" use !flac && ewarn " FLAC encoding support (USE='flac')" ewarn "" sleep 5 fi if use aac && use !ffmpeg then ewarn "WARNING! You are enabling AAC support without using FFmpeg." ewarn "If you want to listen to Apple Lossless files, you need" ewarn "FFmpeg support, as it is the only program capable of decoding" ewarn "Apple lossless files. To fix this warning, enable FFmpeg:" ewarn "" ewarn " FFmpeg support (USE='ffmpeg')" ewarn "" sleep 5 fi if use wma && use !ffmpeg then ewarn "WARNING! You are trying to enable WMA support without FFmpeg!" ewarn "SlimServer cannot handle WMA files unless you enable FFmpeg as" ewarn "a decoder to do this, you neeed to use the following USE flag:" ewarn "" ewarn " FFMpeg support (USE='ffmpeg')" ewarn "" sleep 5 fi enewgroup slimserver enewuser slimserver -1 /bin/false /usr/lib/slimserver slimserver } src_unpack() { unpack ${A} cd ${S} mv Bin/build-perl-modules.pl ${WORKDIR} rm -rf Bin # Shouldn't need the included static binary decoders epatch "${FILESDIR}/${PN}-${PV}.patch" } src_compile() { einfo "Configuring default input and output formats" configure_default_formats einfo "Configuring boot scripts" replace_env_vars "${FILESDIR}/slimserver.confd" \ "${WORKDIR}/slimserver.confd" replace_env_vars "${FILESDIR}/slimserver.initd" \ "${WORKDIR}/slimserver.initd" einfo "Copying format conversion files" if use ffmpeg then cp "${FILESDIR}/formats.conf-ffmpeg" "${WORKDIR}/formats.conf" else cp "${FILESDIR}/formats.conf-other" "${WORKDIR}/formats.conf" fi cp "${FILESDIR}/convert.conf" "${WORKDIR}/convert.conf" einfo "Copying server configuration files" if [ ! -f /var/lib/slimserver/slimserver.conf ] then # Unfortunately, since the SlimServer writes back to this file, # this ugly, un-ebuild-like hack has to remain in place, since # most users won't be able to make any sense out of the extra # lines that SlimServer has added once it starts serving up # music to clients, etc, and I'd rather copy the old config # than have a user accidentally annihilate all of the settings # that they worked so hard to configure. replace_env_vars "${FILESDIR}/slimserver.conf" \ "${WORKDIR}/slimserver.conf" else cp /var/lib/slimserver/slimserver.conf \ "${WORKDIR}/slimserver.conf" fi einfo "Building custom binary CPAN modules" ${WORKDIR}/build-perl-modules.pl <