# 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 device ." HOMEPAGE="http://slimdevices.com" MY_P="SlimServer_v${PV}" SRC_URI="http://slimdevices.com/downloads/${MY_P}/${MY_P}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86 ~ppc" RESTRICT="nostrip" # For profiles/use.local.desc: # media-sound/slimserver:mpc - Adds support for Musepack audio files # media-sound/slimserver:shn - Adds support for Shorten audio files IUSE="flac oggvorbis encode mpc shn" # Note: "mpc" and "shn" flags should probably be masked on some archs. DEPEND=">=dev-lang/perl-5.8.1 >=sys-apps/sed-4" RDEPEND=">=dev-lang/perl-5.8.1 >=dev-perl/libwww-perl-5.800 encode? ( >=media-sound/lame-3.96 ) flac? ( >=media-libs/flac-1.1 dev-perl/Audio-FLAC-Header ) mpc? ( >=media-sound/musepack-tools-1.15s-r1 dev-perl/Audio-Musepack ) oggvorbis? ( >=media-sound/vorbis-tools-1.0 dev-perl/Ogg-Vorbis-Header-PurePerl ) shn? ( >=media-sound/shorten-3.6.0 ) dev-perl/Audio-Wav dev-perl/MP3-Info dev-perl/Tie-RegexpHash dev-perl/Class-DBI dev-perl/DBIx-ContextualFetch dev-perl/File-Spec dev-perl/File-Which dev-perl/Getopt-Long dev-perl/HTML-Parser dev-perl/IO-String dev-perl/MIME-Base64 dev-perl/Storable dev-perl/Template-Toolkit dev-perl/Time-HiRes dev-perl/URI dev-perl/XML-Parser dev-perl/XML-Simple" # Note: the "mDNSResponderPosix" binary is missing. If needed, it can be # packaged from http://developer.apple.com/darwin/projects/rendezvous/ S="${WORKDIR}/${MY_P}" # Configuration (install path, defaults for the sevice, etc.) SLIM_INSTALL_DIR="/usr/share/slimserver" SLIM_HOME_DIR="/var/lib/slimserver" SLIM_CACHE_DIR="${SLIM_HOME_DIR}/cache" SLIM_MUSIC_DIR="${SLIM_HOME_DIR}/music" SLIM_PLAYLISTS_DIR="${SLIM_HOME_DIR}/playlists" SLIM_LOG_FILE="/var/log/slimserver.log" SLIM_CONFIG_FILE="/etc/slimserver.conf" SLIM_USER="slimserver" SLIM_GROUP="users" # List of vars that are defined in this ebuild but are used in the service # script and its config file. CONFIG_VAR_NAMES="SLIM_INSTALL_DIR SLIM_HOME_DIR SLIM_CACHE_DIR SLIM_MUSIC_DIR SLIM_PLAYLISTS_DIR SLIM_LOG_FILE SLIM_CONFIG_FILE SLIM_USER SLIM_GROUP" # This function set default settings values in init.d and conf.d files. sed_config_file() { local sed_cmd="sed" local var_name var_value # One argument required: [ -z "${1}" -o -z "${CONFIG_VAR_NAMES}" ] && return 2 # Build a sed command to do something like this: # sed -e s::slimserver: ... for var_name in ${CONFIG_VAR_NAMES} ; 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. ${sed_cmd} ${1} } # List of formats for which support may be removed depending on USE flags # and what is available for Gentoo. DROPPABLE_FORMATS="mov:Movie flc:FLAC ogg:Ogg wma:WMA shn:Shorten mpc:Musepack" # This function patch sources to remove support of an audio format. drop_format() { local f_pair f_ext f_name drop_patch # One argument required: [ -z "${1}" -o -z "${DROPPABLE_FORMATS}" ] && return 2 # Search for the supplied argument in the droppable formats list. for f_pair in ${DROPPABLE_FORMATS} ; do f_name=${f_pair//*:/} f_ext=${f_pair//:*/} if [ "${1}" == "${f_name}" -o "${1}" == "${f_ext}" ] ; then einfo "Your SlimServer will not support ${f_name} files (*.${f_ext})" # If a specific patch exists, use it (used for Movie for instance). drop_patch="${FILESDIR}/${P}--drop_${f_name}.patch" [ -f "${drop_patch}" ] \ && ( cd ${S} ; epatch "${drop_patch}" ; ) # In most case, dropping a file format module is as simple as # deleting two lines in two Perl files. sed -i "/Slim::Formats::${f_name}/d" \ ${S}/Slim/Music/{Info,LocalDataSource}.pm # Also remove the corresponding rules of conversion, so that the # formats don't eve appear in the we interface. sed -i "/^${f_ext}/{N;d}" \ ${S}/convert.conf # Success exit. return 0 fi done # The argument was not a droppable format. return 1 } src_unpack() { unpack ${A} # Adds support for a --playlistdir CLI option epatch "${FILESDIR}/${P}--playlistdir_option.patch" # Audio::FLAC:Header from is an updated version of the Audio::FLAC # which was provided with SlimServer-5.4. sed -i 's/Audio::FLAC/Audio::FLAC::Header/g' \ "${S}/Slim/Formats/FLAC.pm" # QuickTime (*.mov) support relies on "mov123", which is not available. drop_format Movie # WMA support relies on "wmadec", which is not available. drop_format WMA # Drop some other formats depending on USE flags use flac || drop_format FLAC use oggvorbis || dropformat Ogg use mpc || drop_format mpc use shn || drop_format shn # Prepare the service script and its config file sed_config_file "${FILESDIR}/slimserver.confd" \ > "${S}/slimserver.confd" sed_config_file "${FILESDIR}/slimserver.initd" \ > "${S}/slimserver.initd" } src_install() { # Base installation - Bin/ and CPAN/ are dropped: dodir "${SLIM_INSTALL_DIR}" local mydir local dirs_list="Firmware Graphics HTML IR Plugins Slim slimp3 SQL" for mydir in ${dirs_list} ; do cp -R "${S}/${mydir}" "${D}${SLIM_INSTALL_DIR}" done insinto "${SLIM_INSTALL_DIR}" doins convert.conf types.conf strings.txt # Note: slimserver.pl really must stay in $SLIM_INSTALL_DIR # (code is full of "use FindBin") exeinto "${SLIM_INSTALL_DIR}" doexe slimserver.pl # Documentation: dodoc Installation.txt License.txt dohtml Changelog.html # Service script and its config dodir /etc/init.d newinitd slimserver.initd slimserver dodir /etc/conf.d newconfd slimserver.confd slimserver } pkg_postinst() { # Create the slimserver user enewuser slimserver -1 /bin/false ${SLIM_HOME_DIR} users # Very quick startup guide. einfo "To start the SlimServer, use \"/etc/init.d/slimserver start\"" einfo "This service can be configured in \"/etc/conf.d/slimserver\"" einfo "To connect to the server web interface, try http://localhost:9000" einfo "A configuration web interface is available (see note in \"/etc/conf.d/slimserver\")" }