1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
8 MOZ_LIGHTNING_VER="4.7"
9 MOZ_LIGHTNING_GDATA_VER="2.6"
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
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
23 MOZ_P="${PN}-${MOZ_PV}"
29 PATCH="thunderbird-38.0-patches-0.1"
30 PATCHFF="firefox-45.0-patches-03"
32 MOZ_HTTP_URI="https://archive.mozilla.org/pub/${PN}/releases"
34 MOZCONFIG_OPTIONAL_JIT="enabled"
35 inherit flag-o-matic toolchain-funcs mozconfig-v6.45 makeedit autotools pax-utils check-reqs nsplugins mozlinguas
37 DESCRIPTION="Thunderbird Mail Client"
38 HOMEPAGE="http://www.mozilla.com/en-US/thunderbird/"
40 KEYWORDS="~alpha ~amd64 ~arm ~ppc ~ppc64 ~x86 ~x86-fbsd ~amd64-linux ~x86-linux"
42 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
43 IUSE="bindist crypt hardened ldap lightning +minimal mozdom selinux"
44 RESTRICT="!bindist? ( bindist )"
46 PATCH_URIS=( https://dev.gentoo.org/~{anarchy,axs,polynomial-c}/mozilla/patchsets/{${PATCH},${PATCHFF}}.tar.xz )
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 )
54 ASM_DEPEND=">=dev-lang/yasm-1.1"
61 ( >=app-crypt/gnupg-2.0
63 app-crypt/pinentry[gtk]
64 app-crypt/pinentry[qt4]
71 amd64? ( ${ASM_DEPEND}
77 selinux? ( sec-policy/selinux-thunderbird )
80 S="${WORKDIR}/${MOZ_P}"
82 BUILD_OBJ_DIR="${S}/tbird"
87 export MOZILLA_DIR="${S}/mozilla"
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"
99 # Ensure we have enough disk space to compile
100 CHECKREQS_DISK_BUILD="4G"
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"
114 # Unpack language packs
115 mozlinguas_src_unpack
117 # this version of lightning is a .tar.xz, no xpi needed
118 #xpi_unpack lightning-${MOZ_LIGHTNING_VER}.xpi
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
125 # Apply our Thunderbird patchset
126 rm -f "${WORKDIR}"/thunderbird/2001_ldap_respect_cflags.patch
127 eapply "${WORKDIR}/thunderbird"
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
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!"
140 # Don't exit with error when some libs are missing which we have in
142 sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
143 -i "${S}"/mail/installer/Makefile.in || die
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
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}"
156 # Allow user to apply any additional patches without modifing ebuild
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}"
169 # Ensure we run eautoreconf in mozilla to regenerate configure
170 cd "${S}"/mozilla || die
172 cd "${S}"/mozilla/js/src || die
177 declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
178 MEXTENSIONS="default"
180 ####################################
182 # mozconfig, CFLAGS and CXXFLAGS setup
184 ####################################
189 # We want rpath support to prevent unneeded hacks on different libc variants
190 append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}"
192 # It doesn't compile on alpha without this LDFLAGS
193 use alpha && append-ldflags "-Wl,--no-relax"
195 # Add full relro support for hardened
196 use hardened && append-ldflags "-Wl,-z,relro,-z,now"
198 mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
199 mozconfig_annotate '' --disable-mailnews
200 mozconfig_annotate '' --enable-calendar
202 # Other tb-specific settings
203 mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
204 mozconfig_annotate '' --with-user-appdir=.thunderbird
206 mozconfig_use_enable ldap
212 MEXTENSIONS="${MEXTENSIONS},inspector"
215 # Use an objdir to keep things organized.
216 echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig
218 # Finalize and report settings
221 ####################################
223 # Configure and build
225 ####################################
227 # Disable no-print-directory
228 MAKEOPTS=${MAKEOPTS/--no-print-directory/}
230 if [[ $(gcc-major-version) -lt 4 ]]; then
231 append-cxxflags -fno-stack-protector
235 pushd "${WORKDIR}"/enigmail &>/dev/null ||die
237 popd &>/dev/null ||die
242 mkdir -p "${BUILD_OBJ_DIR}" && cd "${BUILD_OBJ_DIR}" || die
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
248 # Only build enigmail extension if crypt enabled.
250 einfo "Building enigmail"
251 pushd "${WORKDIR}"/enigmail &>/dev/null || die
254 popd &>/dev/null || die
259 declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
260 DICTPATH="\"${EPREFIX}/usr/share/myspell\""
263 cd "${BUILD_OBJ_DIR}" || die
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" \
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" \
275 # Pax mark xpcshell for hardened support, only used for startupcache creation.
276 pax-mark m "${BUILD_OBJ_DIR}"/dist/bin/xpcshell
278 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
279 emake DESTDIR="${D}" install
281 # Install language packs
282 mozlinguas_src_install
284 if ! use bindist; then
285 newicon "${S}"/other-licenses/branding/thunderbird/content/icon48.png thunderbird-icon.png
286 domenu "${FILESDIR}"/icon/${PN}.desktop
288 newicon "${S}"/mail/branding/aurora/content/icon48.png thunderbird-icon-unbranded.png
289 newmenu "${FILESDIR}"/icon/${PN}-unbranded.desktop \
292 sed -i -e "s:Mozilla\ Thunderbird:EarlyBird:g" \
293 "${ED}"/usr/share/applications/${PN}.desktop
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
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}"
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
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}"
322 local enigmail_xpipath="${WORKDIR}/enigmail/build"
324 unzip "${enigmail_xpipath}"/enigmail*.xpi install.rdf || die
325 emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' install.rdf)
327 dodir ${MOZILLA_FIVE_HOME}/extensions/${emid} || die
328 cd "${ED}"${MOZILLA_FIVE_HOME}/extensions/${emid} || die
329 unzip "${enigmail_xpipath}"/enigmail*.xpi || die
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}
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
340 rm -r "${ED}"/usr/include "${ED}"${MOZILLA_FIVE_HOME}/{idl,include,lib,sdk} || \
341 die "Failed to remove sdk and headers"
347 local peimpl=$(eselect --brief --colour=no pinentry show)
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"
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
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."