Use https by default
[gentoo.git] / mail-client / thunderbird / thunderbird-24.8.0.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 WANT_AUTOCONF="2.1"
7 MOZ_ESR=""
8 MOZ_LIGHTNING_VER="2.6.5"
9 MOZ_LIGHTNING_GDATA_VER="2.6.3"
10
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
15 zh-CN zh-TW )
16
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
21         MOZ_PV="${MOZ_PV}esr"
22 fi
23 MOZ_P="${PN}-${MOZ_PV}"
24
25 # Enigmail version
26 EMVER="1.6"
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/"
31
32 inherit flag-o-matic toolchain-funcs mozconfig-3 makeedit multilib autotools pax-utils check-reqs nsplugins mozlinguas
33
34 DESCRIPTION="Thunderbird Mail Client"
35 HOMEPAGE="http://www.mozilla.com/en-US/thunderbird/"
36
37 KEYWORDS="~alpha amd64 ~arm ppc ppc64 x86 ~x86-fbsd ~amd64-linux ~x86-linux"
38 SLOT="0"
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 )"
42
43 PATCH="thunderbird-24.0-patches-0.1"
44 PATCHFF="firefox-24.0-patches-0.9"
45
46 SRC_URI="${SRC_URI}
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 )
50         lightning? (
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
53         )
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"
57
58 ASM_DEPEND=">=dev-lang/yasm-1.1"
59
60 CDEPEND="
61         >=dev-libs/nss-3.16.2
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]
66         virtual/libffi
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 )
76         !x11-plugins/enigmail
77         crypt?  ( || (
78                 ( >=app-crypt/gnupg-2.0
79                         || (
80                                 app-crypt/pinentry[gtk]
81                                 app-crypt/pinentry[qt4]
82                         )
83                 )
84                 =app-crypt/gnupg-1.4*
85         ) )"
86
87 DEPEND="${CDEPEND}
88         >=sys-devel/binutils-2.16.1
89         virtual/pkgconfig
90         amd64? ( ${ASM_DEPEND}
91                 virtual/opengl )
92         x86? ( ${ASM_DEPEND}
93                 virtual/opengl )"
94
95 RDEPEND="${CDEPEND}
96         selinux? ( sec-policy/selinux-thunderbird )
97 "
98
99 if [[ ${PV} =~ beta ]]; then
100         S="${WORKDIR}/comm-beta"
101 else
102         S="${WORKDIR}/comm-esr${PV%%.*}"
103 fi
104
105 pkg_setup() {
106         moz_pkgsetup
107
108         export MOZILLA_DIR="${S}/mozilla"
109
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"
115                 elog
116         fi
117 }
118
119 pkg_pretend() {
120         # Ensure we have enough disk space to compile
121         CHECKREQS_DISK_BUILD="4G"
122         check-reqs_pkg_setup
123 }
124
125 src_unpack() {
126         unpack ${A}
127
128         # Unpack language packs
129         mozlinguas_src_unpack
130
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
135         fi
136 }
137
138 src_prepare() {
139         # Apply our Thunderbird patchset
140         EPATCH_SUFFIX="patch" \
141         EPATCH_FORCE="yes" \
142         epatch "${WORKDIR}/thunderbird"
143
144         # Apply our patchset from firefox to thunderbird as well
145         pushd "${S}"/mozilla &>/dev/null || die
146         EPATCH_SUFFIX="patch" \
147         EPATCH_FORCE="yes" \
148         epatch "${WORKDIR}/firefox"
149         popd &>/dev/null || die
150
151         if use crypt ; then
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
156         fi
157
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!"
163
164         # Don't exit with error when some libs are missing which we have in
165         # system.
166         sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
167                 -i "${S}"/mail/installer/Makefile.in || die
168
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
172
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}"
177                 edos2unix "${file}"
178         done
179
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}"
187         fi
188
189         # Allow user to apply any additional patches without modifing ebuild
190         epatch_user
191
192         eautoreconf
193         # Ensure we run eautoreconf in mozilla to regenerate configure
194         cd "${S}"/mozilla
195         eautoconf
196 }
197
198 src_configure() {
199         declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
200         MEXTENSIONS="default"
201
202         ####################################
203         #
204         # mozconfig, CFLAGS and CXXFLAGS setup
205         #
206         ####################################
207
208         mozconfig_init
209         mozconfig_config
210
211         # It doesn't compile on alpha without this LDFLAGS
212         use alpha && append-ldflags "-Wl,--no-relax"
213
214         # We must force enable jemalloc 3 threw .mozconfig
215         echo "export MOZ_JEMALLOC=1" >> ${S}/.mozconfig
216
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
226
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}}"
232
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
245
246         # Bug #72667
247         if use mozdom; then
248                 MEXTENSIONS="${MEXTENSIONS},inspector"
249         fi
250
251         # Use an objdir to keep things organized.
252         echo "mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/tbird" >> "${S}"/.mozconfig
253
254         # Finalize and report settings
255         mozconfig_final
256
257         ####################################
258         #
259         #  Configure and build
260         #
261         ####################################
262
263         # Disable no-print-directory
264         MAKEOPTS=${MAKEOPTS/--no-print-directory/}
265
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
271                 fi
272         fi
273 }
274
275 src_compile() {
276         CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
277         MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL}" \
278         emake -f client.mk
279
280         # Only build enigmail extension if crypt enabled.
281         if use crypt ; then
282                 cd "${S}"/mailnews/extensions/enigmail || die
283                 ./makemake -r 2&> /dev/null
284                 cd "${S}"/tbird/mailnews/extensions/enigmail
285                 emake
286                 emake xpi
287         fi
288 }
289
290 src_install() {
291         declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
292         DICTPATH="\"${EPREFIX}/usr/share/myspell\""
293
294         declare emid
295         local obj_dir="tbird"
296         cd "${S}/${obj_dir}"
297
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" \
301                 || die
302
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" \
306                 || die
307
308         # Pax mark xpcshell for hardened support, only used for startupcache creation.
309         pax-mark m "${S}"/${obj_dir}/mozilla/dist/bin/xpcshell
310
311         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
312         emake DESTDIR="${D}" install
313
314         # Install language packs
315         mozlinguas_src_install
316
317         if ! use bindist; then
318                 newicon "${S}"/other-licenses/branding/thunderbird/content/icon48.png thunderbird-icon.png
319                 domenu "${FILESDIR}"/icon/${PN}.desktop
320         else
321                 newicon "${S}"/mail/branding/aurora/content/icon48.png thunderbird-icon-unbranded.png
322                 newmenu "${FILESDIR}"/icon/${PN}-unbranded.desktop \
323                         ${PN}.desktop
324
325                 sed -i -e "s:Mozilla\ Thunderbird:EarlyBird:g" \
326                         "${ED}"/usr/share/applications/${PN}.desktop
327         fi
328
329         if use crypt ; then
330                 cd "${T}" || die
331                 unzip "${S}"/${obj_dir}/mozilla/dist/bin/enigmail*.xpi install.rdf \
332                 || die
333                 emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' install.rdf)
334
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
338         fi
339
340         if use lightning ; then
341                 local l c
342                 mozlinguas_export
343
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"
356                 else
357                         ewarn "Sorry, but lightning gdata-provider in ${P} does not support the ${l} locale"
358                 fi; done
359
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 \
364                         || die
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
370                                 doins ${c}-${l}.jar
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"
374                         done
375                 else
376                         ewarn "Sorry, but lightning calendar in ${P} does not support the ${l} locale"
377                 fi; done
378
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
384         fi
385
386         pax-mark m "${ED}"/${MOZILLA_FIVE_HOME}/{thunderbird-bin,thunderbird}
387
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
391
392         if use minimal; then
393                 rm -r "${ED}"/usr/include "${ED}"${MOZILLA_FIVE_HOME}/{idl,include,lib,sdk} || \
394                         die "Failed to remove sdk and headers"
395         fi
396 }
397
398 pkg_postinst() {
399         elog
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"
403 }