]> Pileus Git - ~andy/sunrise/blob - www-client/torbrowser/torbrowser-11.0.ebuild
Use pkgconfig virtual.
[~andy/sunrise] / www-client / torbrowser / torbrowser-11.0.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="3"
6 VIRTUALX_REQUIRED="pgo"
7 WANT_AUTOCONF="2.1"
8
9 MY_PN="firefox"
10 # latest version of the torbrowser-bundle we use the profile-folder from
11 # https://www.torproject.org/dist/torbrowser/linux/
12 TB_V="2.2.35-9"
13
14 # Patch version
15 PATCH="${MY_PN}-11.0-patches-0.4"
16 # Upstream ftp release URI that's used by mozlinguas.eclass
17 # We don't use the http mirror because it deletes old tarballs.
18 MOZ_FTP_URI="ftp://ftp.mozilla.org/pub/${MY_PN}/releases/"
19
20 inherit check-reqs flag-o-matic toolchain-funcs eutils gnome2-utils mozconfig-3 multilib pax-utils autotools python virtualx nsplugins
21
22 DESCRIPTION="Torbrowser without vidalia or tor, includes profile and extensions"
23 HOMEPAGE="https://www.torproject.org/projects/torbrowser.html.en"
24
25 # may work on other arches, but untested
26 KEYWORDS="~amd64 ~x86"
27 SLOT="0"
28 # BSD license applies to torproject-related code like the patches
29 # GPL-2 and MIT applies to the extensions
30 # icons are under CCPL-Attribution-3.0
31 LICENSE="|| ( MPL-1.1 GPL-2 LGPL-2.1 )
32         BSD
33         GPL-2
34         MIT
35         CCPL-Attribution-3.0"
36 IUSE="bindist +crashreporter +ipc pgo selinux system-sqlite +webm"
37
38 SRC_URI="${SRC_URI}
39         http://dev.gentoo.org/~anarchy/mozilla/patchsets/${PATCH}.tar.xz
40         ${MOZ_FTP_URI}/${PV}/source/${MY_PN}-${PV}.source.tar.bz2
41         https://gitweb.torproject.org/user/ioerror/torbrowser.git/blob_plain/branding:/build-scripts/branding/torbrowser/default48.png -> torbrowser.png
42         amd64? ( https://www.torproject.org/dist/${PN}/linux/tor-browser-gnu-linux-x86_64-${TB_V}-dev-en-US.tar.gz )
43         x86? ( https://www.torproject.org/dist/${PN}/linux/tor-browser-gnu-linux-i686-${TB_V}-dev-en-US.tar.gz )"
44
45 # Mesa 7.10 needed for WebGL + bugfixes
46 RDEPEND="
47         >=sys-devel/binutils-2.16.1
48         >=dev-libs/nss-3.13.3
49         >=dev-libs/nspr-4.9
50         >=dev-libs/glib-2.26:2
51         >=media-libs/mesa-7.10
52         media-libs/libpng[apng]
53         virtual/libffi
54         system-sqlite? ( >=dev-db/sqlite-3.7.7.1[fts3,secure-delete,threadsafe,unlock-notify,debug=] )
55         webm? ( >=media-libs/libvpx-1.0.0
56                 media-libs/alsa-lib )
57         crashreporter? ( net-misc/curl )
58         selinux? ( sec-policy/selinux-mozilla )"
59 # We don't use PYTHON_DEPEND/PYTHON_USE_WITH for some silly reason
60 DEPEND="${RDEPEND}
61         virtual/pkgconfig
62         pgo? (
63                 =dev-lang/python-2*[sqlite]
64                 >=sys-devel/gcc-4.5 )
65         webm? ( >=dev-lang/yasm-1.1
66                 virtual/opengl )"
67
68 S="${WORKDIR}/mozilla-release"
69
70 QA_PRESTRIPPED="usr/$(get_libdir)/${PN}/${MY_PN}/firefox"
71
72 pkg_setup() {
73         moz_pkgsetup
74
75         # Avoid PGO profiling problems due to enviroment leakage
76         # These should *always* be cleaned up anyway
77         unset DBUS_SESSION_BUS_ADDRESS \
78                 DISPLAY \
79                 ORBIT_SOCKETDIR \
80                 SESSION_MANAGER \
81                 XDG_SESSION_COOKIE \
82                 XAUTHORITY
83
84         if ! use bindist; then
85                 einfo
86                 elog "You are enabling official branding. You may not redistribute this build"
87                 elog "to any users on your network or the internet. Doing so puts yourself into"
88                 elog "a legal problem with Mozilla Foundation"
89                 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
90         fi
91
92         if use pgo; then
93                 einfo
94                 ewarn "You will do a double build for profile guided optimization."
95                 ewarn "This will result in your build taking at least twice as long as before."
96         fi
97
98         # Ensure we have enough disk space to compile
99         if use pgo || use debug || use test ; then
100                 CHECKREQS_DISK_BUILD="8G"
101         else
102                 CHECKREQS_DISK_BUILD="4G"
103         fi
104         check-reqs_pkg_setup
105 }
106
107 src_prepare() {
108         # Apply our patches
109         EPATCH_SUFFIX="patch" \
110         EPATCH_FORCE="yes" \
111         epatch "${WORKDIR}/firefox"
112
113         # Torbrowser patches for firefox 11, check regularly/for every version-bump
114         # https://gitweb.torproject.org/torbrowser.git/history/HEAD:/src/current-patches
115         EPATCH_SUFFIX="patch" \
116         EPATCH_FORCE="yes" \
117         epatch "${FILESDIR}/${PV}"
118
119         # Allow user to apply any additional patches without modifing ebuild
120         epatch_user
121
122         # Enable gnomebreakpad
123         if use debug ; then
124                 sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
125                         "${S}"/build/unix/run-mozilla.sh || die "sed failed!"
126         fi
127
128         # Disable gnomevfs extension
129         sed -i -e "s:gnomevfs::" "${S}/"browser/confvars.sh \
130                 -e "s:gnomevfs::" "${S}/"xulrunner/confvars.sh \
131                 || die "Failed to remove gnomevfs extension"
132
133         # Ensure that plugins dir is enabled as default
134         # and is different from firefox-location
135         sed -i -e "s:/usr/lib/mozilla/plugins:/usr/$(get_libdir)/${PN}/${MY_PN}/plugins:" \
136                 "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path!"
137
138         # Fix sandbox violations during make clean, bug 372817
139         sed -e "s:\(/no-such-file\):${T}\1:g" \
140                 -i "${S}"/config/rules.mk \
141                 -i "${S}"/js/src/config/rules.mk \
142                 -i "${S}"/nsprpub/configure{.in,} \
143                 || die
144
145         #Fix compilation with curl-7.21.7 bug 376027
146         sed -e '/#include <curl\/types.h>/d'  \
147                 -i "${S}"/toolkit/crashreporter/google-breakpad/src/common/linux/http_upload.cc \
148                 -i "${S}"/toolkit/crashreporter/google-breakpad/src/common/linux/libcurl_wrapper.cc \
149                 -i "${S}"/config/system-headers \
150                 -i "${S}"/js/src/config/system-headers || die "Sed failed"
151
152         eautoreconf
153 }
154
155 src_configure() {
156         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
157         MEXTENSIONS="default"
158
159         ####################################
160         #
161         # mozconfig, CFLAGS and CXXFLAGS setup
162         #
163         ####################################
164
165         mozconfig_init
166         mozconfig_config
167
168         mozconfig_annotate '' --prefix="${EPREFIX}"/usr
169         mozconfig_annotate '' --libdir="${EPREFIX}"/usr/$(get_libdir)/${PN}
170         mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
171         mozconfig_annotate '' --disable-gconf
172         mozconfig_annotate '' --disable-mailnews
173         mozconfig_annotate '' --enable-canvas
174         mozconfig_annotate '' --enable-safe-browsing
175         mozconfig_annotate '' --with-system-png
176         mozconfig_annotate '' --enable-system-ffi
177
178         # Other ff-specific settings
179         mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
180         mozconfig_annotate '' --target="${CTARGET:-${CHOST}}"
181
182         # Allow for a proper pgo build
183         if use pgo; then
184                 echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig
185         fi
186
187         # Finalize and report settings
188         mozconfig_final
189
190         if [[ $(gcc-major-version) -lt 4 ]]; then
191                 append-cxxflags -fno-stack-protector
192         elif [[ $(gcc-major-version) -gt 4 || $(gcc-minor-version) -gt 3 ]]; then
193                 if use amd64 || use x86; then
194                         append-flags -mno-avx
195                 fi
196         fi
197 }
198
199 src_compile() {
200         if use pgo; then
201                 addpredict /root
202                 addpredict /etc/gconf
203                 # Reset and cleanup environment variables used by GNOME/XDG
204                 gnome2_environment_reset
205
206                 # Firefox tries to use dri stuff when it's run, see bug 380283
207                 shopt -s nullglob
208                 cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
209                 if test -n "${cards}"; then
210                         # FOSS drivers are fine
211                         addpredict "${cards}"
212                 else
213                         cards=$(echo -n /dev/ati/card* /dev/nvidiactl* | sed 's/ /:/g')
214                         if test -n "${cards}"; then
215                                 # Binary drivers seem to cause access violations anyway, so
216                                 # let's use indirect rendering so that the device files aren't
217                                 # touched at all. See bug 394715.
218                                 export LIBGL_ALWAYS_INDIRECT=1
219                                 addpredict "${cards}"
220                         fi
221                 fi
222                 shopt -u nullglob
223
224                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
225                 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
226                 Xemake -f client.mk profiledbuild || die "Xemake failed"
227         else
228                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
229                 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
230                 emake -f client.mk || die "emake failed"
231         fi
232 }
233
234 src_install() {
235         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
236
237         # MOZ_BUILD_ROOT, and hence OBJ_DIR change depending on arch, compiler, pgo, etc.
238         local obj_dir="$(echo */config.log)"
239         obj_dir="${obj_dir%/*}"
240         cd "${S}/${obj_dir}"
241
242         # Pax mark xpcshell for hardened support, only used for startupcache creation.
243         pax-mark m "${S}/${obj_dir}"/dist/bin/xpcshell
244
245         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
246         emake DESTDIR="${D}" install || die "emake install failed"
247
248         # remove default symlink in /usr/bin, because we add a proper wrapper-script later
249         rm "${ED}"/usr/bin/${MY_PN} || die "Failed to remove binary-symlink"
250         # we dont want development stuff for this kind of build, might as well
251         # conflict with other firefox-builds
252         rm -rf "${ED}"/usr/include "${ED}${MOZILLA_FIVE_HOME}"/{idl,include,lib,sdk} || \
253                 die "Failed to remove sdk and headers"
254
255         # Required in order to use plugins and even run firefox on hardened.
256         pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/{firefox,firefox-bin,plugin-container}
257
258         # Plugins dir
259         share_plugins_dir
260         dodir /usr/$(get_libdir)/${PN}/nsbrowser/plugins || die
261
262         # Install pre-configured Torbrowser-profile
263         insinto /usr/share/${PN}
264         doins -r "${WORKDIR}"/tor-browser_en-US/Data/profile || die
265
266         # create wrapper to start torbrowser
267         make_wrapper ${PN} "/usr/$(get_libdir)/${PN}/${MY_PN}/${MY_PN} -no-remote -profile ~/.${PN}/profile"
268
269         doicon "${DISTDIR}"/torbrowser.png
270         make_desktop_entry ${PN} "Torbrowser" torbrowser.png "Network;WebBrowser"
271         dodoc "${WORKDIR}"/tor-browser_en-US/Docs/changelog || die
272 }
273
274 pkg_postinst() {
275         einfo ""
276         elog "Copy the folder /usr/share/${PN}/profile into ~/.${PN} and run '${PN}'."
277         elog ""
278         elog "This profile folder includes pre-configuration recommended by upstream,"
279         elog "as well as the _extensions_ Torbutton, NoScript and HTTPS-Everywhere."
280         elog "If you want to start from scratch just create the directories ~/.${PN}/profile."
281         elog ""
282         elog "Note that torbrowser uses a different _plugins_ folder too:"
283         elog "/usr/$(get_libdir)/${PN}/nsbrowser/plugins"
284         einfo ""
285 }