Use https by default
[gentoo.git] / www-client / seamonkey / seamonkey-2.33.1-r1.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
8 # This list can be updated with scripts/get_langs.sh from the mozilla overlay
9 MOZ_LANGS=(be ca cs de en en-GB en-US es-AR es-ES fi fr gl hu it ja lt nb-NO nl
10             pl pt-PT ru sk sv-SE tr uk zh-CN zh-TW)
11
12 MOZ_PV="${PV/_pre*}"
13 MOZ_PV="${MOZ_PV/_alpha/a}"
14 MOZ_PV="${MOZ_PV/_beta/b}"
15 MOZ_PV="${MOZ_PV/_rc/rc}"
16 MOZ_P="${P}"
17 MY_MOZ_P="${PN}-${MOZ_PV}"
18
19 if [[ ${PV} == *_pre* ]] ; then
20         MOZ_HTTP_URI="http://archive.mozilla.org/pub/${PN}/candidates/${MOZ_PV}-candidates/build${PV##*_pre}"
21         MOZ_LANGPACK_PREFIX="linux-i686/xpi/"
22         # And the langpack stuff stays at eclass defaults
23 else
24         MOZ_HTTP_URI="http://archive.mozilla.org/pub/${PN}/releases/${MOZ_PV}"
25         MOZ_LANGPACK_PREFIX="langpack/${MY_MOZ_P}."
26         MOZ_LANGPACK_SUFFIX=".langpack.xpi"
27 fi
28
29 MOZCONFIG_OPTIONAL_WIFI=1
30 #MOZCONFIG_OPTIONAL_JIT="enabled"
31 inherit check-reqs flag-o-matic toolchain-funcs eutils mozconfig-v5.36 multilib pax-utils fdo-mime autotools mozextension nsplugins mozlinguas
32
33 PATCHFF="firefox-36.0-patches-01"
34 PATCH="${PN}-2.33-patches-01"
35 EMVER="1.8.2"
36
37 DESCRIPTION="Seamonkey Web Browser"
38 HOMEPAGE="http://www.seamonkey-project.org"
39
40 if [[ ${PV} == *_pre* ]] ; then
41         # pre-releases. No need for arch teams to change KEYWORDS here.
42
43         KEYWORDS=""
44 else
45         # This is where arch teams should change the KEYWORDS.
46
47         KEYWORDS="~alpha amd64 ~arm ~ppc ~ppc64 x86"
48 fi
49
50 SLOT="0"
51 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
52 IUSE="+chatzilla +crypt +gmp-autoupdate +ipc minimal pulseaudio +roaming selinux test"
53
54 SRC_URI="${SRC_URI}
55         ${MOZ_HTTP_URI}/source/${MY_MOZ_P}.source.tar.bz2 -> ${P}.source.tar.bz2
56         https://dev.gentoo.org/~axs/mozilla/patchsets/${PATCHFF}.tar.xz
57         https://dev.gentoo.org/~polynomial-c/mozilla/patchsets/${PATCH}.tar.xz
58         https://dev.gentoo.org/~polynomial-c/mozilla/patchsets/${PATCHFF}.tar.xz
59         crypt? ( http://www.enigmail.net/download/source/enigmail-${EMVER}.tar.gz )"
60
61 ASM_DEPEND=">=dev-lang/yasm-1.1"
62
63 RDEPEND=">=dev-libs/nss-3.17.4
64         >=dev-libs/nspr-4.10.8
65         crypt? ( || (
66                         ( >=app-crypt/gnupg-2.0
67                                 || (
68                                         app-crypt/pinentry[gtk]
69                                         app-crypt/pinentry[qt4]
70                                 )
71                         )
72                         =app-crypt/gnupg-1.4* ) )
73         system-sqlite? ( >=dev-db/sqlite-3.8.7.4:3[secure-delete,debug=] )"
74
75 DEPEND="${RDEPEND}
76         !elibc_glibc? ( !elibc_uclibc?  ( dev-libs/libexecinfo ) )
77         crypt? ( dev-lang/perl )
78         amd64? ( ${ASM_DEPEND}
79                 virtual/opengl )
80         x86? ( ${ASM_DEPEND}
81                 virtual/opengl )"
82
83 if [[ ${PV} == *beta* ]] ; then
84         S="${WORKDIR}/comm-beta"
85 else
86         S="${WORKDIR}/comm-release"
87 fi
88
89 BUILD_OBJ_DIR="${S}/seamonk"
90
91 pkg_setup() {
92         if [[ ${PV} == *_pre* ]] ; then
93                 ewarn "You're using an unofficial release of ${PN}. Don't file any bug in"
94                 ewarn "Gentoo's Bugtracker against this package in case it breaks for you."
95                 ewarn "Those belong to upstream: https://bugzilla.mozilla.org"
96         fi
97
98         moz_pkgsetup
99 }
100
101 pkg_pretend() {
102         # Ensure we have enough disk space to compile
103         if use debug || use test ; then
104                 CHECKREQS_DISK_BUILD="8G"
105         else
106                 CHECKREQS_DISK_BUILD="4G"
107         fi
108         check-reqs_pkg_setup
109 }
110
111 src_unpack() {
112         unpack ${A}
113
114         # Unpack language packs
115         mozlinguas_src_unpack
116 }
117
118 src_prepare() {
119         # Apply our patches
120         EPATCH_SUFFIX="patch" \
121         EPATCH_FORCE="yes" \
122         epatch "${WORKDIR}/seamonkey"
123
124         epatch "${FILESDIR}"/${PN}-2.30-jemalloc-configure.patch
125
126         # browser patches go here
127         pushd "${S}"/mozilla &>/dev/null || die
128         EPATCH_EXCLUDE="2000-firefox_gentoo_install_dirs.patch
129                         8002_jemalloc_configure_unbashify.patch" \
130         EPATCH_SUFFIX="patch" \
131         EPATCH_FORCE="yes" \
132         epatch "${WORKDIR}/firefox"
133         popd &>/dev/null || die
134         # drop -Wl,--build-id from LDFLAGS, bug #465466
135
136         # Shell scripts sometimes contain DOS line endings; bug 391889
137         grep -rlZ --include="*.sh" $'\r$' . |
138         while read -r -d $'\0' file ; do
139                 einfo edos2unix "${file}"
140                 edos2unix "${file}"
141         done
142
143         # Allow user to apply any additional patches without modifing ebuild
144         epatch_user
145
146         local ms="${S}/mozilla"
147
148         # Enable gnomebreakpad
149         if use debug ; then
150                 sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
151                         "${ms}"/build/unix/run-mozilla.sh || die "sed failed!"
152         fi
153
154         # Ensure that are plugins dir is enabled as default
155         sed -i -e "s:/usr/lib/mozilla/plugins:/usr/lib/nsbrowser/plugins:" \
156                 "${ms}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 32bit!"
157         sed -i -e "s:/usr/lib64/mozilla/plugins:/usr/lib64/nsbrowser/plugins:" \
158                 "${ms}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path for 64bit!"
159
160         # Don't exit with error when some libs are missing which we have in
161         # system.
162         sed '/^MOZ_PKG_FATAL_WARNINGS/s@= 1@= 0@' \
163                 -i "${S}"/suite/installer/Makefile.in || die
164         # Don't error out when there's no files to be removed:
165         sed 's@\(xargs rm\)$@\1 -f@' \
166                 -i "${ms}"/toolkit/mozapps/installer/packager.mk || die
167
168         if has_version '>=media-libs/freetype-2.6' ; then
169                 sed '/ftcache\.h/aftfntfmt.h' \
170                         -i "${S}/mozilla/config/system-headers" || die
171         fi
172
173         eautoreconf
174         cd "${S}"/mozilla || die
175         eautoconf
176         cd "${S}"/mozilla/js/src || die
177         eautoconf
178         cd "${S}"/mozilla/memory/jemalloc/src || die
179         WANT_AUTOCONF= eautoconf
180 }
181
182 src_configure() {
183         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
184         MEXTENSIONS="default"
185         # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
186         # Note: These are for Gentoo Linux use ONLY. For your own distribution, please
187         # get your own set of keys.
188         _google_api_key=AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc
189
190         ####################################
191         #
192         # mozconfig, CFLAGS and CXXFLAGS setup
193         #
194         ####################################
195
196         mozconfig_init
197         mozconfig_config
198
199         # It doesn't compile on alpha without this LDFLAGS
200         use alpha && append-ldflags "-Wl,--no-relax"
201
202         if use chatzilla ; then
203                 MEXTENSIONS+=",irc"
204         else
205                 MEXTENSIONS+=",-irc"
206         fi
207         if ! use roaming ; then
208                 MEXTENSIONS+=",-sroaming"
209         fi
210
211         # Setup api key for location services
212         echo -n "${_google_api_key}" > "${S}"/google-api-key
213         mozconfig_annotate '' --with-google-api-keyfile="${S}/google-api-key"
214
215         mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
216         mozconfig_annotate '' --enable-jsd
217         mozconfig_annotate '' --enable-canvas
218
219         # Other sm-specific settings
220         mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
221
222         mozconfig_annotate '' --enable-safe-browsing
223
224         # jit needs to be enabled unconditionally (bug #544436)
225         mozconfig_annotate '' --enable-ion
226         mozconfig_annotate '' --enable-yarr-jit
227
228         # Use an objdir to keep things organized.
229         echo "mk_add_options MOZ_OBJDIR=${BUILD_OBJ_DIR}" \
230                 >> "${S}"/.mozconfig
231
232         # Finalize and report settings
233         mozconfig_final
234
235         if use crypt ; then
236                 pushd "${WORKDIR}"/enigmail &>/dev/null || die
237                 econf
238                 popd &>/dev/null || die
239         fi
240
241         # Work around breakage in makeopts with --no-print-directory
242         MAKEOPTS="${MAKEOPTS/--no-print-directory/}"
243
244         if [[ $(gcc-major-version) -lt 4 ]] ; then
245                 append-cxxflags -fno-stack-protector
246         elif [[ $(gcc-major-version) -gt 4 || $(gcc-minor-version) -gt 3 ]] ; then
247                 if use amd64 || use x86 ; then
248                         append-flags -mno-avx
249                 fi
250         fi
251
252         emake V=1 -f client.mk configure
253 }
254
255 src_compile() {
256         CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
257         MOZ_MAKE_FLAGS="${MAKEOPTS}" SHELL="${SHELL}" \
258         emake V=1 -f client.mk
259
260         # Only build enigmail extension if conditions are met.
261         if use crypt ; then
262                 einfo "Building enigmail"
263                 pushd "${WORKDIR}"/enigmail &>/dev/null || die
264                 emake -j1
265                 emake xpi
266                 popd &>/dev/null || die
267         fi
268 }
269
270 src_install() {
271         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
272         DICTPATH="\"${EPREFIX}/usr/share/myspell\""
273
274         local emid
275         cd "${BUILD_OBJ_DIR}" || die
276
277         # Pax mark xpcshell for hardened support, only used for startupcache creation.
278         pax-mark m "${BUILD_OBJ_DIR}/dist/bin/xpcshell"
279
280         # Copy our preference before omnijar is created.
281         sed "s|SEAMONKEY_PVR|${PVR}|" "${FILESDIR}"/all-gentoo-1.js > \
282                 "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \
283                 || die
284
285         # Set default path to search for dictionaries.
286         echo "pref(\"spellchecker.dictionary_path\", ${DICTPATH});" \
287                 >> "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \
288                 || die
289
290         echo 'pref("extensions.autoDisableScopes", 3);' >> \
291                 "${BUILD_OBJ_DIR}/dist/bin/defaults/pref/all-gentoo.js" \
292                 || die
293
294         local plugin
295         if ! use gmp-autoupdate ; then
296                 for plugin in gmp-gmpopenh264 ; do
297                         echo "pref(\"media.${plugin}.autoupdate\", false);" >> \
298                                 "${S}/${BUILD_OBJ_DIR}/dist/bin/browser/defaults/preferences/all-gentoo.js" \
299                                 || dir
300                 done
301         fi
302
303         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
304         emake DESTDIR="${D}" install
305         cp "${FILESDIR}"/${PN}.desktop "${T}" || die
306
307         if use crypt ; then
308                 local em_dir="${WORKDIR}/enigmail/build"
309                 pushd "${T}" &>/dev/null || die
310                 unzip "${em_dir}"/enigmail*.xpi install.rdf || die
311                 emid=$(sed -n '/<em:id>/!d; s/.*\({.*}\).*/\1/; p; q' install.rdf)
312                 #'
313                 dodir ${MOZILLA_FIVE_HOME}/extensions/${emid}
314                 cd "${D}"${MOZILLA_FIVE_HOME}/extensions/${emid} || die
315                 unzip "${em_dir}"/enigmail*.xpi || die
316
317                 popd &>/dev/null || die
318         fi
319
320         sed 's|^\(MimeType=.*\)$|\1text/x-vcard;text/directory;application/mbox;message/rfc822;x-scheme-handler/mailto;|' \
321                 -i "${T}"/${PN}.desktop || die
322         sed 's|^\(Categories=.*\)$|\1Email;|' -i "${T}"/${PN}.desktop \
323                 || die
324
325         # Install language packs
326         mozlinguas_src_install
327
328         # Add StartupNotify=true bug 290401
329         if use startup-notification ; then
330                 echo "StartupNotify=true" >> "${T}"/${PN}.desktop || die
331         fi
332
333         # Install icon and .desktop for menu entry
334         newicon "${S}"/suite/branding/nightly/content/icon64.png ${PN}.png
335         domenu "${T}"/${PN}.desktop
336
337         # Required in order to use plugins and even run seamonkey on hardened.
338         pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/{seamonkey,seamonkey-bin,plugin-container}
339
340         if use minimal ; then
341                 rm -rf "${ED}"/usr/include "${ED}${MOZILLA_FIVE_HOME}"/{idl,include,lib,sdk}
342         fi
343
344         # Handle plugins dir through nsplugins.eclass
345         share_plugins_dir
346
347         #doman "${BUILD_OBJ_DIR}/suite/app/${PN}.1"
348
349         # revdep-rebuild entry
350         insinto /etc/revdep-rebuild
351         echo "SEARCH_DIRS_MASK=${MOZILLA_FIVE_HOME}*" >> ${T}/11${PN}
352         doins "${T}"/11${PN}
353 }
354
355 pkg_preinst() {
356         MOZILLA_FIVE_HOME="${ROOT}/usr/$(get_libdir)/${PN}"
357
358         if [ -d ${MOZILLA_FIVE_HOME}/plugins ] ; then
359                 rm ${MOZILLA_FIVE_HOME}/plugins -rf
360         fi
361 }
362
363 pkg_postinst() {
364         MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
365
366         # Update mimedb for the new .desktop file
367         fdo-mime_desktop_database_update
368
369         if use chatzilla ; then
370                 elog "chatzilla is now an extension which can be en-/disabled and configured via"
371                 elog "the Add-on manager."
372         fi
373 }