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 )"
67 S="${WORKDIR}/mozilla-release"
69 QA_PRESTRIPPED="usr/$(get_libdir)/${PN}/${MY_PN}/firefox"
74 # Avoid PGO profiling problems due to enviroment leakage
75 # These should *always* be cleaned up anyway
76 unset DBUS_SESSION_BUS_ADDRESS \
83 if ! use bindist; then
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"
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."
97 # Ensure we have enough disk space to compile
98 if use pgo || use debug || use test ; then
99 CHECKREQS_DISK_BUILD="8G"
101 CHECKREQS_DISK_BUILD="4G"
108 EPATCH_SUFFIX="patch" \
110 epatch "${WORKDIR}/firefox"
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" \
116 epatch "${FILESDIR}/${PV}"
118 # Allow user to apply any additional patches without modifing ebuild
121 # Enable gnomebreakpad
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!"
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"
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!"
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,} \
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"
155 MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
156 MEXTENSIONS="default"
158 ####################################
160 # mozconfig, CFLAGS and CXXFLAGS setup
162 ####################################
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
177 # Other ff-specific settings
178 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
179 mozconfig_annotate '' --target="${CTARGET:-${CHOST}}"
181 # Allow for a proper pgo build
183 echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig
186 # Finalize and report settings
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
201 addpredict /etc/gconf
202 # Reset and cleanup environment variables used by GNOME/XDG
203 gnome2_environment_reset
205 # Firefox tries to use dri stuff when it's run, see bug 380283
207 cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
208 if test -n "${cards}"; then
209 # FOSS drivers are fine
210 addpredict "${cards}"
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}"
223 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
224 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
225 Xemake -f client.mk profiledbuild || die "Xemake failed"
227 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
228 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
229 emake -f client.mk || die "emake failed"
234 MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}/${MY_PN}"
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%/*}"
241 # Pax mark xpcshell for hardened support, only used for startupcache creation.
242 pax-mark m "${S}/${obj_dir}"/dist/bin/xpcshell
244 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
245 emake DESTDIR="${D}" install || die "emake install failed"
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"
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}
259 dodir /usr/$(get_libdir)/${PN}/nsbrowser/plugins || die
261 # Install pre-configured Torbrowser-profile
262 insinto /usr/share/${PN}
263 doins -r "${WORKDIR}"/tor-browser_en-US/Data/profile || die
265 # create wrapper to start torbrowser
266 make_wrapper ${PN} "/usr/$(get_libdir)/${PN}/${MY_PN}/${MY_PN} -no-remote -profile ~/.${PN}/profile"
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
275 elog "Copy the folder /usr/share/${PN}/profile into ~/.${PN} and run '${PN}'."
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."
281 elog "Note that torbrowser uses a different _plugins_ folder too:"
282 elog "/usr/$(get_libdir)/${PN}/nsbrowser/plugins"