summaryrefslogtreecommitdiff
blob: 6a82d1d8a60cd07baa636cd8e2fffa383e336f0d (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=2

inherit flag-o-matic multilib perl-module

DESCRIPTION="Text-based, multi-protocol instant messenger"
HOMEPAGE="http://www.ekg2.org"
SRC_URI="http://qwpx.net/~mgorny/${PN}-scons/${P}.tar.lzma"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="dbus extra gadu gif gnutls gpg gpm gsm gtk icq idn inotify irc
	jabber jogger jpeg mail minimal ncurses nls nntp oracle oss pcap
	perl python readline remote rss ruby sim sms spell
	sqlite sqlite3 srv ssl static unicode web xosd zlib"

# -- non-obvious plugin mappings --
# extra	    -> autoresponder, polchat, rivchat, rot13, xmsg
# !minimal  -> ioctld, logs, rc
# any sound -> pcm
# web	    -> httprc_xajax

RDEPEND="
	dbus? ( sys-apps/dbus )
	gpg? ( app-crypt/gpgme )
	gsm? ( media-sound/gsm )
	gtk? ( x11-libs/gtk+:2 )
	idn? ( net-dns/libidn )
	nls? ( virtual/libintl )
	oracle?	( dev-db/oracle-instantclient-basic )
	pcap? ( net-libs/libpcap )
	perl? ( dev-lang/perl )
	python?	( dev-lang/python )
	readline? ( sys-libs/readline )
	rss? ( dev-libs/expat )
	ruby? ( dev-lang/ruby )
	sim? ( dev-libs/openssl )
	xosd? ( x11-libs/xosd )
	gadu? ( net-libs/libgadu
		gif? ( media-libs/giflib )
		jpeg? ( media-libs/jpeg ) )
	jabber? ( dev-libs/expat
		gnutls? ( net-libs/gnutls )
		!gnutls? ( ssl? ( dev-libs/openssl ) )
		zlib? ( sys-libs/zlib ) )
	!minimal? (
		zlib? ( sys-libs/zlib ) )
	ncurses? ( sys-libs/ncurses[unicode?]
		gpm? ( sys-libs/gpm )
		spell? ( app-text/aspell ) )
	sqlite3? ( dev-db/sqlite:3 )
	!sqlite3? ( sqlite? ( dev-db/sqlite:0 ) )"

DEPEND="dev-util/scons
	|| ( app-arch/xz-utils app-arch/lzma-utils )
	${RDEPEND}"

pkg_setup() {
	if ! use gtk && ! use ncurses && ! use readline && ! use remote && ! use web; then
		ewarn 'ekg2 is being compiled without any frontend, you should consider'
		ewarn 'enabling at least one of following USEflags:'
		ewarn '  gtk, ncurses, readline, remote, web.'
	fi

	# workaround for largefile-enabled gpgme (bug #302097)
	use gpg && has_version '>=app-crypt/gpgme-1.2' && append-flags -D_FILE_OFFSET_BITS=64
}

use_plug() {
	use $1 && echo -n ,${2:-$1}
}

# Build comma-separated plugin list based on USE
# We can put the same plugin few times if it's referenced by more than one flag

build_plugin_list() {
	echo '@none' \
	$(use_plug dbus) \
	$(use_plug extra autoresponder,polchat,rivchat,rot13,xmsg) \
	$(use_plug gadu gg) \
	$(use_plug gpg) \
	$(use_plug gsm) \
	$(use_plug gtk) \
	$(use_plug icq) \
	$(use_plug irc) \
	$(use_plug jabber jabber) \
	$(use_plug jogger jogger) \
	$(use_plug mail) \
	$(use_plug !minimal ioctld,logs,rc) \
	$(use_plug ncurses) \
	$(use_plug nntp feed) \
	$(use_plug oracle logsoracle) \
	$(use_plug oss oss,pcm) \
	$(use_plug pcap sniff) \
	$(use_plug perl) \
	$(use_plug python) \
	$(use_plug readline) \
	$(use_plug remote) \
	$(use_plug rss feed) \
	$(use_plug ruby) \
	$(use_plug sim) \
	$(use_plug sms) \
	$(use_plug sqlite logsqlite) \
	$(use_plug sqlite3 logsqlite) \
	$(use_plug web httprc_xajax) \
	$(use_plug xosd) \
		| tr -d '[[:space:]]'
}

# create DEPS list for plugin
# + means dep forced (fail if unavailable, prioritize over other one-of)
# - means dep disabled (don't even check for it)
# use:opt maps USEflag to specified opt
# usea|useb|usec makes one-of opt

make_deps() {
	local spls spll flag fopt out

	echo -n " $1_DEPS="
	shift

	# loop over different opts
	while [ -n "$1" ]; do
		spls=$1
		out=
		# loop over one-of opts
		while true; do
			# get next one-of, make sure spls gets empty if last
			spll=${spls%%|*}
			spls=${spls:$(( ${#spll} + 1 ))}
			# parse use:opt, if no :opt specified fopt=flag
			flag=${spll%:*}
			fopt=${spll#*:}

			# if one of one-of opt matches, we output only it
			# else we need to output all of them disabled
			use ${flag} && out=+ || out=${out}-
			out=${out}${fopt}

			# got more one-of opts? parse them only if this didn't match
			if [ -n "${spls}" ] && ! use ${flag}; then
				out=${out},
				continue
			fi

			echo -n ${out}
			shift
			[ -n "$1" ] && echo -n ,
			break
		done
	done
}

# create all DEPS lists

build_addopts_list() {
	use extra && make_deps XMSG inotify
	use gadu && make_deps GG gif jpeg
	use jabber && make_deps JABBER zlib 'gnutls|ssl:openssl'
	use mail && make_deps MAIL inotify
	use !minimal && make_deps LOGS zlib
	use ncurses && make_deps NCURSES gpm spell:aspell
	use rss || use nntp && make_deps FEED rss:expat
	use sqlite3 || use sqlite && make_deps LOGSQLITE 'sqlite3|sqlite'
}

# SCons doesn't build perl modules, perl-module.eclass does it better

foreach_perl_module() {
	if use perl; then
		cd plugins/perl || die 'cd plugins/perl failed'
		for DIR in */; do
			cd "${DIR}" || die "cd ${DIR} (perl module) failed"
			$1
			cd ..

			# workaround perl-module.eclass
			unset SRC_PREP
		done
		cd ../..
	fi
}

use_var() {
	echo -n "${2:-$1}=" | tr 'a-z' 'A-Z'
	use $1 && echo -n '1' || echo -n '0'
}

src_configure() {
	# HARDDEPS -> build should fail if some dep is unsatisfied
	# DISTNOTES -> are displayed with /version, helpful for upstream bug reports

	scons PLUGINS=$(build_plugin_list) $(build_addopts_list) \
		HARDDEPS=1 SKIPCHECKS=1 RELPLUGINS=0 \
		$(use_var unicode) $(use_var nls) $(use_var static) \
		$(use_var idn) $(use_var srv RESOLV) \
		PREFIX=/usr LIBDIR="\$EPREFIX/$(get_libdir)" \
		DOCDIR="\$DATAROOTDIR/doc/${PF}" \
		DISTNOTES="Sunrise ebuild ${PVR}, USE=${USE}" \
		${MAKEOPTS} conf || die "scons conf failed"

	foreach_perl_module perl-module_src_configure
}

src_compile() {
	# SKIPCONF -> no need to reconfigure

	scons SKIPCONF=1 ${MAKEOPTS} || die "scons failed"

	foreach_perl_module perl-module_src_compile
}

src_test() {
	foreach_perl_module perl-module_src_test
}

src_install() {
	scons DESTDIR="${D}" ${MAKEOPTS} install || die "scons install failed"

	foreach_perl_module perl-module_src_install

	use perl && fixlocalpod
	prepalldocs
}

pkg_postinst() {
	elog "EKG2 is still considered very experimental. Please do report all issues"
	elog "to mailing list ekg2-users@lists.ziew.org (you can write in English)."
	elog "Please do not file bugs to Gentoo Bugzilla."
	elog
	elog "Before reporting a bug, please check if it's reproducible and get"
	elog "complete backtrace of it. Even if you can't reproduce it, you may let us"
	elog "know that something like that happened."
	elog
	elog "How to get backtraces:"
	elog "	http://www.gentoo.org/proj/en/qa/backtraces.xml"
	elog
	elog "Thank you and have fun."
}