# 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://slimdevices.com" #MY_P="SlimServer_v${PV}" MY_P="SlimServer_v6.0b3" SRC_URI="http://www.slimdevices.com/downloads/${MY_P}/${MY_P}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86 ~ppc" RESTRICT="nostrip" IUSE="flac oggvorbis encode mpc shn" # Notes: # - 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 # - Flags "mpc" and "shn" should be use.masked on archs which don't have # media-sound/musepack-tools and media-sound/shorten packages yet. DEPEND=">=dev-lang/perl-5.8.1 >=sys-apps/sed-4" RDEPEND=">=dev-lang/perl-5.8.1 encode? ( >=media-sound/lame-3.96 ) flac? ( >=media-libs/flac-1.1 ) mpc? ( >=media-sound/musepack-tools-1.15s-r1 ) oggvorbis? ( >=media-sound/vorbis-tools-1.0 ) shn? ( >=media-sound/shorten-3.6.0 ) dev-perl/Time-HiRes" # Notes: # - The server uses many other Perl modules, which will also be installed. # We can't really use modules from the Portage tree because their versions # include a lot of small modifications and bugfixes compared to the ones # from CPAN. S="${WORKDIR}/${MY_P}" # Configuration (install path, defaults for the sevice, etc.) SLIM_INSTALL_DIR="/usr/share/slimserver" # Note: should be /usr/lib/slimserver? SLIM_HOME_DIR="/var/lib/slimserver" # Note: should be /home/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="slimserver" SLIM_OTHER_GROUPS="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 SLIM_OTHER_GROUPS" # 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 comment the corresponding rules of conversion, so that the # formats don't even appear in the we interface. sed -i "/^${f_ext}/,+1{s:^:#:}" \ ${S}/convert.conf # Success exit. return 0 fi done # The argument was not a droppable format. return 1 } src_unpack() { unpack ${A} # Don't use the Perl binary modules (only Time::HighRes actually): rm -rf ${S}/CPAN/arch sed -i "/'CPAN','arch'/d" \ ${S}/slimserver.pl # Don't use the provided executable binaries: # sed -i "/'Bin'/d" \ # ${S}/Slim/Utils/Misc.pm # If USE="-encode", then comment mp3 conversion rules use encode \ || sed -i '/^[a-z]/{N;/\[lame\]/{s:\(^\|\n\):\1#:g}}' \ ${S}/convert.conf # 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/ is not installed): dodir "${SLIM_INSTALL_DIR}" local mydir local dirs_list="CPAN 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: the server script really must stay in $SLIM_INSTALL_DIR # (code is full of "use FindBin") exeinto "${SLIM_INSTALL_DIR}" newexe slimserver.pl slimserver # 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 group and user enewgroup ${SLIM_GROUP} local mygroups="${SLIM_GROUP}" [ -n "${SLIM_OTHER_GROUPS}" ] \ && mygroups="${mygroups},${SLIM_OTHER_GROUPS}" enewuser ${SLIM_USER} -1 /bin/false ${SLIM_HOME_DIR} ${mygroups} # 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\")" einfo "You will need to re-compile Perl modules for Slimserver to work," einfo "run /usr/share/slimserver/Bin/build-perl-modules.pl" }