1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 MOZ_LIGHTNING_VER="4.7.8"
8 MOZ_LIGHTNING_GDATA_VER="2.6"
10 # This list can be updated using scripts/get_langs.sh from the mozilla overlay
11 MOZ_LANGS=(ar ast be bg bn-BD br ca cs cy da de el en en-GB en-US es-AR
12 es-ES et eu fi fr fy-NL ga-IE gd gl he hr hsb hu hy-AM id is it ja ko lt
13 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
16 # Convert the ebuild version to the upstream mozilla version, used by mozlinguas
17 MOZ_PV="${PV/_beta/b}"
20 PATCH="thunderbird-38.0-patches-0.1"
21 PATCHFF="firefox-45.0-patches-12"
23 MOZ_HTTP_URI="https://archive.mozilla.org/pub/${PN}/releases"
25 # ESR releases have slightly version numbers
26 if [[ ${MOZ_ESR} == 1 ]]; then
29 MOZ_P="${PN}-${MOZ_PV}"
31 MOZCONFIG_OPTIONAL_JIT="enabled"
32 inherit flag-o-matic toolchain-funcs mozconfig-v6.45 autotools pax-utils check-reqs nsplugins mozlinguas-v2 xdg-utils gnome2-utils
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 hardened ldap lightning +minimal mozdom selinux"
41 RESTRICT="!bindist? ( bindist )"
43 PATCH_URIS=( https://dev.gentoo.org/~{anarchy,axs,polynomial-c}/mozilla/patchsets/{${PATCH},${PATCHFF}}.tar.xz )
45 ${MOZ_HTTP_URI}/${MOZ_PV}/source/${MOZ_P}.source.tar.xz
46 https://dev.gentoo.org/~axs/distfiles/lightning-${MOZ_LIGHTNING_VER}.tar.xz
47 lightning? ( https://dev.gentoo.org/~axs/distfiles/gdata-provider-${MOZ_LIGHTNING_GDATA_VER}-r1.tar.xz )
50 ASM_DEPEND=">=dev-lang/yasm-1.1"
55 crypt? ( >=x11-plugins/enigmail-1.9.6.1-r1 )
59 amd64? ( ${ASM_DEPEND}
65 selinux? ( sec-policy/selinux-thunderbird )
68 S="${WORKDIR}/${MOZ_P}"
70 BUILD_OBJ_DIR="${S}/tbird"
75 export MOZILLA_DIR="${S}/mozilla"
77 if ! use bindist ; then
78 elog "You are enabling official branding. You may not redistribute this build"
79 elog "to any users on your network or the internet. Doing so puts yourself into"
80 elog "a legal problem with Mozilla Foundation"
81 elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
87 # Ensure we have enough disk space to compile
88 CHECKREQS_DISK_BUILD="4G"
91 if use jit && [[ -n ${PROFILE_IS_HARDENED} ]]; then
92 ewarn "You are emerging this package on a hardened profile with USE=jit enabled."
93 ewarn "This is horribly insecure as it disables all PAGEEXEC restrictions."
94 ewarn "Please ensure you know what you are doing. If you don't, please consider"
95 ewarn "emerging the package with USE=-jit"
102 # Unpack language packs
103 mozlinguas_src_unpack
105 # this version of lightning is a .tar.xz, no xpi needed
106 #xpi_unpack lightning-${MOZ_LIGHTNING_VER}.xpi
108 # this version of gdata-provider is a .tar.xz , no xpi needed
109 #use lightning && xpi_unpack gdata-provider-${MOZ_LIGHTNING_GDATA_VER}.xpi
113 # Apply our Thunderbird patchset
114 rm -f "${WORKDIR}"/thunderbird/2001_ldap_respect_cflags.patch
115 eapply "${WORKDIR}/thunderbird"
117 # Apply our patchset from firefox to thunderbird as well
118 pushd "${S}"/mozilla &>/dev/null || die
119 eapply "${WORKDIR}/firefox"
120 popd &>/dev/null || die
122 # Ensure that are plugins dir is enabled as default
123 sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \
124 "${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!"
125 sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \
126 "${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!"
128 # Don't exit with error when some libs are missing which we have in
130 sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
131 -i "${S}"/mail/installer/Makefile.in || die
133 # Don't error out when there's no files to be removed:
134 sed 's@\(xargs rm\)$@\1 -f@' \
135 -i "${S}"/mozilla/toolkit/mozapps/installer/packager.mk || die
137 # Shell scripts sometimes contain DOS line endings; bug 391889
138 grep -rlZ --include="*.sh" $'\r$' . |
139 while read -r -d $'\0' file ; do
140 einfo edos2unix "${file}"
144 # Allow user to apply any additional patches without modifing ebuild
147 # Confirm the version of lightning being grabbed for langpacks is the same
148 # as that used in thunderbird
149 local THIS_MOZ_LIGHTNING_VER=$(python "${S}"/calendar/lightning/build/makeversion.py ${PV})
150 if [[ ${MOZ_LIGHTNING_VER} != ${THIS_MOZ_LIGHTNING_VER} ]]; then
151 eqawarn "The version of lightning used for localization differs from the version"
152 eqawarn "in thunderbird. Please update MOZ_LIGHTNING_VER in the ebuild from ${MOZ_LIGHTNING_VER}"
153 eqawarn "to ${THIS_MOZ_LIGHTNING_VER}"
157 # Ensure we run eautoreconf in mozilla to regenerate configure
158 cd "${S}"/mozilla || die
160 cd "${S}"/mozilla/js/src || die
165 MEXTENSIONS="default"
167 ####################################
169 # mozconfig, CFLAGS and CXXFLAGS setup
171 ####################################
176 # It doesn't compile on alpha without this LDFLAGS
177 use alpha && append-ldflags "-Wl,--no-relax"
179 # Add full relro support for hardened
180 use hardened && append-ldflags "-Wl,-z,relro,-z,now"
182 mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
183 mozconfig_annotate '' --disable-mailnews
184 mozconfig_annotate '' --enable-calendar
186 # Other tb-specific settings
187 mozconfig_annotate '' --with-user-appdir=.thunderbird
189 mozconfig_use_enable ldap
195 MEXTENSIONS="${MEXTENSIONS},inspector"
198 # Use an objdir to keep things organized.
199 echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig
201 # Finalize and report settings
204 ####################################
206 # Configure and build
208 ####################################
210 # Disable no-print-directory
211 MAKEOPTS=${MAKEOPTS/--no-print-directory/}
213 if [[ $(gcc-major-version) -lt 4 ]]; then
214 append-cxxflags -fno-stack-protector
219 mkdir -p "${BUILD_OBJ_DIR}" && cd "${BUILD_OBJ_DIR}" || die
221 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
222 MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX%/}/bin/bash}" \
223 emake -f "${S}"/client.mk
228 cd "${BUILD_OBJ_DIR}" || die
230 # Copy our preference before omnijar is created.
231 cp "${FILESDIR}"/thunderbird-gentoo-default-prefs-1.js-1 \
232 "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \
235 mozconfig_install_prefs \
236 "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js"
238 # dev-db/sqlite does not have FTS3_TOKENIZER support.
239 # gloda needs it to function, and bad crashes happen when its enabled and doesn't work
240 if in_iuse system-sqlite && use system-sqlite ; then
241 echo "lockPref(\"mailnews.database.global.indexer.enabled\", false);" \
242 >>"${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" || die
245 # Pax mark xpcshell for hardened support, only used for startupcache creation.
246 pax-mark m "${BUILD_OBJ_DIR}"/dist/bin/xpcshell
248 MOZ_MAKE_FLAGS="${MAKEOPTS}" \
249 emake DESTDIR="${D}" install
251 # Install language packs
252 mozlinguas_src_install
254 local size sizes icon_path icon
255 if ! use bindist; then
256 icon_path="${S}/other-licenses/branding/thunderbird"
259 domenu "${FILESDIR}"/icon/${PN}.desktop
261 icon_path="${S}/mail/branding/aurora"
262 icon="${PN}-icon-unbranded"
264 newmenu "${FILESDIR}"/icon/${PN}-unbranded.desktop \
267 sed -i -e "s:Mozilla\ Thunderbird:EarlyBird:g" \
268 "${ED}"/usr/share/applications/${PN}.desktop
271 # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
272 newicon "${icon_path}"/mailicon48.png "${icon}".png
273 # Install icons for menu entry
274 sizes="16 22 24 32 48 256"
275 for size in ${sizes}; do
276 newicon -s ${size} "${icon_path}/mailicon${size}.png" "${icon}.png"
280 # stage extra locales for lightning and install over existing
281 mozlinguas_xpistage_langpacks "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning \
282 "${WORKDIR}"/lightning-${MOZ_LIGHTNING_VER} lightning calendar
284 emid='{e2fda1a4-762b-4020-b5ad-a41df1933103}'
285 mkdir -p "${T}/${emid}" || die
286 cp -RLp -t "${T}/${emid}" "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning/* || die
287 insinto ${MOZILLA_FIVE_HOME}/distribution/extensions
288 doins -r "${T}/${emid}"
290 if use lightning; then
291 # move lightning out of distribution/extensions and into extensions for app-global install
292 mv "${ED}"/${MOZILLA_FIVE_HOME}/{distribution,}/extensions/${emid} || die
294 # stage extra locales for gdata-provider and install app-global
295 mozlinguas_xpistage_langpacks "${BUILD_OBJ_DIR}"/dist/xpi-stage/gdata-provider \
296 "${WORKDIR}"/gdata-provider-${MOZ_LIGHTNING_GDATA_VER}
297 emid='{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}'
298 mkdir -p "${T}/${emid}" || die
299 cp -RLp -t "${T}/${emid}" "${BUILD_OBJ_DIR}"/dist/xpi-stage/gdata-provider/* || die
300 insinto ${MOZILLA_FIVE_HOME}/extensions
301 doins -r "${T}/${emid}"
305 emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' "${EPREFIX}"/usr/share/enigmail/install.rdf)
306 if [[ -n ${emid} ]]; then
307 dosym "${EPREFIX}"/usr/share/enigmail ${MOZILLA_FIVE_HOME}/extensions/${emid}
309 eerror "${EPREFIX}/usr/share/enigmail/install.rdf: No such file or directory"
310 die "<EM:ID> tag for installed enigmail could not be found!"
314 # Required in order for jit to work on hardened, for mozilla-31 and above
315 use jit && pax-mark pm "${ED}"${MOZILLA_FIVE_HOME}/{thunderbird,thunderbird-bin}
317 # Plugin-container needs to be pax-marked for hardened to ensure plugins such as flash
318 # continue to work as expected.
319 pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/plugin-container
322 rm -r "${ED}"/usr/include "${ED}"${MOZILLA_FIVE_HOME}/{idl,include,lib,sdk} || \
323 die "Failed to remove sdk and headers"
330 # Because PM's dont seem to properly merge a symlink replacing a directory
332 local emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' "${EPREFIX}"/usr/share/enigmail/install.rdf)
333 if [[ -z ${emid} ]]; then
334 eerror "${EPREFIX}/usr/share/enigmail/install.rdf: No such file or directory"
335 die "Could not find enigmail on disk during pkg_preinst()"
337 if [[ ! -h "${EPREFIX}${MOZILLA_FIVE_HOME}/extensions/${emid}" ]] && \
338 [[ -d "${EPREFIX}${MOZILLA_FIVE_HOME}/extensions/${emid}" ]]; then
339 rm -Rf "${EPREFIX}${MOZILLA_FIVE_HOME}/extensions/${emid}" || (
340 eerror "Could not remove enigmail directory from previous installation,"
341 eerror "You must remove this by hand and rename the symbolic link yourself:"
343 eerror "\t cd ${EPREFIX}${MOZILLA_FIVE_HOME}/extensions"
344 eerror "\t rm -Rf ${emid}"
345 eerror "\t mv ${emid}.backup* ${emid}" )
351 xdg_desktop_database_update
352 gnome2_icon_cache_update
354 elog "If you experience problems with plugins please issue the"
355 elog "following command : rm \${HOME}/.thunderbird/*/extensions.sqlite ,"
356 elog "then restart thunderbird"
357 if ! use lightning; then
359 elog "If calendar fails to show up in extensions please open config editor"
360 elog "and set extensions.lastAppVersion to 38.0.0 to force a reload. If this"
361 elog "fails to show the calendar extension after restarting with above change"
362 elog "please file a bug report."
367 xdg_desktop_database_update
368 gnome2_icon_cache_update