]> Pileus Git - ~andy/sunrise/blob - www-client/torbrowser/torbrowser-11.0.ebuild
www-client/torbrowser: Version bump
[~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.1
49         >=dev-libs/nspr-4.8.8
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         dev-util/pkgconfig
62         pgo? (
63                 =dev-lang/python-2*[sqlite]
64                 >=sys-devel/gcc-4.5 )
65         webm? ( >=dev-lang/yasm-1.1 )"
66
67 S="${WORKDIR}/mozilla-release"
68
69 QA_PRESTRIPPED="usr/$(get_libdir)/${PN}/${MY_PN}/firefox"
70
71 pkg_setup() {
72         moz_pkgsetup
73
74         # Avoid PGO profiling problems due to enviroment leakage
75         # These should *always* be cleaned up anyway
76         unset DBUS_SESSION_BUS_ADDRESS \
77                 DISPLAY \
78                 ORBIT_SOCKETDIR \
79                 SESSION_MANAGER \
80                 XDG_SESSION_COOKIE \
81                 XAUTHORITY
82
83         if ! use bindist; then
84                 einfo
85                 elog "You are enabling official branding. You may not redistribute this build"
86                 elog "to any users on your network or the internet. Doing so puts yourself into"
87                 elog "a legal problem with Mozilla Foundation"
88                 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
89         fi
90
91         if use pgo; then
92                 einfo
93                 ewarn "You will do a double build for profile guided optimization."
94                 ewarn "This will result in your build taking at least twice as long as before."
95         fi
96
97         # Ensure we have enough disk space to compile
98         if use pgo || use debug || use test ; then
99                 CHECKREQS_DISK_BUILD="8G"
100         else
101                 CHECKREQS_DISK_BUILD="4G"
102         fi
103         check-reqs_pkg_setup
104 }
105
106 src_prepare() {
107         # Apply our patches
108         EPATCH_SUFFIX="patch" \
109         EPATCH_FORCE="yes" \
110         epatch "${WORKDIR}/firefox"
111
112         # Torbrowser patches for firefox 11, check regularly/for every version-bump
113         # https://gitweb.torproject.org/torbrowser.git/history/HEAD:/src/current-patches
114         EPATCH_SUFFIX="patch" \
115         EPATCH_FORCE="yes" \
116         epatch "${FILESDIR}/${PV}"
117
118         # Allow user to apply any additional patches without modifing ebuild
119         epatch_user
120
121         # Enable gnomebreakpad
122         if use debug ; then
123                 sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
124                         "${S}"/build/unix/run-mozilla.sh || die "sed failed!"
125         fi
126
127         # Disable gnomevfs extension
128         sed -i -e "s:gnomevfs::" "${S}/"browser/confvars.sh \
129                 -e "s:gnomevfs::" "${S}/"xulrunner/confvars.sh \
130                 || die "Failed to remove gnomevfs extension"
131
132         # Ensure that plugins dir is enabled as default
133         # and is different from firefox-location
134         sed -i -e "s:/usr/lib/mozilla/plugins:/usr/$(get_libdir)/${PN}/${MY_PN}/plugins:" \
135                 "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path!"
136
137         # Fix sandbox violations during make clean, bug 372817
138         sed -e "s:\(/no-such-file\):${T}\1:g" \
139                 -i "${S}"/config/rules.mk \
140                 -i "${S}"/js/src/config/rules.mk \
141                 -i "${S}"/nsprpub/configure{.in,} \
142                 || die
143
144         #Fix compilation with curl-7.21.7 bug 376027
145         sed -e '/#include <curl\/types.h>/d'  \
146                 -i "${S}"/toolkit/crashreporter/google-breakpad/src/common/linux/http_upload.cc \
147                 -i "${S}"/toolkit/crashreporter/google-breakpad/src/common/linux/libcurl_wrapper.cc \
148                 -i "${S}"/config/system-headers \
149                 -i "${S}"/js/src/config/system-headers || die "Sed failed"
150
151         eautoreconf
152 }
153
154 src_configure() {
155         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
156         MEXTENSIONS="default"
157
158         ####################################
159         #
160         # mozconfig, CFLAGS and CXXFLAGS setup
161         #
162         ####################################
163
164         mozconfig_init
165         mozconfig_config
166
167         mozconfig_annotate '' --prefix="${EPREFIX}"/usr
168         mozconfig_annotate '' --libdir="${EPREFIX}"/usr/$(get_libdir)/${PN}
169         mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
170         mozconfig_annotate '' --disable-gconf
171         mozconfig_annotate '' --disable-mailnews
172         mozconfig_annotate '' --enable-canvas
173         mozconfig_annotate '' --enable-safe-browsing
174         mozconfig_annotate '' --with-system-png
175         mozconfig_annotate '' --enable-system-ffi
176
177         # Other ff-specific settings
178         mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
179         mozconfig_annotate '' --target="${CTARGET:-${CHOST}}"
180
181         # Allow for a proper pgo build
182         if use pgo; then
183                 echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig
184         fi
185
186         # Finalize and report settings
187         mozconfig_final
188
189         if [[ $(gcc-major-version) -lt 4 ]]; then
190                 append-cxxflags -fno-stack-protector
191         elif [[ $(gcc-major-version) -gt 4 || $(gcc-minor-version) -gt 3 ]]; then
192                 if use amd64 || use x86; then
193                         append-flags -mno-avx
194                 fi
195         fi
196 }
197
198 src_compile() {
199         if use pgo; then
200                 addpredict /root
201                 addpredict /etc/gconf
202                 # Reset and cleanup environment variables used by GNOME/XDG
203                 gnome2_environment_reset
204
205                 # Firefox tries to use dri stuff when it's run, see bug 380283
206                 shopt -s nullglob
207                 cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
208                 if test -n "${cards}"; then
209                         # FOSS drivers are fine
210                         addpredict "${cards}"
211                 else
212                         cards=$(echo -n /dev/ati/card* /dev/nvidiactl* | sed 's/ /:/g')
213                         if test -n "${cards}"; then
214                                 # Binary drivers seem to cause access violations anyway, so
215                                 # let's use indirect rendering so that the device files aren't
216                                 # touched at all. See bug 394715.
217                                 export LIBGL_ALWAYS_INDIRECT=1
218                                 addpredict "${cards}"
219                         fi
220                 fi
221                 shopt -u nullglob
222
223                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
224                 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
225                 Xemake -f client.mk profiledbuild || die "Xemake failed"
226         else
227                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
228                 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
229                 emake -f client.mk || die "emake failed"
230         fi
231 }
232
233 src_install() {
234         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
235
236         # MOZ_BUILD_ROOT, and hence OBJ_DIR change depending on arch, compiler, pgo, etc.
237         local obj_dir="$(echo */config.log)"
238         obj_dir="${obj_dir%/*}"
239         cd "${S}/${obj_dir}"
240
241         # Pax mark xpcshell for hardened support, only used for startupcache creation.
242         pax-mark m "${S}/${obj_dir}"/dist/bin/xpcshell
243
244         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
245         emake DESTDIR="${D}" install || die "emake install failed"
246
247         # remove default symlink in /usr/bin, because we add a proper wrapper-script later
248         rm "${ED}"/usr/bin/${MY_PN} || die "Failed to remove binary-symlink"
249         # we dont want development stuff for this kind of build, might as well
250         # conflict with other firefox-builds
251         rm -rf "${ED}"/usr/include "${ED}${MOZILLA_FIVE_HOME}"/{idl,include,lib,sdk} || \
252                 die "Failed to remove sdk and headers"
253
254         # Required in order to use plugins and even run firefox on hardened.
255         pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/{firefox,firefox-bin,plugin-container}
256
257         # Plugins dir
258         share_plugins_dir
259         dodir /usr/$(get_libdir)/${PN}/nsbrowser/plugins || die
260
261         # Install pre-configured Torbrowser-profile
262         insinto /usr/share/${PN}
263         doins -r "${WORKDIR}"/tor-browser_en-US/Data/profile || die
264
265         # create wrapper to start torbrowser
266         make_wrapper ${PN} "/usr/$(get_libdir)/${PN}/${MY_PN}/${MY_PN} -no-remote -profile ~/.${PN}/profile"
267
268         doicon "${DISTDIR}"/torbrowser.png
269         make_desktop_entry ${PN} "Torbrowser" torbrowser.png "Network;WebBrowser"
270         dodoc "${WORKDIR}"/tor-browser_en-US/Docs/changelog || die
271 }
272
273 pkg_postinst() {
274         einfo ""
275         elog "Copy the folder /usr/share/${PN}/profile into ~/.${PN} and run '${PN}'."
276         elog ""
277         elog "This profile folder includes pre-configuration recommended by upstream,"
278         elog "as well as the _extensions_ Torbutton, NoScript and HTTPS-Everywhere."
279         elog "If you want to start from scratch just create the directories ~/.${PN}/profile."
280         elog ""
281         elog "Note that torbrowser uses a different _plugins_ folder too:"
282         elog "/usr/$(get_libdir)/${PN}/nsbrowser/plugins"
283         einfo ""
284 }