summaryrefslogtreecommitdiff
blob: dc1fafd672cf94408aed8b18e4e742a99edad83e (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-misc/boinc/boinc-6.2.15.ebuild,v 1.3 2008/11/28 00:06:59 scarabeus Exp $

EAPI="1"

inherit depend.apache flag-o-matic wxwidgets autotools

MY_PV="${PV//./_}"
DESCRIPTION="The Berkeley Open Infrastructure for Network Computing"
HOMEPAGE="http://boinc.ssl.berkeley.edu/"
SRC_URI="http://dev.gentooexperimental.org/~scarabeus/${P}.tar.bz2
		bindist? ( amd64? ( http://${PN}dl.ssl.berkeley.edu/dl/${P/-/_}_x86_64-pc-linux-gnu.sh )
					x86? ( http://${PN}dl.ssl.berkeley.edu/dl/${P/-/_}_i686-pc-linux-gnu.sh )
				)"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64 ~ia64 ~ppc ~sparc ~x86"
IUSE="X bindist server unicode"
# bindist is only for x86 and amd64 for rest package.use.mask

RDEPEND="sys-libs/zlib
	>=net-misc/curl-7.15.5
	>=dev-libs/openssl-0.9.7
	X? ( =x11-libs/wxGTK-2.8* )
	server? (
		!bindist? (
			>=virtual/mysql-4.0
			virtual/php
			>=dev-lang/python-2.2.3
			>=dev-python/mysql-python-0.9.2
		)
	)"
DEPEND="app-misc/ca-certificates
	!bindist? (
		>=sys-devel/gcc-3.0.4
		>=sys-devel/autoconf-2.58
		>=sys-devel/automake-1.8
		>=dev-util/pkgconfig-0.15
		>=sys-devel/m4-1.4
	)
	X? ( x11-libs/libXmu
		x11-libs/libXt
		x11-libs/libX11
		x11-proto/xproto
		media-libs/freeglut
		virtual/glu
		media-libs/jpeg )
	server? ( !bindist? ( virtual/imap-c-client ) )
	${RDEPEND}"
# subversion is not needed only if user choose binary for amd64 or x86
want_apache server

LANGS="ar be bg ca cs da de el en_US es eu fi fr hr hu it ja lt lv nb nl pl pt pt_BR ro ru sk sl sv_SE tr uk zh_CN zh_TW"
for LNG in ${LANGS}; do
	IUSE="${IUSE} linguas_${LNG}"
done

src_unpack() {
	local target

	if ! use bindist; then
		unpack ${P}.tar.bz2
		cd "${S}"
		# replace CXXFLAGS, those added are suggested by upstream
		sed -i \
			-e "s:-O3 -fomit-frame-pointer -fforce-addr -ffast-math \$(AM_CPPFLAGS):\$(AM_CPPFLAGS) -O3 -funroll-loops -fforce-addr	-ffast-math:" \
			client/Makefile.am || die "sed client/Makefile.am failed"
		# silence warnings
		epatch "${FILESDIR}"/"${P}"-project-list-size.patch
		epatch "${FILESDIR}"/"${P}"-mute-warnings.patch
		# do autoreconf
		rm "${S}"/m4/libtool.m4
		AT_M4DIR="m4" eautoreconf
	else
		use server && elog "Server feature is working only for source build, please disable bindist if you really intend to use server."
		use x86 && target="i686" || target="x86_64"
		cp "${DISTDIR}"/${P/-/_}_${target}-pc-linux-gnu.sh "${WORKDIR}"
		cd "${WORKDIR}"
		sh ${P/-/_}_${target}-pc-linux-gnu.sh
	fi
	# patch up certificates
	mkdir "${S}"/curl/
	ln -s /etc/ssl/certs/ca-certificates.crt "${S}"/curl/ca-bundle.crt
	sed -i \
		-e "s:::g" \
		"${S}"/Makefile
}

src_compile() {
	if ! use bindist; then
		if use X; then
			WX_GTK_VER=2.8
			use unicode && need-wxwidgets unicode || need-wxwidgets gtk2
			wxconf="--with-wx-config=${WX_CONFIG}"
		fi

		econf \
			--enable-client \
			--with-ssl \
			${wxconf} \
			$(use_enable unicode) \
			$(use_enable server) \
			$(use_with X x) || die "econf failed"

		# Make it link to the compiled libs, not the installed ones
		# remove precompiled binaries from svn
		sed -i \
			-e "s:LDFLAGS = :LDFLAGS = -L../lib :g" \
			*/Makefile || die "sed failed"
		emake -j1 || die "emake failed"
	fi
}

src_install() {
	dodir /var/lib/${PN}
	newinitd "${FILESDIR}"/${PN}.init ${PN}
	newconfd "${FILESDIR}"/${PN}.conf ${PN}
	if ! use bindist; then
		make install DESTDIR="${D}" || die "make install failed"
		# icon
		newicon "${S}"/sea/${PN}mgr.48x48.png ${PN}.png
		# wrapper to allow gui to load gui_rpc_auth.cfg because ${PN} devs assume curdir to be datadir for ${PN}_gui
		mv "${D}"/usr/bin/${PN}_gui "${D}"/usr/bin/${PN}mgr
		echo "cd \"/var/lib/${PN}\" && exec /usr/bin/${PN}mgr \$@" > "${D}"/usr/bin/${PN}_gui
		chmod 755 "${D}"/usr/bin/${PN}_gui
		# desktop
		if use X; then
			make_desktop_entry ${PN}_gui ${PN} ${PN} "Education;Science" /var/lib/${PN}
		fi
		# required headers by seti@home
		insopts -m0644
		insinto /usr/include/${PN}
		doins "${S}"/api/{reduce.h,graphics_api.h,graphics_data.h,${PN}_gl.h}
		# symlink locale so it actualy work for source dist.
		insinto /usr/share/locale/
		cd "${S}"/locale/client
		for LNG in ${LINGUAS}; do
			doins -r ${LNG}
		done
		dosym /usr/share/locale /var/lib/${PN}/locale
		cd "${S}"
	else
		local S_BIN="${WORKDIR}"/BOINC
		cd "${S_BIN}"
		# fix ${PN}.conf file for binary package
		sed -i -e "s:/usr/bin/${PN}_client:/opt/${PN}/${PN}:g" "${D}"/etc/conf.d/${PN}
		if use X; then
			# icon
			newicon "${S_BIN}"/${PN}mgr.48x48.png ${PN}.png
			# desktop
			make_desktop_entry /opt/${PN}/run_manager "${PN}" ${PN} "Education;Science"	/var/lib/${PN}
		fi
		# use correct path in scripts
		sed -i \
			-e "s:${S_BIN}:/var/lib/${PN}:g" \
			-e "s:./${PN}:/opt/${PN}/${PN}:g" \
			run_client || die "sed run_client failed"
		sed -i \
			-e "s:${S_BIN}:/var/lib/${PN}:g" \
			-e "s:./${PN}mgr:/opt/${PN}/${PN}mgr:g" \
			run_manager || die "sed run_manager failed"
		# install binaries
		exeopts -m0755
		exeinto /opt/${PN}

		doexe "${S_BIN}"//{${PN},${PN}_cmd,${PN}cmd,${PN}mgr,run_client,run_manager}
		fowners 0:${PN} /opt/${PN}/{${PN},${PN}_cmd,${PN}cmd,${PN}mgr,run_client,run_manager}
		# locale
		mkdir -p "${D}"/opt/${PN}/locale
		insopts -m0644
		insinto /opt/${PN}/
		cd "${S_BIN}"/locale/
		for LNG in ${LINGUAS}; do
			doins -r "${LNG}"
		done
		dosym /opt/${PN}/locale /var/lib/${PN}/locale
		cd "${S}"
	fi
	dosym /etc/ssl/certs/ca-certificates.crt /var/lib/${PN}/ca-bundle.crt
	insopts -m0640
	insinto /var/lib/${PN}
	doins "${FILESDIR}"/gui_rpc_auth.cfg
	fowners ${PN}:${PN} /var/lib/${PN}/gui_rpc_auth.cfg
	fowners ${PN}:${PN} /var/lib/${PN}/
}

pkg_preinst() {
	enewgroup ${PN}
	enewuser ${PN} -1 -1 /var/lib/${PN} ${PN}
}

pkg_postinst() {
	echo
	if use bindist; then
		elog "You are using the binary distributed version."
		elog "The manager can be found at /opt/${PN}/run_manager"
	fi
	elog "You need to attach to a project to do anything useful with ${PN}."
	elog "You can do this by running /etc/init.d/${PN} attach"
	elog "${PN} The howto for configuration is located at:"
	elog "http://${PN}.berkeley.edu/anonymous_platform.php"
	if use server && ! use bindist ; then
		echo
		elog "You have chosen to enable server mode. this ebuild has installed"
		elog "the necessary packages to be a server. You will need to have a"
		elog "project. Contact ${PN} directly for further information."
	fi
	echo
	# Add warning about the new password for the client, bug 121896.
	elog "If you need to use the graphical client the password is in"
	elog "/var/lib/${PN}/gui_rpc_auth.cfg which is for first run empty."
	elog "You should change this to something more secure."
	echo
}