1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
8 MOZ_LIGHTNING_VER="2.6.5"
9 MOZ_LIGHTNING_GDATA_VER="2.6.3"
11 # This list can be updated using scripts/get_langs.sh from the mozilla overlay
12 MOZ_LANGS=(ar ast be bg bn-BD br ca cs da de el en en-GB en-US es-AR
13 es-ES et eu fi fr fy-NL ga-IE gd gl he hr hu hy-AM id is it ja ko lt nb-NO
14 nl nn-NO pa-IN pl pt-BR pt-PT rm ro ru si sk sl sq sr sv-SE ta-LK tr uk vi
17 # Convert the ebuild version to th firefox-24.0-patches-0.4.tar.xze upstream mozilla version, used by mozlinguas
18 MOZ_PV="${PV/_beta/b}"
19 # ESR releases have slightly version numbers
20 if [[ ${MOZ_ESR} == 1 ]]; then
23 MOZ_P="${PN}-${MOZ_PV}"
27 # Upstream ftp release URI that's used by mozlinguas.eclass
28 # We don't use the http mirror because it deletes old tarballs.
29 MOZ_FTP_URI="ftp://ftp.mozilla.org/pub/${PN}/releases/"
30 MOZ_HTTP_URI="http://ftp.mozilla.org/pub/${PN}/releases/"
32 inherit flag-o-matic toolchain-funcs mozconfig-3 makeedit multilib autotools pax-utils check-reqs nsplugins mozlinguas
34 DESCRIPTION="Thunderbird Mail Client"
35 HOMEPAGE="http://www.mozilla.com/en-US/thunderbird/"
37 KEYWORDS="~alpha amd64 ~arm ppc ppc64 x86 ~x86-fbsd ~amd64-linux ~x86-linux"
39 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
40 IUSE="bindist crypt gstreamer +jit ldap +lightning +minimal mozdom pulseaudio selinux system-cairo system-icu system-jpeg system-sqlite"
41 RESTRICT="!bindist? ( bindist )"
43 PATCH="thunderbird-24.0-patches-0.1"
44 PATCHFF="firefox-24.0-patches-0.9"
47 ${MOZ_FTP_URI}${MOZ_PV}/source/${MOZ_P}.source.tar.bz2
48 ${MOZ_HTTP_URI}${MOZ_PV}/source/${MOZ_P}.source.tar.bz2
49 crypt? ( http://www.enigmail.net/download/source/enigmail-${EMVER}.tar.gz )
51 ${MOZ_HTTP_URI/${PN}/calendar/lightning}${MOZ_LIGHTNING_VER}/linux/lightning.xpi -> lightning-${MOZ_LIGHTNING_VER}.xpi
52 ${MOZ_HTTP_URI/${PN}/calendar/lightning}${MOZ_LIGHTNING_GDATA_VER}/linux/gdata-provider.xpi -> gdata-provider-${MOZ_LIGHTNING_GDATA_VER}.xpi
54 https://dev.gentoo.org/~anarchy/mozilla/patchsets/${PATCH}.tar.xz
55 https://dev.gentoo.org/~anarchy/mozilla/patchsets/${PATCHFF}.tar.xz
56 https://dev.gentoo.org/~polynomial-c/mozilla/patchsets/${PATCH}.tar.xz"
58 ASM_DEPEND=">=dev-lang/yasm-1.1"
62 >=dev-libs/nspr-4.10.4
63 >=dev-libs/glib-2.26:2
64 >=media-libs/mesa-7.10
65 >=media-libs/libpng-1.6.6[apng]
67 gstreamer? ( media-plugins/gst-plugins-meta:0.10[ffmpeg] )
68 pulseaudio? ( media-sound/pulseaudio )
69 system-cairo? ( >=x11-libs/cairo-1.12[X] )
70 system-icu? ( >=dev-libs/icu-51.1 )
71 system-jpeg? ( >=media-libs/libjpeg-turbo-1.2.1 )
72 system-sqlite? ( >=dev-db/sqlite-3.8.0.2:3[secure-delete,debug=] )
73 >=media-libs/libvpx-1.0.0
74 <media-libs/libvpx-1.4
75 kernel_linux? ( media-libs/alsa-lib )
78 ( >=app-crypt/gnupg-2.0
80 app-crypt/pinentry[gtk]
81 app-crypt/pinentry[qt4]
88 >=sys-devel/binutils-2.16.1
90 amd64? ( ${ASM_DEPEND}
96 selinux? ( sec-policy/selinux-thunderbird )
99 if [[ ${PV} =~ beta ]]; then
100 S="${WORKDIR}/comm-beta"
102 S="${WORKDIR}/comm-esr${PV%%.*}"
108 export MOZILLA_DIR="${S}/mozilla"
110 if ! use bindist ; then
111 elog "You are enabling official branding. You may not redistribute this build"
112 elog "to any users on your network or the internet. Doing so puts yourself into"
113 elog "a legal problem with Mozilla Foundation"
114 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
120 # Ensure we have enough disk space to compile
121 CHECKREQS_DISK_BUILD="4G"
128 # Unpack language packs
129 mozlinguas_src_unpack
131 # Unpack lightning for calendar locales
132 if use lightning ; then
133 xpi_unpack lightning-${MOZ_LIGHTNING_VER}.xpi
134 xpi_unpack gdata-provider-${MOZ_LIGHTNING_GDATA_VER}.xpi
139 # Apply our Thunderbird patchset
140 EPATCH_SUFFIX="patch" \
142 epatch "${WORKDIR}/thunderbird"
144 # Apply our patchset from firefox to thunderbird as well
145 pushd "${S}"/mozilla &>/dev/null || die
146 EPATCH_SUFFIX="patch" \
148 epatch "${WORKDIR}/firefox"
149 popd &>/dev/null || die
152 mv "${WORKDIR}"/enigmail "${S}"/mailnews/extensions/enigmail
153 pushd "${S}"/mailnews/extensions/enigmail &>/dev/null || die
154 epatch "${FILESDIR}"/enigmail-1.6.0-parallel-fix.patch
155 popd &>/dev/null || die
158 # Ensure that are plugins dir is enabled as default
159 sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \
160 "${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!"
161 sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \
162 "${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!"
164 # Don't exit with error when some libs are missing which we have in
166 sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
167 -i "${S}"/mail/installer/Makefile.in || die
169 # Don't error out when there's no files to be removed:
170 sed 's@\(xargs rm\)$@\1 -f@' \
171 -i "${S}"/mozilla/toolkit/mozapps/installer/packager.mk || die
173 # Shell scripts sometimes contain DOS line endings; bug 391889
174 grep -rlZ --include="*.sh" $'\r$' . |
175 while read -r -d $'\0' file ; do
176 einfo edos2unix "${file}"
180 # Confirm the version of lightning being grabbed for langpacks is the same
181 # as that used in thunderbird
182 local THIS_MOZ_LIGHTNING_VER=$(cat "${S}"/calendar/sunbird/config/version.txt)
183 if [[ ${MOZ_LIGHTNING_VER} != ${THIS_MOZ_LIGHTNING_VER} ]]; then
184 eqawarn "The version of lightning used for localization differs from the version"
185 eqawarn "in thunderbird. Please update MOZ_LIGHTNING_VER in the ebuild from ${MOZ_LIGHTNING_VER}"
186 eqawarn "to ${THIS_MOZ_LIGHTNING_VER}"
189 # Allow user to apply any additional patches without modifing ebuild
193 # Ensure we run eautoreconf in mozilla to regenerate configure
199 declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
200 MEXTENSIONS="default"
202 ####################################
204 # mozconfig, CFLAGS and CXXFLAGS setup
206 ####################################
211 # It doesn't compile on alpha without this LDFLAGS
212 use alpha && append-ldflags "-Wl,--no-relax"
214 # We must force enable jemalloc 3 threw .mozconfig
215 echo "export MOZ_JEMALLOC=1" >> ${S}/.mozconfig
217 mozconfig_annotate '' --enable-jemalloc
218 mozconfig_annotate '' --enable-replace-malloc
219 mozconfig_annotate '' --prefix="${EPREFIX}"/usr
220 mozconfig_annotate '' --libdir="${EPREFIX}"/usr/$(get_libdir)
221 mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
222 mozconfig_annotate '' --disable-gconf
223 mozconfig_annotate '' --disable-mailnews
224 mozconfig_annotate '' --with-system-png
225 mozconfig_annotate '' --enable-system-ffi
227 # Other ff-specific settings
228 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
229 mozconfig_annotate '' --with-user-appdir=.thunderbird
230 mozconfig_annotate '' --target="${CTARGET:-${CHOST}}"
231 mozconfig_annotate '' --build="${CTARGET:-${CHOST}}"
233 # Use enable features
234 mozconfig_use_enable gstreamer
235 mozconfig_use_enable pulseaudio
236 mozconfig_use_enable system-cairo
237 mozconfig_use_enable system-sqlite
238 mozconfig_use_with system-jpeg
239 mozconfig_use_with system-icu
240 mozconfig_use_enable system-icu intl-api
241 mozconfig_use_enable lightning calendar
242 mozconfig_use_enable ldap
243 # Feature is know to cause problems on hardened
244 mozconfig_use_enable jit ion
248 MEXTENSIONS="${MEXTENSIONS},inspector"
251 # Use an objdir to keep things organized.
252 echo "mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/tbird" >> "${S}"/.mozconfig
254 # Finalize and report settings
257 ####################################
259 # Configure and build
261 ####################################
263 # Disable no-print-directory
264 MAKEOPTS=${MAKEOPTS/--no-print-directory/}
266 if [[ $(gcc-major-version) -lt 4 ]]; then
267 append-cxxflags -fno-stack-protector
268 elif [[ $(gcc-major-version) -gt 4 || $(gcc-minor-version) -gt 3 ]]; then
269 if use amd64 || use x86; then
270 append-flags -mno-avx
276 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
277 MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL}" \
280 # Only build enigmail extension if crypt enabled.
282 cd "${S}"/mailnews/extensions/enigmail || die
283 ./makemake -r 2&> /dev/null
284 cd "${S}"/tbird/mailnews/extensions/enigmail
291 declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
292 DICTPATH="\"${EPREFIX}/usr/share/myspell\""
295 local obj_dir="tbird"
298 # Copy our preference before omnijar is created.
299 cp "${FILESDIR}"/thunderbird-gentoo-default-prefs-1.js-1 \
300 "${S}/${obj_dir}/mozilla/dist/bin/defaults/pref/all-gentoo.js" \
303 # Set default path to search for dictionaries.
304 echo "pref(\"spellchecker.dictionary_path\", ${DICTPATH});" \
305 >> "${S}/${obj_dir}/mozilla/dist/bin/defaults/pref/all-gentoo.js" \
308 # Pax mark xpcshell for hardened support, only used for startupcache creation.
309 pax-mark m "${S}"/${obj_dir}/mozilla/dist/bin/xpcshell
311 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
312 emake DESTDIR="${D}" install
314 # Install language packs
315 mozlinguas_src_install
317 if ! use bindist; then
318 newicon "${S}"/other-licenses/branding/thunderbird/content/icon48.png thunderbird-icon.png
319 domenu "${FILESDIR}"/icon/${PN}.desktop
321 newicon "${S}"/mail/branding/aurora/content/icon48.png thunderbird-icon-unbranded.png
322 newmenu "${FILESDIR}"/icon/${PN}-unbranded.desktop \
325 sed -i -e "s:Mozilla\ Thunderbird:EarlyBird:g" \
326 "${ED}"/usr/share/applications/${PN}.desktop
331 unzip "${S}"/${obj_dir}/mozilla/dist/bin/enigmail*.xpi install.rdf \
333 emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' install.rdf)
335 dodir ${MOZILLA_FIVE_HOME}/extensions/${emid} || die
336 cd "${D}"${MOZILLA_FIVE_HOME}/extensions/${emid} || die
337 unzip "${S}"/${obj_dir}/mozilla/dist/bin/enigmail*.xpi || die
340 if use lightning ; then
344 emid="{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}"
345 dodir ${MOZILLA_FIVE_HOME}/extensions/${emid}
346 cd "${ED}"${MOZILLA_FIVE_HOME}/extensions/${emid}
347 unzip "${S}"/${obj_dir}/mozilla/dist/xpi-stage/gdata-provider-*.xpi
348 # Install locales for gdata-provider -- each locale is a directory tree
349 insinto ${MOZILLA_FIVE_HOME}/extensions/${emid}/chrome
350 cd "${WORKDIR}"/gdata-provider-${MOZ_LIGHTNING_GDATA_VER}/chrome
351 for l in "${mozlinguas[@]}"; do if [[ -d gdata-provider-${l} ]]; then
352 doins -r gdata-provider-${l}
353 echo "locale gdata-provider ${l} chrome/gdata-provider-${l}/locale/${l}/" \
354 >> "${ED}"/${MOZILLA_FIVE_HOME}/extensions/${emid}/chrome.manifest \
355 || die "Error adding gdata-provider-${l} to chrome.manifest"
357 ewarn "Sorry, but lightning gdata-provider in ${P} does not support the ${l} locale"
360 emid="{e2fda1a4-762b-4020-b5ad-a41df1933103}"
361 dodir ${MOZILLA_FIVE_HOME}/extensions/${emid}
362 cd "${ED}"${MOZILLA_FIVE_HOME}/extensions/${emid} || die
363 unzip "${S}"/${obj_dir}/mozilla/dist/xpi-stage/lightning-*.xpi \
365 # Install locales for lightning - each locale is a jar file
366 insinto ${MOZILLA_FIVE_HOME}/extensions/${emid}/chrome
367 cd "${WORKDIR}"/lightning-${MOZ_LIGHTNING_VER}/chrome || die
368 for l in "${mozlinguas[@]}"; do if [[ -e calendar-${l}.jar ]]; then
369 for c in calendar lightning; do
371 echo "locale ${c} $l jar:chrome/${c}-${l}.jar!/locale/${l}/${c}/" \
372 >> "${ED}"/${MOZILLA_FIVE_HOME}/extensions/${emid}/chrome.manifest \
373 || die "Error adding ${c}-${l} to chrome.manifest"
376 ewarn "Sorry, but lightning calendar in ${P} does not support the ${l} locale"
379 # Fix mimetype so it shows up as a calendar application in GNOME 3
380 # This requires that the .desktop file was already installed earlier
381 sed -e "s:^\(MimeType=\):\1text/calendar;:" \
382 -e "s:^\(Categories=\):\1Calendar;:" \
383 -i "${ED}"/usr/share/applications/${PN}.desktop || die
386 pax-mark m "${ED}"/${MOZILLA_FIVE_HOME}/{thunderbird-bin,thunderbird}
388 # Plugin-container needs to be pax-marked for hardened to ensure plugins such as flash
389 # continue to work as expected.
390 pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/plugin-container
393 rm -r "${ED}"/usr/include "${ED}"${MOZILLA_FIVE_HOME}/{idl,include,lib,sdk} || \
394 die "Failed to remove sdk and headers"
400 elog "If you experience problems with plugins please issue the"
401 elog "following command : rm \${HOME}/.thunderbird/*/extensions.sqlite ,"
402 elog "then restart thunderbird"