Line 0
Link Here
|
|
|
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="4.0.2" |
9 |
MOZ_LIGHTNING_GDATA_VER="1.9" |
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.8.2" |
27 |
|
28 |
# Patches |
29 |
PATCH="thunderbird-38.0-patches-0.1" |
30 |
PATCHFF="firefox-38.0-patches-04" |
31 |
|
32 |
MOZ_HTTP_URI="http://ftp.mozilla.org/pub/${PN}/releases" |
33 |
|
34 |
MOZCONFIG_OPTIONAL_JIT="enabled" |
35 |
inherit flag-o-matic toolchain-funcs mozconfig-v6.38 makeedit multilib 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="amd64 ~arm ~ppc x86" |
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.bz2 |
49 |
${MOZ_HTTP_URI/${PN}/calendar/lightning}/${MOZ_LIGHTNING_VER}/linux/lightning.xpi -> lightning-${MOZ_LIGHTNING_VER}.xpi |
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.19.2 |
58 |
>=dev-libs/nspr-4.10.8 |
59 |
!x11-plugins/enigmail |
60 |
crypt? ( || ( |
61 |
( >=app-crypt/gnupg-2.1.8 |
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 |
if [[ ${PV} =~ beta ]]; then |
81 |
S="${WORKDIR}/comm-beta" |
82 |
else |
83 |
S="${WORKDIR}/comm-esr${PV%%.*}" |
84 |
fi |
85 |
|
86 |
BUILD_OBJ_DIR="${S}/tbird" |
87 |
|
88 |
pkg_setup() { |
89 |
moz_pkgsetup |
90 |
|
91 |
export MOZILLA_DIR="${S}/mozilla" |
92 |
|
93 |
if ! use bindist ; then |
94 |
elog "You are enabling official branding. You may not redistribute this build" |
95 |
elog "to any users on your network or the internet. Doing so puts yourself into" |
96 |
elog "a legal problem with Mozilla Foundation" |
97 |
elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag" |
98 |
elog |
99 |
fi |
100 |
} |
101 |
|
102 |
pkg_pretend() { |
103 |
# Ensure we have enough disk space to compile |
104 |
CHECKREQS_DISK_BUILD="4G" |
105 |
check-reqs_pkg_setup |
106 |
|
107 |
if use jit && [[ -n ${PROFILE_IS_HARDENED} ]]; then |
108 |
ewarn "You are emerging this package on a hardened profile with USE=jit enabled." |
109 |
ewarn "This is horribly insecure as it disables all PAGEEXEC restrictions." |
110 |
ewarn "Please ensure you know what you are doing. If you don't, please consider" |
111 |
ewarn "emerging the package with USE=-jit" |
112 |
fi |
113 |
} |
114 |
|
115 |
src_unpack() { |
116 |
unpack ${A} |
117 |
|
118 |
# Unpack language packs |
119 |
mozlinguas_src_unpack |
120 |
|
121 |
xpi_unpack lightning-${MOZ_LIGHTNING_VER}.xpi |
122 |
# this version of gdata-provider is a .tar.xz , no xpi needed |
123 |
#use lightning && xpi_unpack gdata-provider-${MOZ_LIGHTNING_GDATA_VER}.xpi |
124 |
} |
125 |
|
126 |
src_prepare() { |
127 |
# Apply our Thunderbird patchset |
128 |
EPATCH_SUFFIX="patch" \ |
129 |
EPATCH_FORCE="yes" \ |
130 |
epatch "${WORKDIR}/thunderbird" |
131 |
|
132 |
# Apply our patchset from firefox to thunderbird as well |
133 |
pushd "${S}"/mozilla &>/dev/null || die |
134 |
EPATCH_SUFFIX="patch" \ |
135 |
EPATCH_FORCE="yes" \ |
136 |
epatch "${WORKDIR}/firefox" |
137 |
popd &>/dev/null || die |
138 |
|
139 |
## patches for building with musl libc |
140 |
|
141 |
## backports from firefox |
142 |
|
143 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-crashreporter.patch # fixed? |
144 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-fts-header.patch # bug 1139173, fixed in 40.0.a1 |
145 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-u_int64_t.patch # bug 1130164, fixed in 39.0a1 |
146 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-profiler-gettid.patch # fixed? |
147 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-sandbox-cdefs.patch # bug 1157864, fixed in 42.0a1 |
148 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-updater.patch # bug 1157850, not fixed as of today |
149 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-basename.patch # bug 1041962, not fixed as of today |
150 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-sysctl-headers.patch # bug 1130175, fixed in 39.0a1 |
151 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-xpcom-blocksize.patch # bug 1152176, fixed in 41.0a1 |
152 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-cdefs-header.patch # bug 1151202, fixed in 40.0a1 |
153 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-xre.patch # bug 1130710, fixed in 40.0a1 |
154 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-netwerk.patch # from alpine |
155 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-bug-1130709.patch # bug 1130709, fixed in 40.0a1 |
156 |
epatch "${FILESDIR}"/musl/thunderbird-38.3.0-queue.patch # bug 1152185, fixed in 41.0a1 | works, but not sure if needed |
157 |
|
158 |
# epatch "${FILESDIR}"/musl/thunderbird-38.3.0-fix-bug-1130175.patch # cannot be applied due to major changes in mozilla/media/mtransport/third_party/nICEr/src/stun/addrs.c |
159 |
|
160 |
## end of musl patching |
161 |
|
162 |
# Ensure that are plugins dir is enabled as default |
163 |
sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \ |
164 |
"${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!" |
165 |
sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \ |
166 |
"${S}"/mozilla/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!" |
167 |
|
168 |
# Don't exit with error when some libs are missing which we have in |
169 |
# system. |
170 |
sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \ |
171 |
-i "${S}"/mail/installer/Makefile.in || die |
172 |
|
173 |
# Don't error out when there's no files to be removed: |
174 |
sed 's@\(xargs rm\)$@\1 -f@' \ |
175 |
-i "${S}"/mozilla/toolkit/mozapps/installer/packager.mk || die |
176 |
|
177 |
# Shell scripts sometimes contain DOS line endings; bug 391889 |
178 |
grep -rlZ --include="*.sh" $'\r$' . | |
179 |
while read -r -d $'\0' file ; do |
180 |
einfo edos2unix "${file}" |
181 |
edos2unix "${file}" |
182 |
done |
183 |
|
184 |
# Allow user to apply any additional patches without modifing ebuild |
185 |
epatch_user |
186 |
|
187 |
# Confirm the version of lightning being grabbed for langpacks is the same |
188 |
# as that used in thunderbird |
189 |
local THIS_MOZ_LIGHTNING_VER=$(python "${S}"/calendar/lightning/build/makeversion.py ${PV}) |
190 |
if [[ ${MOZ_LIGHTNING_VER} != ${THIS_MOZ_LIGHTNING_VER} ]]; then |
191 |
eqawarn "The version of lightning used for localization differs from the version" |
192 |
eqawarn "in thunderbird. Please update MOZ_LIGHTNING_VER in the ebuild from ${MOZ_LIGHTNING_VER}" |
193 |
eqawarn "to ${THIS_MOZ_LIGHTNING_VER}" |
194 |
fi |
195 |
|
196 |
eautoreconf |
197 |
# Ensure we run eautoreconf in mozilla to regenerate configure |
198 |
cd "${S}"/mozilla || die |
199 |
eautoconf |
200 |
cd "${S}"/mozilla/js/src || die |
201 |
eautoconf |
202 |
} |
203 |
|
204 |
src_configure() { |
205 |
declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" |
206 |
MEXTENSIONS="default" |
207 |
|
208 |
#################################### |
209 |
# |
210 |
# mozconfig, CFLAGS and CXXFLAGS setup |
211 |
# |
212 |
#################################### |
213 |
|
214 |
mozconfig_init |
215 |
mozconfig_config |
216 |
|
217 |
# It doesn't compile on alpha without this LDFLAGS |
218 |
use alpha && append-ldflags "-Wl,--no-relax" |
219 |
|
220 |
# Add full relro support for hardened |
221 |
use hardened && append-ldflags "-Wl,-z,relro,-z,now" |
222 |
|
223 |
mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}" |
224 |
mozconfig_annotate '' --disable-mailnews |
225 |
mozconfig_annotate '' --enable-calendar |
226 |
|
227 |
# Other tb-specific settings |
228 |
mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME} |
229 |
mozconfig_annotate '' --with-user-appdir=.thunderbird |
230 |
|
231 |
mozconfig_use_enable ldap |
232 |
|
233 |
mozlinguas_mozconfig |
234 |
|
235 |
# Bug #72667 |
236 |
if use mozdom; then |
237 |
MEXTENSIONS="${MEXTENSIONS},inspector" |
238 |
fi |
239 |
|
240 |
# Use an objdir to keep things organized. |
241 |
echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" >> "${S}"/.mozconfig |
242 |
|
243 |
# Finalize and report settings |
244 |
mozconfig_final |
245 |
|
246 |
#################################### |
247 |
# |
248 |
# Configure and build |
249 |
# |
250 |
#################################### |
251 |
|
252 |
# Disable no-print-directory |
253 |
MAKEOPTS=${MAKEOPTS/--no-print-directory/} |
254 |
|
255 |
if [[ $(gcc-major-version) -lt 4 ]]; then |
256 |
append-cxxflags -fno-stack-protector |
257 |
fi |
258 |
|
259 |
if use crypt; then |
260 |
pushd "${WORKDIR}"/enigmail &>/dev/null ||die |
261 |
econf |
262 |
popd &>/dev/null ||die |
263 |
fi |
264 |
} |
265 |
|
266 |
src_compile() { |
267 |
mkdir -p "${BUILD_OBJ_DIR}" && cd "${BUILD_OBJ_DIR}" || die |
268 |
|
269 |
CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \ |
270 |
MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL:-${EPREFIX%/}/bin/bash}" \ |
271 |
emake -f "${S}"/client.mk |
272 |
|
273 |
# Only build enigmail extension if crypt enabled. |
274 |
if use crypt ; then |
275 |
einfo "Building enigmail" |
276 |
pushd "${WORKDIR}"/enigmail &>/dev/null || die |
277 |
emake -j1 |
278 |
emake -j1 xpi |
279 |
popd &>/dev/null || die |
280 |
fi |
281 |
} |
282 |
|
283 |
src_install() { |
284 |
declare MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}" |
285 |
DICTPATH="\"${EPREFIX}/usr/share/myspell\"" |
286 |
|
287 |
declare emid |
288 |
cd "${BUILD_OBJ_DIR}" || die |
289 |
|
290 |
# Copy our preference before omnijar is created. |
291 |
cp "${FILESDIR}"/thunderbird-gentoo-default-prefs-1.js-1 \ |
292 |
"${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \ |
293 |
|| die |
294 |
|
295 |
# Set default path to search for dictionaries. |
296 |
echo "pref(\"spellchecker.dictionary_path\", ${DICTPATH});" \ |
297 |
>> "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \ |
298 |
|| die |
299 |
|
300 |
# Pax mark xpcshell for hardened support, only used for startupcache creation. |
301 |
pax-mark m "${BUILD_OBJ_DIR}"/mozilla/dist/bin/xpcshell |
302 |
|
303 |
MOZ_MAKE_FLAGS="${MAKEOPTS}" \ |
304 |
emake DESTDIR="${D}" install |
305 |
|
306 |
# Install language packs |
307 |
mozlinguas_src_install |
308 |
|
309 |
if ! use bindist; then |
310 |
newicon "${S}"/other-licenses/branding/thunderbird/content/icon48.png thunderbird-icon.png |
311 |
domenu "${FILESDIR}"/icon/${PN}.desktop |
312 |
else |
313 |
newicon "${S}"/mail/branding/aurora/content/icon48.png thunderbird-icon-unbranded.png |
314 |
newmenu "${FILESDIR}"/icon/${PN}-unbranded.desktop \ |
315 |
${PN}.desktop |
316 |
|
317 |
sed -i -e "s:Mozilla\ Thunderbird:EarlyBird:g" \ |
318 |
"${ED}"/usr/share/applications/${PN}.desktop |
319 |
fi |
320 |
|
321 |
local emid |
322 |
# stage extra locales for lightning and install over existing |
323 |
mozlinguas_xpistage_langpacks "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning \ |
324 |
"${WORKDIR}"/lightning-${MOZ_LIGHTNING_VER} lightning calendar |
325 |
|
326 |
emid='{e2fda1a4-762b-4020-b5ad-a41df1933103}' |
327 |
mkdir -p "${T}/${emid}" || die |
328 |
cp -RLp -t "${T}/${emid}" "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning/* || die |
329 |
insinto ${MOZILLA_FIVE_HOME}/distribution/extensions |
330 |
doins -r "${T}/${emid}" |
331 |
|
332 |
if use lightning; then |
333 |
# move lightning out of distribution/extensions and into extensions for app-global install |
334 |
mv "${ED}"/${MOZILLA_FIVE_HOME}/{distribution,}/extensions/${emid} || die |
335 |
|
336 |
# stage extra locales for gdata-provider and install app-global |
337 |
mozlinguas_xpistage_langpacks "${BUILD_OBJ_DIR}"/dist/xpi-stage/gdata-provider \ |
338 |
"${WORKDIR}"/gdata-provider-${MOZ_LIGHTNING_GDATA_VER} |
339 |
emid='{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}' |
340 |
mkdir -p "${T}/${emid}" || die |
341 |
cp -RLp -t "${T}/${emid}" "${BUILD_OBJ_DIR}"/dist/xpi-stage/gdata-provider/* || die |
342 |
insinto ${MOZILLA_FIVE_HOME}/extensions |
343 |
doins -r "${T}/${emid}" |
344 |
fi |
345 |
|
346 |
if use crypt ; then |
347 |
local enigmail_xpipath="${WORKDIR}/enigmail/build" |
348 |
cd "${T}" || die |
349 |
unzip "${enigmail_xpipath}"/enigmail*.xpi install.rdf || die |
350 |
emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' install.rdf) |
351 |
|
352 |
dodir ${MOZILLA_FIVE_HOME}/extensions/${emid} || die |
353 |
cd "${ED}"${MOZILLA_FIVE_HOME}/extensions/${emid} || die |
354 |
unzip "${enigmail_xpipath}"/enigmail*.xpi || die |
355 |
fi |
356 |
|
357 |
# Required in order for jit to work on hardened, for mozilla-31 and above |
358 |
use jit && pax-mark pm "${ED}"${MOZILLA_FIVE_HOME}/{thunderbird,thunderbird-bin} |
359 |
|
360 |
# Plugin-container needs to be pax-marked for hardened to ensure plugins such as flash |
361 |
# continue to work as expected. |
362 |
pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/plugin-container |
363 |
|
364 |
if use minimal; then |
365 |
rm -r "${ED}"/usr/include "${ED}"${MOZILLA_FIVE_HOME}/{idl,include,lib,sdk} || \ |
366 |
die "Failed to remove sdk and headers" |
367 |
fi |
368 |
|
369 |
# workaround to make thunderbird find libmozalloc.so on musl |
370 |
into / |
371 |
echo "LDPATH=${MOZILLA_FIVE_HOME}" > "${T}"/20thunderbird |
372 |
doenvd "${T}"/20thunderbird || die |
373 |
|
374 |
} |
375 |
|
376 |
pkg_postinst() { |
377 |
if use crypt; then |
378 |
local peimpl=$(eselect --brief --colour=no pinentry show) |
379 |
case "${peimpl}" in |
380 |
*gtk*|*qt*) ;; |
381 |
*) ewarn "The pinentry front-end currently selected is not one supported by thunderbird." |
382 |
ewarn "You may be prompted for your password in an inaccessible shell!!" |
383 |
ewarn "Please use 'eselect pinentry' to select either the gtk or qt front-end" |
384 |
;; |
385 |
esac |
386 |
fi |
387 |
elog |
388 |
elog "If you experience problems with plugins please issue the" |
389 |
elog "following command : rm \${HOME}/.thunderbird/*/extensions.sqlite ," |
390 |
elog "then restart thunderbird" |
391 |
if ! use lightning; then |
392 |
elog |
393 |
elog "If calendar fails to show up in extensions please open config editor" |
394 |
elog "and set extensions.lastAppVersion to 38.0.0 to force a reload. If this" |
395 |
elog "fails to show the calendar extension after restarting with above change" |
396 |
elog "please file a bug report." |
397 |
fi |
398 |
} |