aboutsummaryrefslogtreecommitdiffstats
path: root/net-im/spectrum/spectrum-1.4.8-r1.ebuild
blob: 2e32141babeedafa0604f23485b2bce7a04959cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="4"

inherit cmake-utils

DESCRIPTION="Spectrum is an XMPP transport/gateway"
HOMEPAGE="http://spectrum.im"

SRC_URI="http://spectrum.im/attachments/download/43/spectrum-${PV}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"

IUSE="mysql sqlite symlinks tools staticport"

RDEPEND=">=dev-libs/poco-1.3.3[mysql?,sqlite?]
	media-gfx/imagemagick[cxx]
	>=net-im/pidgin-2.6.0
	>=net-libs/gloox-1.0
	dev-python/xmpppy
	dev-libs/libev
	<dev-lang/python-3"
DEPEND="${RDEPEND}
	sys-devel/gettext
	dev-util/cmake"

PROTOCOL_LIST="aim facebook gg icq irc msn msn_pecan myspace qq simple sipe twitter xmpp yahoo"
mycmakeargs=( -DPYTHON_EXECUTABLE=/usr/bin/python2 )

pkg_setup() {
	if ! ( use sqlite || use mysql ); then
		ewarn "No database use flag set!"
		ewarn "You need to enable the mysql or sqlite use flag!"
		die
	fi
}

src_install () {
	cmake-utils_src_install

	# Install transports with seperate config files (default).
	# If USE="symlinks" is set, install one config file with symlinks to all transports.

	port=5347

	# prepare config for mysql or just copy
	cp "${FILESDIR}/spectrum.cfg" spectrum.cfg

	if use mysql ; then
	sed -e 's,^\(type\)=sqlite$,\1=mysql,' \
		-e 's,^#\(host=localhost\)$,\1,' \
		-e 's,^#\(user=user\)$,\1,' \
		-e 's,^#\(password=password\)$,\1,' \
		-e 's,^\(database=.*\),#\1,' \
		-e 's,^#\(prefix=.*\),\1,' \
		-i spectrum.cfg || die
	fi

	# install shared-config when using symlinks
	if use symlinks; then
		insinto /etc/spectrum
		newins spectrum.cfg spectrum-shared-conf || die
	fi

	# install protocol-specific configs or symlinks
	dodir /etc/spectrum
	for protocol in ${PROTOCOL_LIST}; do
		if use symlinks; then
			dosym spectrum-shared-conf "/etc/spectrum/${protocol}:${port}.cfg" || die
			sed -e 's,PROTOCOL,'${protocol}:${port}',g' \
				"${FILESDIR}"/spectrum.confd > spectrum.confd
		else
			sed -e 's,\$filename:protocol,'${protocol}',g' \
				-e 's,\$filename:port,'${port}',g' \
				spectrum.cfg > "${ED}/etc/spectrum/${protocol}.cfg" || die
			sed -e 's,PROTOCOL,'${protocol}',g' \
				"${FILESDIR}"/spectrum.confd > spectrum.confd
		fi

		# install prepared confd
		newconfd spectrum.confd spectrum.${protocol} || die

		if ! use staticport; then
			port=$[${port}+1]
		fi
	done

	# Install init files
	newinitd "${FILESDIR}"/spectrum.initd spectrum || die
	for protocol in ${PROTOCOL_LIST}; do
		dosym spectrum /etc/init.d/spectrum."${protocol}"
	done

	# Directories
	dodir "/var/lib/spectrum" || die
	dodir "/var/log/spectrum" || die
	dodir "/var/run/spectrum" || die

	# Directories for each transport
	for protocol in ${PROTOCOL_LIST}; do
		dodir "/var/lib/spectrum/$protocol/database" || die
		dodir "/var/lib/spectrum/$protocol/userdir" || die
		dodir "/var/lib/spectrum/$protocol/filetransfer_cache" || die
	done

	# Install mysql schema
	if use mysql; then
		insinto "/usr/share/spectrum/schemas"
		doins schemas/* || die
	fi

	# Install misc tools
	if use tools; then
		insinto "/usr/share/spectrum/tools"
		doins tools/* || die
	fi

	# Set correct rights
	fowners jabber:jabber -R "/etc/spectrum" || die
	fowners jabber:jabber -R "/var/lib/spectrum" || die
	fowners jabber:jabber -R "/var/log/spectrum" || die
	fowners jabber:jabber -R "/var/run/spectrum" || die
	fperms 750 "/etc/spectrum" || die
	fperms 750 "/var/lib/spectrum" || die
	fperms 750 "/var/log/spectrum" || die
	fperms 750 "/var/run/spectrum" || die
}