summaryrefslogtreecommitdiff
path: root/eclass/transmission-2.80.eclass
blob: afaf9a3867e7c1eca92093cd53ac241d930d29a7 (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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# Copyright 1999-2013 Sabayon
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: transmission-2.xx.eclass
# @MAINTAINER:
# slawomir.nizio@sabayon.org
# @AUTHOR:
# Sławomir Nizio <slawomir.nizio@sabayon.org>
# @BLURB: eclass to ease managing of Sabayon split net-p2p/transmission
# @DESCRIPTION:
# This eclass is to ease managing of split net-p2p/transmission for Sabayon.
# Its name contains a version that corresponds to net-p2p/transmission one,
# because the eclass will change often when needed to follow changes
# in Gentoo ebuild.

# @ECLASS-VARIABLE: TRANSMISSION_PATCHES
# @DEFAULT_UNSET
# @DESCRIPTION:
# Array that contains patches to apply just before eautoreconf.

# @ECLASS-VARIABLE: TRANSMISSION_ECLASS_VERSION_OK
# @DESCRIPTION:
# Set this to x.y if you want to use transmission-x.y.eclass from ebuild
# with ${PV} different than x.y. This is to catch bugs.
: ${TRANSMISSION_ECLASS_VERSION_OK:=${PV}}

# @ECLASS-VARIABLE: E_TRANSM_TAIL
# @INTERNAL
# @DESCRIPTION:
# "Tail" of package name. Can take value gtk, qt4, etc. or can be empty.
E_TRANSM_TAIL=${PN#transmission}
E_TRANSM_TAIL=${E_TRANSM_TAIL#-}

# @FUNCTION: _transmission_is
# @INTERNAL
# @DESCRIPTION:
# Function used to check which variant of Transmission are we working on.
# Argument should be one of these: (none), gtk, qt4, daemon, cli, base.
# If argument is empty or omitted, true value means that it is
# net-p2p/transmission (metapackage).
_transmission_is() {
	local what=$1
	[[ ${what} = "${E_TRANSM_TAIL}" ]]
}

MY_ECLASSES=""
_transmission_is gtk && MY_ECLASSES+="fdo-mime gnome2-utils"
_transmission_is qt4 && MY_ECLASSES+="fdo-mime qt4-r2"
_transmission_is "" || MY_ECLASSES+=" autotools"
_transmission_is base && MY_ECLASSES+=" user"

inherit eutils multilib ${MY_ECLASSES}

unset MY_ECLASSES

case ${EAPI:-0} in
	4|5) EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_compile \
		pkg_preinst pkg_postinst pkg_postrm ;;
	*) die "EAPI=${EAPI} is not supported" ;;
esac

[[ ${PN} = transmission* ]] || \
	die "This eclass can only be used with net-p2p/transmission* ebuilds!"
# Bug catcher!
if ! [[ ${PV} = *9999* ]] && [[ ${TRANSMISSION_ECLASS_VERSION_OK} != ${ECLASS#*-} ]]; then
	eerror "used eclass ${ECLASS}"
	eerror "TRANSMISSION_ECLASS_VERSION_OK=${TRANSMISSION_ECLASS_VERSION_OK}"
	die "ebuild version ${PV} doesn't match with the eclass"
fi

MY_PN="transmission"
MY_P="${MY_PN}-${PV}"

DESCRIPTION="A Fast, Easy and Free BitTorrent client"
HOMEPAGE="http://www.transmissionbt.com/"
SRC_URI="http://download.transmissionbt.com/${MY_PN}/files/${MY_P}.tar.xz"

LICENSE="GPL-2 MIT"
SLOT="0"
IUSE=""

# only common dependencies plus blockers
RDEPEND=""
_transmission_is base || RDEPEND+="~net-p2p/transmission-base-${PV}"
if ! _transmission_is ""; then
	RDEPEND+="
	>=dev-libs/libevent-2.0.10:=
	dev-libs/openssl:0=
	net-libs/libnatpmp:=
	>=net-libs/miniupnpc-1.6.20120509:=
	>=net-misc/curl-7.16.3:=[ssl]
	sys-libs/zlib:="
fi

DEPEND="${RDEPEND}"
if _transmission_is base; then
	RDEPEND+=" !<net-p2p/transmission-gtk-${PV}
	!<net-p2p/transmission-qt4-${PV}
	!<net-p2p/transmission-daemon-${PV}
	!<net-p2p/transmission-cli-${PV}"
fi
if ! _transmission_is ""; then
	DEPEND+=" dev-libs/glib:2
	dev-util/intltool
	virtual/pkgconfig
	sys-devel/gettext
	virtual/os-headers"
fi

S="${WORKDIR}/${MY_P}"
_transmission_is "" && S="${WORKDIR}"

transmission-2.80_pkg_setup() {
	if _transmission_is base; then
		enewgroup transmission
		enewuser transmission -1 -1 -1 transmission
	fi
}

transmission-2.80_src_prepare() {
	_transmission_is "" && return

	sed -i -e '/CFLAGS/s:-ggdb3::' configure.ac || die

	if ! use_if_iuse ayatana; then
		sed -i -e '/^LIBAPPINDICATOR_MINIMUM/s:=.*:=9999:' configure.ac || die
	fi

	# http://trac.transmissionbt.com/ticket/4324
	sed -i -e 's|noinst\(_PROGRAMS = $(TESTS)\)|check\1|' lib${MY_PN}/Makefile.am || die

	if [[ ${#TRANSMISSION_PATCHES[@]} -gt 0 ]]; then
		epatch "${TRANSMISSION_PATCHES[@]}"
	fi

	eautoreconf

	if ! _transmission_is base; then
		local sedcmd="s:\$(top_builddir)/libtransmission/libtransmission.a:"
		sedcmd+="${EROOT}usr/$(get_libdir)/libtransmission.a:"
		find . -name Makefile.in -exec sed -i -e "${sedcmd}" {} \; || die
		sed -i -e '/libtransmission \\/d' Makefile.in || die
		if _transmission_is qt4; then
			sedcmd="s:\$\${TRANSMISSION_TOP}/libtransmission/libtransmission.a:"
			sedcmd+="${EROOT}usr/$(get_libdir)/libtransmission.a:"
			sed -i -e "${sedcmd}" qt/qtr.pro || die
		fi
	fi
}

transmission-2.80_src_configure() {
	_transmission_is "" && return

	local econfargs=(
		--enable-external-natpmp
	)

	if _transmission_is base; then
		export ac_cv_header_xfs_xfs_h=$(usex xfs)
		econfargs+=(
			--disable-cli
			--disable-daemon
			--without-gtk
			$(use_enable lightweight)
		)
	elif _transmission_is cli; then
		econfargs+=(
			--enable-cli
			--disable-daemon
			--without-gtk
		)
	elif _transmission_is daemon; then
		econfargs+=(
			--disable-cli
			--enable-daemon
			--without-gtk
			$(use_with systemd systemd-daemon)
		)
	elif _transmission_is gtk; then
		econfargs+=(
			--disable-cli
			--disable-daemon
			--with-gtk
		)
	elif _transmission_is qt4; then
		econfargs+=(
			--disable-cli
			--disable-daemon
			--without-gtk
		)
	else
		die "Something is wrong... (E_TRANSM_TAIL=$E_TRANSM_TAIL)"
	fi

	econf "${econfargs[@]}"
	if _transmission_is qt4; then
		pushd qt >/dev/null
		eqmake4 qtr.pro
		popd >/dev/null
	fi
}

transmission-2.80_src_compile() {
	_transmission_is "" && return

	emake
	if _transmission_is qt4; then
		pushd qt >/dev/null
		emake
		lrelease translations/*.ts
		popd >/dev/null
	fi
}


# Note: not providing src_install. Too many differences and too much code
# which would only clutter this pretty eclass.

transmission-2.80_pkg_preinst() {
	_transmission_is gtk && gnome2_icon_savelist
}

transmission-2.80_pkg_postinst() {
	if _transmission_is gtk || _transmission_is qt4; then
		fdo-mime_desktop_database_update
	fi

	_transmission_is gtk && gnome2_icon_cache_update

	if _transmission_is daemon; then
		elog "If you use ${MY_PN}-daemon, please, set 'rpc-username' and"
		elog "'rpc-password' (in plain text, ${MY_PN}-daemon will hash it on"
		elog "start) in settings.json file located at /var/${MY_PN}/config or"
		elog "any other appropriate config directory."
	fi

	if _transmission_is gtk; then
		# in -gtk only?
		elog
		elog "To enable sound emerge media-libs/libcanberra and check that at least"
		elog "some sound them is selected. For this go:"
		elog "Gnome/system/preferences/sound themes tab and 'sound theme: default'"
		elog
	fi

	if _transmission_is base; then
		elog "Since µTP is enabled by default, ${MY_PN} needs large kernel buffers for"
		elog "the UDP socket. You can append following lines into /etc/sysctl.conf:"
		elog " net.core.rmem_max = 4194304"
		elog " net.core.wmem_max = 1048576"
		elog "and run sysctl -p"
	fi
}

transmission-2.80_pkg_postrm() {
	if _transmission_is gtk || _transmission_is qt4; then
		fdo-mime_desktop_database_update
	fi

	_transmission_is gtk && gnome2_icon_cache_update
}