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