net-libs/spectrum/spectrum-1.4.7.ebuild
changeset 223 170b7f18863e
parent 222 8d5962438a43
child 224 9fd7aa2f35be
equal deleted inserted replaced
222:8d5962438a43 223:170b7f18863e
     1 # Copyright 1999-2010 Gentoo Foundation
       
     2 # Distributed under the terms of the GNU General Public License v2
       
     3 # $Header: $
       
     4 EAPI=2
       
     5 
       
     6 inherit cmake-utils
       
     7 
       
     8 DESCRIPTION="Spectrum is an XMPP transport/gateway"
       
     9 HOMEPAGE="http://spectrum.im"
       
    10 
       
    11 SRC_URI="http://spectrum.im/attachments/download/37/spectrum-${PV}.tar.gz"
       
    12 
       
    13 LICENSE="GPL-2"
       
    14 SLOT="0"
       
    15 KEYWORDS="~amd64 ~x86"
       
    16 
       
    17 IUSE="mysql sqlite symlinks tools staticport"
       
    18 
       
    19 RDEPEND=">=dev-libs/poco-1.3.3[mysql?,sqlite?]
       
    20 	media-gfx/imagemagick[cxx]
       
    21         >=net-im/pidgin-2.6.0
       
    22         >=net-libs/gloox-1.0
       
    23         dev-python/xmpppy"
       
    24 DEPEND="${RDEPEND}
       
    25         sys-devel/gettext
       
    26         dev-util/cmake"
       
    27 
       
    28 PROTOCOL_LIST="aim facebook gg icq irc msn msn_pecan myspace qq simple sipe twitter xmpp yahoo"
       
    29 
       
    30 pkg_setup() {
       
    31 	if ! ( use sqlite || use mysql ); then
       
    32 		ewarn "No database use flag set!"
       
    33 		ewarn "You need to enable the mysql or sqlite use flag!"
       
    34 		die
       
    35 	fi
       
    36 }
       
    37 
       
    38 src_install () {
       
    39 	cmake-utils_src_install
       
    40 
       
    41 	# Install transports with seperate config files (default).
       
    42 	# If USE="symlinks" is set, install one config file with symlinks to all transports.
       
    43 
       
    44 	port=5347
       
    45 
       
    46 	# prepare config for mysql or just copy
       
    47 	cp "${FILESDIR}/spectrum.cfg" "${WORKDIR}/spectrum.cfg"
       
    48 
       
    49 	if use mysql ; then
       
    50 	sed -e 's,^\(type\)=sqlite$,\1=mysql,' \
       
    51 		-e 's,^#\(host=localhost\)$,\1,' \
       
    52 		-e 's,^#\(user=user\)$,\1,' \
       
    53 		-e 's,^#\(password=password\)$,\1,' \
       
    54 		-e 's,^\(database=.*\),#\1,' \
       
    55 		-e 's,^#\(prefix=.*\),\1,' \
       
    56 		-i "${WORKDIR}/spectrum.cfg" || die
       
    57 	fi
       
    58 
       
    59 	# install shared-config when using symlinks
       
    60 	if use symlinks; then
       
    61 		insinto /etc/spectrum
       
    62 		newins "${WORKDIR}"/spectrum.cfg spectrum-shared-conf || die
       
    63 	fi
       
    64 
       
    65 	# install protocol-specific configs or symlinks
       
    66 	insinto /etc/spectrum
       
    67 	for protocol in ${PROTOCOL_LIST}; do
       
    68 		if use symlinks; then
       
    69 			dosym spectrum-shared-conf "/etc/spectrum/${protocol}:${port}.cfg" || die
       
    70 			sed -e 's,PROTOCOL,'${protocol}:${port}',g' \
       
    71 				"${FILESDIR}"/spectrum.confd > "${WORKDIR}"/spectrum.confd
       
    72 		else
       
    73 			sed -e 's,\$filename:protocol,'${protocol}',g' \
       
    74 				-e 's,\$filename:port,'${port}',g' \
       
    75 				"${WORKDIR}"/spectrum.cfg > "${WORKDIR}/${protocol}.cfg" || die
       
    76 			sed -e 's,PROTOCOL,'${protocol}',g' \
       
    77 				"${FILESDIR}"/spectrum.confd > "${WORKDIR}"/spectrum.confd
       
    78 			doins "${WORKDIR}/${protocol}.cfg" || die
       
    79 		fi
       
    80 
       
    81 		# install prepared confd
       
    82 		newconfd "${WORKDIR}"/spectrum.confd spectrum.${protocol} || die
       
    83 
       
    84 		if ! use staticport; then
       
    85 			port=$[${port}+1]
       
    86 		fi
       
    87 	done
       
    88 
       
    89 	# Install init files
       
    90 	newinitd "${FILESDIR}"/spectrum.initd spectrum || die
       
    91 	for protocol in ${PROTOCOL_LIST}; do
       
    92 		dosym spectrum /etc/init.d/spectrum."${protocol}"
       
    93 	done
       
    94 
       
    95 	# Directories
       
    96 	dodir "/var/lib/spectrum" || die
       
    97 	dodir "/var/log/spectrum" || die
       
    98 	dodir "/var/run/spectrum" || die
       
    99 
       
   100 	# Directories for each transport
       
   101 	for protocol in ${PROTOCOL_LIST}; do
       
   102 		dodir "/var/lib/spectrum/$protocol/database" || die
       
   103 		dodir "/var/lib/spectrum/$protocol/userdir" || die
       
   104 		dodir "/var/lib/spectrum/$protocol/filetransfer_cache" || die
       
   105 	done
       
   106 
       
   107 	# Install mysql schema
       
   108 	if use mysql; then
       
   109 		insinto "/usr/share/spectrum/schemas"
       
   110 		doins schemas/* || die
       
   111 	fi
       
   112 
       
   113 	# Install misc tools
       
   114 	if use tools; then
       
   115 		insinto "/usr/share/spectrum/tools"
       
   116 		doins tools/* || die
       
   117 	fi
       
   118 }
       
   119 
       
   120 pkg_postinst() {
       
   121 	# Set correct rights
       
   122 	chown jabber:jabber -R "/etc/spectrum" || die
       
   123 	chown jabber:jabber -R "/var/lib/spectrum" || die
       
   124 	chown jabber:jabber -R "/var/log/spectrum" || die
       
   125 	chown jabber:jabber -R "/var/run/spectrum" || die
       
   126 	chmod 750 "/etc/spectrum" || die
       
   127 	chmod 750 "/var/lib/spectrum" || die
       
   128 	chmod 750 "/var/log/spectrum" || die
       
   129 	chmod 750 "/var/run/spectrum" || die
       
   130 }