1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 VIRTUALX_REQUIRED="pgo"
10 # latest version of the torbrowser-bundle we use the profile-folder from
11 # https://www.torproject.org/dist/torbrowser/linux/
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/"
20 inherit check-reqs flag-o-matic toolchain-funcs eutils gnome2-utils mozconfig-3 multilib pax-utils autotools python virtualx nsplugins
22 DESCRIPTION="Torbrowser without vidalia or tor, includes profile and extensions"
23 HOMEPAGE="https://www.torproject.org/projects/torbrowser.html.en"
25 # may work on other arches, but untested
26 KEYWORDS="~amd64 ~x86"
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 )
36 IUSE="bindist +crashreporter +ipc pgo selinux system-sqlite +webm"
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 )"
45 # Mesa 7.10 needed for WebGL + bugfixes
47 >=sys-devel/binutils-2.16.1
50 >=dev-libs/glib-2.26:2
51 >=media-libs/mesa-7.10
52 media-libs/libpng[apng]
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
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
63 =dev-lang/python-2*[sqlite]
65 webm? ( >=dev-lang/yasm-1.1
68 S="${WORKDIR}/mozilla-release"
70 QA_PRESTRIPPED="usr/$(get_libdir)/${PN}/${MY_PN}/firefox"
75 # Avoid PGO profiling problems due to enviroment leakage
76 # These should *always* be cleaned up anyway
77 unset DBUS_SESSION_BUS_ADDRESS \
84 if ! use bindist; then
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"
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."
98 # Ensure we have enough disk space to compile
99 if use pgo || use debug || use test ; then
100 CHECKREQS_DISK_BUILD="8G"
102 CHECKREQS_DISK_BUILD="4G"
109 EPATCH_SUFFIX="patch" \
111 epatch "${WORKDIR}/firefox"
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" \
117 epatch "${FILESDIR}/${PV}"
119 # Allow user to apply any additional patches without modifing ebuild
122 # Enable gnomebreakpad
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!"
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"
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!"
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,} \
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"
156 MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
157 MEXTENSIONS="default"
159 ####################################
161 # mozconfig, CFLAGS and CXXFLAGS setup
163 ####################################
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
178 # Other ff-specific settings
179 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
180 mozconfig_annotate '' --target="${CTARGET:-${CHOST}}"
182 # Allow for a proper pgo build
184 echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig
187 # Finalize and report settings
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
202 addpredict /etc/gconf
203 # Reset and cleanup environment variables used by GNOME/XDG
204 gnome2_environment_reset
206 # Firefox tries to use dri stuff when it's run, see bug 380283
208 cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
209 if test -n "${cards}"; then
210 # FOSS drivers are fine
211 addpredict "${cards}"
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}"
224 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
225 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
226 Xemake -f client.mk profiledbuild || die "Xemake failed"
228 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
229 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
230 emake -f client.mk || die "emake failed"
235 MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
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%/*}"
242 # Pax mark xpcshell for hardened support, only used for startupcache creation.
243 pax-mark m "${S}/${obj_dir}"/dist/bin/xpcshell
245 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
246 emake DESTDIR="${D}" install || die "emake install failed"
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"
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}
260 dodir /usr/$(get_libdir)/${PN}/nsbrowser/plugins || die
262 # Install pre-configured Torbrowser-profile
263 insinto /usr/share/${PN}
264 doins -r "${WORKDIR}"/tor-browser_en-US/Data/profile || die
266 # create wrapper to start torbrowser
267 make_wrapper ${PN} "/usr/$(get_libdir)/${PN}/${MY_PN}/${MY_PN} -no-remote -profile ~/.${PN}/profile"
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
276 elog "Copy the folder /usr/share/${PN}/profile into ~/.${PN} and run '${PN}'."
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."
282 elog "Note that torbrowser uses a different _plugins_ folder too:"
283 elog "/usr/$(get_libdir)/${PN}/nsbrowser/plugins"