mail-client/thunderbird: drop old
[gentoo.git] / mail-client / thunderbird / thunderbird-45.0.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6 WANT_AUTOCONF="2.1"
7 MOZ_ESR=""
8 MOZ_LIGHTNING_VER="4.7"
9 MOZ_LIGHTNING_GDATA_VER="2.6"
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 cy 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 hsb hu hy-AM id is it ja ko lt
14 nb-NO nl nn-NO pa-IN pl pt-BR pt-PT rm ro ru si sk sl sq sr sv-SE ta-LK tr
15 uk vi zh-CN zh-TW )
16
17 # Convert the ebuild version to the 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.9.1"
27
28 # Patches
29 PATCH="thunderbird-38.0-patches-0.1"
30 PATCHFF="firefox-45.0-patches-03"
31
32 MOZ_HTTP_URI="https://archive.mozilla.org/pub/${PN}/releases"
33
34 MOZCONFIG_OPTIONAL_JIT="enabled"
35 inherit flag-o-matic toolchain-funcs mozconfig-v6.45 makeedit autotools pax-utils check-reqs nsplugins mozlinguas
36
37 DESCRIPTION="Thunderbird Mail Client"
38 HOMEPAGE="http://www.mozilla.com/en-US/thunderbird/"
39
40 KEYWORDS="~alpha ~amd64 ~arm ~ppc ~ppc64 ~x86 ~x86-fbsd ~amd64-linux ~x86-linux"
41 SLOT="0"
42 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
43 IUSE="bindist crypt hardened ldap lightning +minimal mozdom selinux"
44 RESTRICT="!bindist? ( bindist )"
45
46 PATCH_URIS=( https://dev.gentoo.org/~{anarchy,axs,polynomial-c}/mozilla/patchsets/{${PATCH},${PATCHFF}}.tar.xz )
47 SRC_URI="${SRC_URI}
48         ${MOZ_HTTP_URI}/${MOZ_PV}/source/${MOZ_P}.source.tar.xz
49         https://dev.gentoo.org/~axs/distfiles/lightning-${MOZ_LIGHTNING_VER}.tar.xz
50         lightning? ( https://dev.gentoo.org/~axs/distfiles/gdata-provider-${MOZ_LIGHTNING_GDATA_VER}.tar.xz )
51         crypt? ( http://www.enigmail.net/download/source/enigmail-${EMVER}.tar.gz )
52         ${PATCH_URIS[@]}"
53
54 ASM_DEPEND=">=dev-lang/yasm-1.1"
55
56 CDEPEND="
57         >=dev-libs/nss-3.21.1
58         >=dev-libs/nspr-4.12
59         !x11-plugins/enigmail
60         crypt?  ( || (
61                 ( >=app-crypt/gnupg-2.0
62                         || (
63                                 app-crypt/pinentry[gtk]
64                                 app-crypt/pinentry[qt4]
65                         )
66                 )
67                 =app-crypt/gnupg-1.4*
68         ) )"
69
70 DEPEND="${CDEPEND}
71         amd64? ( ${ASM_DEPEND}
72                 virtual/opengl )
73         x86? ( ${ASM_DEPEND}
74                 virtual/opengl )"
75
76 RDEPEND="${CDEPEND}
77         selinux? ( sec-policy/selinux-thunderbird )
78 "
79
80 S="${WORKDIR}/${MOZ_P}"
81
82 BUILD_OBJ_DIR="${S}/tbird"
83
84 pkg_setup() {
85         moz_pkgsetup
86
87         export MOZILLA_DIR="${S}/mozilla"
88
89         if ! use bindist ; then
90                 elog "You are enabling official branding. You may not redistribute this build"
91                 elog "to any users on your network or the internet. Doing so puts yourself into"
92                 elog "a legal problem with Mozilla Foundation"
93                 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
94                 elog
95         fi
96 }
97
98 pkg_pretend() {
99         # Ensure we have enough disk space to compile
100         CHECKREQS_DISK_BUILD="4G"
101         check-reqs_pkg_setup
102
103         if use jit && [[ -n ${PROFILE_IS_HARDENED} ]]; then
104                 ewarn "You are emerging this package on a hardened profile with USE=jit enabled."
105                 ewarn "This is horribly insecure as it disables all PAGEEXEC restrictions."
106                 ewarn "Please ensure you know what you are doing.  If you don't, please consider"
107                 ewarn "emerging the package with USE=-jit"
108         fi
109 }
110
111 src_unpack() {
112         unpack ${A}
113
114         # Unpack language packs
115         mozlinguas_src_unpack
116
117         # this version of lightning is a .tar.xz, no xpi needed
118         #xpi_unpack lightning-${MOZ_LIGHTNING_VER}.xpi
119
120         # this version of gdata-provider is a .tar.xz , no xpi needed
121         #use lightning && xpi_unpack gdata-provider-${MOZ_LIGHTNING_GDATA_VER}.xpi
122 }
123
124 src_prepare() {
125         # Apply our Thunderbird patchset
126         rm -f "${WORKDIR}"/thunderbird/2001_ldap_respect_cflags.patch
127         eapply "${WORKDIR}/thunderbird"
128
129         # Apply our patchset from firefox to thunderbird as well
130         pushd "${S}"/mozilla &>/dev/null || die
131         eapply "${WORKDIR}/firefox"
132         popd &>/dev/null || die
133
134         # Ensure that are plugins dir is enabled as default
135         sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \
136                 "${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!"
137         sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \
138                 "${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!"
139
140         # Don't exit with error when some libs are missing which we have in
141         # system.
142         sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
143                 -i "${S}"/mail/installer/Makefile.in || die
144
145         # Don't error out when there's no files to be removed:
146         sed 's@\(xargs rm\)$@\1 -f@' \
147                 -i "${S}"/mozilla/toolkit/mozapps/installer/packager.mk || die
148
149         # Shell scripts sometimes contain DOS line endings; bug 391889
150         grep -rlZ --include="*.sh" $'\r$' . |
151         while read -r -d $'\0' file ; do
152                 einfo edos2unix "${file}"
153                 edos2unix "${file}"
154         done
155
156         # Allow user to apply any additional patches without modifing ebuild
157         eapply_user
158
159         # Confirm the version of lightning being grabbed for langpacks is the same
160         # as that used in thunderbird
161         local THIS_MOZ_LIGHTNING_VER=$(python "${S}"/calendar/lightning/build/makeversion.py ${PV})
162         if [[ ${MOZ_LIGHTNING_VER} != ${THIS_MOZ_LIGHTNING_VER} ]]; then
163                 eqawarn "The version of lightning used for localization differs from the version"
164                 eqawarn "in thunderbird.  Please update MOZ_LIGHTNING_VER in the ebuild from ${MOZ_LIGHTNING_VER}"
165                 eqawarn "to ${THIS_MOZ_LIGHTNING_VER}"
166         fi
167
168         eautoreconf
169         # Ensure we run eautoreconf in mozilla to regenerate configure
170         cd "${S}"/mozilla || die
171         eautoconf
172         cd "${S}"/mozilla/js/src || die
173         eautoconf
174 }
175
176 src_configure() {
177         declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
178         MEXTENSIONS="default"
179
180         ####################################
181         #
182         # mozconfig, CFLAGS and CXXFLAGS setup
183         #
184         ####################################
185
186         mozconfig_init
187         mozconfig_config
188
189         # We want rpath support to prevent unneeded hacks on different libc variants
190         append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}"
191
192         # It doesn't compile on alpha without this LDFLAGS
193         use alpha && append-ldflags "-Wl,--no-relax"
194
195         # Add full relro support for hardened
196         use hardened && append-ldflags "-Wl,-z,relro,-z,now"
197
198         mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
199         mozconfig_annotate '' --disable-mailnews
200         mozconfig_annotate '' --enable-calendar
201
202         # Other tb-specific settings
203         mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
204         mozconfig_annotate '' --with-user-appdir=.thunderbird
205
206         mozconfig_use_enable ldap
207
208         mozlinguas_mozconfig
209
210         # Bug #72667
211         if use mozdom; then
212                 MEXTENSIONS="${MEXTENSIONS},inspector"
213         fi
214
215         # Use an objdir to keep things organized.
216         echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig
217
218         # Finalize and report settings
219         mozconfig_final
220
221         ####################################
222         #
223         #  Configure and build
224         #
225         ####################################
226
227         # Disable no-print-directory
228         MAKEOPTS=${MAKEOPTS/--no-print-directory/}
229
230         if [[ $(gcc-major-version) -lt 4 ]]; then
231                 append-cxxflags -fno-stack-protector
232         fi
233
234         if use crypt; then
235                 pushd "${WORKDIR}"/enigmail &>/dev/null ||die
236                 econf
237                 popd &>/dev/null ||die
238         fi
239 }
240
241 src_compile() {
242         mkdir -p "${BUILD_OBJ_DIR}" && cd "${BUILD_OBJ_DIR}" || die
243
244         CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
245         MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX%/}/bin/bash}" \
246         emake -f "${S}"/client.mk
247
248         # Only build enigmail extension if crypt enabled.
249         if use crypt ; then
250                 einfo "Building enigmail"
251                 pushd "${WORKDIR}"/enigmail &>/dev/null || die
252                 emake -j1
253                 emake -j1 xpi
254                 popd &>/dev/null || die
255         fi
256 }
257
258 src_install() {
259         declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
260         DICTPATH="\"${EPREFIX}/usr/share/myspell\""
261
262         declare emid
263         cd "${BUILD_OBJ_DIR}" || die
264
265         # Copy our preference before omnijar is created.
266         cp "${FILESDIR}"/thunderbird-gentoo-default-prefs-1.js-1 \
267                 "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \
268                 || die
269
270         # Set default path to search for dictionaries.
271         echo "pref(\"spellchecker.dictionary_path\", ${DICTPATH});" \
272                 >> "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \
273                 || die
274
275         # Pax mark xpcshell for hardened support, only used for startupcache creation.
276         pax-mark m "${BUILD_OBJ_DIR}"/dist/bin/xpcshell
277
278         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
279         emake DESTDIR="${D}" install
280
281         # Install language packs
282         mozlinguas_src_install
283
284         if ! use bindist; then
285                 newicon "${S}"/other-licenses/branding/thunderbird/content/icon48.png thunderbird-icon.png
286                 domenu "${FILESDIR}"/icon/${PN}.desktop
287         else
288                 newicon "${S}"/mail/branding/aurora/content/icon48.png thunderbird-icon-unbranded.png
289                 newmenu "${FILESDIR}"/icon/${PN}-unbranded.desktop \
290                         ${PN}.desktop
291
292                 sed -i -e "s:Mozilla\ Thunderbird:EarlyBird:g" \
293                         "${ED}"/usr/share/applications/${PN}.desktop
294         fi
295
296         local emid
297         # stage extra locales for lightning and install over existing
298         mozlinguas_xpistage_langpacks "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning \
299                 "${WORKDIR}"/lightning-${MOZ_LIGHTNING_VER} lightning calendar
300
301         emid='{e2fda1a4-762b-4020-b5ad-a41df1933103}'
302         mkdir -p "${T}/${emid}" || die
303         cp -RLp -t "${T}/${emid}" "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning/* || die
304         insinto ${MOZILLA_FIVE_HOME}/distribution/extensions
305         doins -r "${T}/${emid}"
306
307         if use lightning; then
308                 # move lightning out of distribution/extensions and into extensions for app-global install
309                 mv "${ED}"/${MOZILLA_FIVE_HOME}/{distribution,}/extensions/${emid} || die
310
311                 # stage extra locales for gdata-provider and install app-global
312                 mozlinguas_xpistage_langpacks "${BUILD_OBJ_DIR}"/dist/xpi-stage/gdata-provider \
313                         "${WORKDIR}"/gdata-provider-${MOZ_LIGHTNING_GDATA_VER}
314                 emid='{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}'
315                 mkdir -p "${T}/${emid}" || die
316                 cp -RLp -t "${T}/${emid}" "${BUILD_OBJ_DIR}"/dist/xpi-stage/gdata-provider/* || die
317                 insinto ${MOZILLA_FIVE_HOME}/extensions
318                 doins -r "${T}/${emid}"
319         fi
320
321         if use crypt ; then
322                 local enigmail_xpipath="${WORKDIR}/enigmail/build"
323                 cd "${T}" || die
324                 unzip "${enigmail_xpipath}"/enigmail*.xpi install.rdf || die
325                 emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' install.rdf)
326
327                 dodir ${MOZILLA_FIVE_HOME}/extensions/${emid} || die
328                 cd "${ED}"${MOZILLA_FIVE_HOME}/extensions/${emid} || die
329                 unzip "${enigmail_xpipath}"/enigmail*.xpi || die
330         fi
331
332         # Required in order for jit to work on hardened, for mozilla-31 and above
333         use jit && pax-mark pm "${ED}"${MOZILLA_FIVE_HOME}/{thunderbird,thunderbird-bin}
334
335         # Plugin-container needs to be pax-marked for hardened to ensure plugins such as flash
336         # continue to work as expected.
337         pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/plugin-container
338
339         if use minimal; then
340                 rm -r "${ED}"/usr/include "${ED}"${MOZILLA_FIVE_HOME}/{idl,include,lib,sdk} || \
341                         die "Failed to remove sdk and headers"
342         fi
343 }
344
345 pkg_postinst() {
346         if use crypt; then
347                 local peimpl=$(eselect --brief --colour=no pinentry show)
348                 case "${peimpl}" in
349                 *gtk*|*qt*) ;;
350                 *)      ewarn "The pinentry front-end currently selected is not one supported by thunderbird."
351                         ewarn "You may be prompted for your password in an inaccessible shell!!"
352                         ewarn "Please use 'eselect pinentry' to select either the gtk or qt front-end"
353                         ;;
354                 esac
355         fi
356         elog
357         elog "If you experience problems with plugins please issue the"
358         elog "following command : rm \${HOME}/.thunderbird/*/extensions.sqlite ,"
359         elog "then restart thunderbird"
360         if ! use lightning; then
361                 elog
362                 elog "If calendar fails to show up in extensions please open config editor"
363                 elog "and set extensions.lastAppVersion to 38.0.0 to force a reload. If this"
364                 elog "fails to show the calendar extension after restarting with above change"
365                 elog "please file a bug report."
366         fi
367 }