Gentoo Archives: gentoo-commits

From: Ian Stakenvicius <axs@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-client/firefox/, eclass/
Date: Wed, 06 Jul 2016 21:28:22
Message-Id: 1467840294.b5417f70dc4ad66b907c42a914a3b42211624f79.axs@gentoo
1 commit: b5417f70dc4ad66b907c42a914a3b42211624f79
2 Author: Ian Stakenvicius <axs <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 6 14:30:40 2016 +0000
4 Commit: Ian Stakenvicius <axs <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 6 21:24:54 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b5417f70
7
8 www-client/firefox: migrate LINGUAS to L10N
9
10 Bug: http://bugs.gentoo.org/587334
11
12 Package-Manager: portage-2.2.28
13
14 eclass/mozlinguas-v2.eclass | 370 +++++++++++++++++++++++++++++++++
15 www-client/firefox/firefox-47.0.ebuild | 2 +-
16 2 files changed, 371 insertions(+), 1 deletion(-)
17
18 diff --git a/eclass/mozlinguas-v2.eclass b/eclass/mozlinguas-v2.eclass
19 new file mode 100644
20 index 0000000..4facb58
21 --- /dev/null
22 +++ b/eclass/mozlinguas-v2.eclass
23 @@ -0,0 +1,370 @@
24 +# Copyright 1999-2015 Gentoo Foundation
25 +# Distributed under the terms of the GNU General Public License v2
26 +# $Id$
27 +
28 +# @ECLASS: mozlinguas-v2.eclass
29 +# @MAINTAINER:
30 +# mozilla@g.o
31 +# @AUTHOR:
32 +# Nirbheek Chauhan <nirbheek@g.o>
33 +# Ian Stakenvicius <axs@g.o>
34 +# @BLURB: Handle language packs for mozilla products
35 +# @DESCRIPTION:
36 +# Sets IUSE according to MOZ_LANGS (language packs available). Also exports
37 +# src_unpack, src_compile and src_install for use in ebuilds, and provides
38 +# supporting functions for langpack generation and installation.
39 +
40 +inherit mozextension
41 +
42 +case "${EAPI:-0}" in
43 + 0|1)
44 + die "EAPI ${EAPI:-0} does not support the '->' SRC_URI operator";;
45 + 2|3|4|5|6)
46 + EXPORT_FUNCTIONS src_unpack src_compile src_install;;
47 + *)
48 + die "EAPI ${EAPI} is not supported, contact eclass maintainers";;
49 +esac
50 +
51 +# @ECLASS-VARIABLE: MOZ_LANGS
52 +# @DESCRIPTION:
53 +# Array containing the list of language pack xpis available for
54 +# this release. The list can be updated with scripts/get_langs.sh from the
55 +# mozilla overlay.
56 +: ${MOZ_LANGS:=()}
57 +
58 +# @ECLASS-VARIABLE: MOZ_PV
59 +# @DESCRIPTION:
60 +# Ebuild package version converted to equivalent upstream version.
61 +# Defaults to ${PV}, and should be overridden for alphas, betas, and RCs
62 +: ${MOZ_PV:="${PV}"}
63 +
64 +# @ECLASS-VARIABLE: MOZ_PN
65 +# @DESCRIPTION:
66 +# Ebuild package name converted to equivalent upstream name.
67 +# Defaults to ${PN}, and should be overridden for binary ebuilds.
68 +: ${MOZ_PN:="${PN}"}
69 +
70 +# @ECLASS-VARIABLE: MOZ_P
71 +# @DESCRIPTION:
72 +# Ebuild package name + version converted to upstream equivalent.
73 +# Defaults to ${MOZ_PN}-${MOZ_PV}
74 +: ${MOZ_P:="${MOZ_PN}-${MOZ_PV}"}
75 +
76 +# @ECLASS-VARIABLE: MOZ_FTP_URI
77 +# @DESCRIPTION:
78 +# The ftp URI prefix for the release tarballs and language packs.
79 +: ${MOZ_FTP_URI:=""}
80 +
81 +# @ECLASS-VARIABLE: MOZ_HTTP_URI
82 +# @DESCRIPTION:
83 +# The http URI prefix for the release tarballs and language packs.
84 +: ${MOZ_HTTP_URI:=""}
85 +
86 +# @ECLASS-VARIABLE: MOZ_LANGPACK_PREFIX
87 +# @DESCRIPTION:
88 +# The relative path till the lang code in the langpack file URI.
89 +# Defaults to ${MOZ_PV}/linux-i686/xpi/
90 +: ${MOZ_LANGPACK_PREFIX:="${MOZ_PV}/linux-i686/xpi/"}
91 +
92 +# @ECLASS-VARIABLE: MOZ_LANGPACK_SUFFIX
93 +# @DESCRIPTION:
94 +# The suffix after the lang code in the langpack file URI.
95 +# Defaults to '.xpi'
96 +: ${MOZ_LANGPACK_SUFFIX:=".xpi"}
97 +
98 +# @ECLASS-VARIABLE: MOZ_LANGPACK_UNOFFICIAL
99 +# @DESCRIPTION:
100 +# The status of the langpack, used to differentiate within
101 +# Manifests and on Gentoo mirrors as to when the langpacks are
102 +# generated officially by Mozilla or if they were generated
103 +# unofficially by others (ie the Gentoo mozilla team). When
104 +# this var is set, the distfile will have a .unofficial.xpi
105 +# suffix.
106 +: ${MOZ_LANGPACK_UNOFFICIAL:=""}
107 +
108 +# @ECLASS-VARIABLE: MOZ_GENERATE_LANGPACKS
109 +# @DESCRIPTION:
110 +# This flag specifies whether or not the langpacks should be
111 +# generated directly during the build process, rather than
112 +# being downloaded and installed from upstream pre-built
113 +# extensions. Primarily it supports pre-release builds.
114 +# Defaults to empty.
115 +: ${MOZ_GENERATE_LANGPACKS:=""}
116 +
117 +# @ECLASS-VARIABLE: MOZ_L10N_SOURCEDIR
118 +# @DESCRIPTION:
119 +# The path that l10n sources can be found at, once unpacked.
120 +# Defaults to ${WORKDIR}/l10n-sources
121 +: ${MOZ_L10N_SOURCEDIR:="${WORKDIR}/l10n-sources"}
122 +
123 +# @ECLASS-VARIABLE: MOZ_L10N_URI_PREFIX
124 +# @DESCRIPTION:
125 +# The full URI prefix of the distfile for each l10n locale. The
126 +# AB_CD and MOZ_L10N_URI_SUFFIX will be appended to this to complete the
127 +# SRC_URI when MOZ_GENERATE_LANGPACKS is set. If empty, nothing will
128 +# be added to SRC_URI.
129 +# Defaults to empty.
130 +: ${MOZ_L10N_URI_PREFIX:=""}
131 +
132 +# @ECLASS-VARIABLE: MOZ_L10N_URI_SUFFIX
133 +# @DESCRIPTION:
134 +# The suffix of l10n source distfiles.
135 +# Defaults to '.tar.xz'
136 +: ${MOZ_L10N_URI_SUFFIX:=".tar.xz"}
137 +
138 +# @ECLASS-VARIABLE: MOZ_FORCE_UPSTREAM_L10N
139 +# @DESCRIPTION:
140 +# Set this to use upstream langpaks even if the package normally
141 +# shouldn't (ie it is an alpha or beta package)
142 +: ${MOZ_FORCE_UPSTREAM_L10N:=""}
143 +
144 +
145 +# @ECLASS-VARIABLE: MOZ_TOO_REGIONALIZED_FOR_L10N
146 +# @INTERNAL
147 +# @DESCRIPTION:
148 +# Upstream identifiers that should not contain region subtags in L10N
149 +MOZ_TOO_REGIONALIZED_FOR_L10N=( fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO nn-NO pa-IN sv-SE )
150 +
151 +# Add l10n_* to IUSE according to available language packs
152 +# No language packs for alphas and betas
153 +if ! [[ -n ${MOZ_GENERATE_LANGPACKS} ]] ; then
154 + if ! [[ ${PV} =~ alpha|beta ]] || { [[ ${PN} == seamonkey ]] && ! [[ ${PV} =~ alpha ]] ; } || [[ -n ${MOZ_FORCE_UPSTREAM_L10N} ]] ; then
155 + [[ -z ${MOZ_FTP_URI} ]] && [[ -z ${MOZ_HTTP_URI} ]] && die "No URI set to download langpacks, please set one of MOZ_{FTP,HTTP}_URI"
156 + for x in "${MOZ_LANGS[@]}" ; do
157 + # en and en_US are handled internally
158 + if [[ ${x} == en ]] || [[ ${x} == en-US ]]; then
159 + continue
160 + fi
161 + # strip region subtag if $x is in the list
162 + if has ${x} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then
163 + xflag=${x%%-*}
164 + else
165 + xflag=${x}
166 + fi
167 + SRC_URI+=" l10n_${xflag/[_@]/-}? ("
168 + [[ -n ${MOZ_FTP_URI} ]] && SRC_URI+="
169 + ${MOZ_FTP_URI}/${MOZ_LANGPACK_PREFIX}${x}${MOZ_LANGPACK_SUFFIX} -> ${MOZ_P}-${x}${MOZ_LANGPACK_UNOFFICIAL:+.unofficial}.xpi"
170 + [[ -n ${MOZ_HTTP_URI} ]] && SRC_URI+="
171 + ${MOZ_HTTP_URI}/${MOZ_LANGPACK_PREFIX}${x}${MOZ_LANGPACK_SUFFIX} -> ${MOZ_P}-${x}${MOZ_LANGPACK_UNOFFICIAL:+.unofficial}.xpi"
172 + SRC_URI+=" )"
173 + IUSE+=" l10n_${xflag/[_@]/-}"
174 + # We used to do some magic if specific/generic locales were missing, but
175 + # we stopped doing that due to bug 325195.
176 + done
177 + fi
178 +else
179 + for x in "${MOZ_LANGS[@]}" ; do
180 + # en and en_US are handled internally
181 + if [[ ${x} == en ]] || [[ ${x} == en-US ]]; then
182 + continue
183 + fi
184 + # strip region subtag if $x is in the list
185 + if has ${x} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then
186 + xflag=${x%%-*}
187 + else
188 + xflag=${x}
189 + fi
190 +# Do NOT grab l10n sources from hg tip at this time, since it is a moving target
191 +# if [[ ${PV} =~ alpha ]]; then
192 +# # Please note that this URI is not deterministic - digest breakage could occur
193 +# SRC_URI+=" l10n_${xflag/[_@]/-}? ( http://hg.mozilla.org/releases/l10n/mozilla-aurora/ach/archive/tip.tar.bz2 -> ${MOZ_P}-l10n-${x}.tar.bz2 )"
194 +# elif [[ ${PV} =~ beta ]] && ! [[ ${PN} == seamonkey ]]; then
195 +# # Please note that this URI is not deterministic - digest breakage could occur
196 +# SRC_URI+=" l10n_${xflag/[_@]/-}? ( http://hg.mozilla.org/releases/l10n/mozilla-beta/ach/archive/tip.tar.bz2 -> ${MOZ_P}-l10n-${x}.tar.bz2 )"
197 +# elif [[ -n ${MOZ_L10N_URI_PREFIX} ]]; then
198 + if [[ -n ${MOZ_L10N_URI_PREFIX} ]]; then
199 + SRC_URI+=" l10n_${xflag/[_@]/-}? ( ${MOZ_L10N_URI_PREFIX}${x}${MOZ_L10N_URI_SUFFIX} )"
200 + fi
201 + IUSE+=" l10n_${x/[_@]/-}"
202 + done
203 +fi
204 +unset x xflag
205 +
206 +# @FUNCTION: mozlinguas_export
207 +# @INTERNAL
208 +# @DESCRIPTION:
209 +# Generate the list of language packs called "mozlinguas"
210 +# This list is used to unpack and install the xpi language packs
211 +mozlinguas_export() {
212 + if [[ ${PN} == seamonkey ]] ; then
213 + [[ ${PV} =~ alpha ]] && ! [[ -n ${MOZ_GENERATE_LANGPACKS} ]] && return
214 + else
215 + [[ ${PV} =~ alpha|beta ]] && ! [[ -n ${MOZ_GENERATE_LANGPACKS} ]] && return
216 + fi
217 + local lingua lflag
218 + mozlinguas=()
219 + # Set mozlinguas based on the enabled l10n_* USE flags.
220 + for lingua in "${MOZ_LANGS[@]}"; do
221 + # strip region subtag if $x is in the list
222 + if has ${lingua} en en-US; then
223 + # For mozilla products, en and en_US are handled internally
224 + continue
225 + elif has ${lingua} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then
226 + lflag=${lingua%%-*}
227 + else
228 + lflag=${lingua}
229 + fi
230 + use l10n_${lflag/[_@]/-} && mozlinguas+=( ${lingua} )
231 + done
232 + # Compatibility code - Check LINGUAS and warn if anything set there isn't enabled via l10n
233 + for lingua in ${LINGUAS}; do
234 + if has ${lingua//[_@]/-} en en-US; then
235 + # For mozilla products, en and en_US are handled internally
236 + continue
237 + # If this language is supported by ${P},
238 + elif has ${lingua} "${MOZ_LANGS[@]//-/_}"; then
239 + # Warn the language is missing, if it isn't already there
240 + has ${lingua//[_@]/-} "${mozlinguas[@]//[_@]/-}" || \
241 + ewarn "LINGUAS value ${lingua} is not enabled using L10N use flags"
242 + continue
243 + # For each short lingua that isn't in MOZ_LANGS,
244 + # We used to add *all* long MOZ_LANGS to the mozlinguas list,
245 + # but we stopped doing that due to bug 325195.
246 + else
247 + :
248 + fi
249 + ewarn "Sorry, but ${P} does not support the ${lingua} locale"
250 + done
251 +}
252 +
253 +# @FUNCTION: mozlinguas_src_unpack
254 +# @DESCRIPTION:
255 +# Unpack xpi language packs according to the user's LINGUAS settings
256 +mozlinguas_src_unpack() {
257 + local x
258 + if ! [[ -n ${MOZ_GENERATE_LANGPACKS} ]]; then
259 + mozlinguas_export
260 + for x in "${mozlinguas[@]}"; do
261 + # FIXME: Add support for unpacking xpis to portage
262 + xpi_unpack "${MOZ_P}-${x}${MOZ_LANGPACK_UNOFFICIAL:+.unofficial}.xpi"
263 + done
264 + if [[ "${mozlinguas[*]}" != "" && "${mozlinguas[*]}" != "en" ]]; then
265 + einfo "Selected language packs (first will be default): ${mozlinguas[*]}"
266 + fi
267 + fi
268 +}
269 +# For the phase function export
270 +mozlinguas-v2_src_unpack() {
271 + mozlinguas_src_unpack
272 +}
273 +
274 +
275 +# @FUNCTION: mozlinguas_mozconfig
276 +# @DESCRIPTION:
277 +# if applicable, add the necessary flag to .mozconfig to support
278 +# the generation of locales. Note that this function requires
279 +# mozconfig_annontate to already be declared via an inherit of
280 +# mozconfig or mozcoreconf.
281 +mozlinguas_mozconfig() {
282 + if [[ -n ${MOZ_GENERATE_LANGPACKS} ]]; then
283 + if declare -f mozconfig_annotate >/dev/null ; then
284 + mozconfig_annotate 'for building locales' --with-l10n-base=${MOZ_L10N_SOURCEDIR}
285 + else
286 + die "Could not configure l10n-base, mozconfig_annotate not declared -- missing inherit?"
287 + fi
288 + fi
289 +}
290 +
291 +# @FUNCTION: mozlinguas_src_compile
292 +# @DESCRIPTION:
293 +# if applicable, build the selected locales.
294 +mozlinguas_src_compile() {
295 + if [[ -n ${MOZ_GENERATE_LANGPACKS} ]]; then
296 + # leverage BUILD_OBJ_DIR if set otherwise assume PWD.
297 + local x y targets=( "langpack" ) localedir="${BUILD_OBJ_DIR:-.}"
298 + case ${PN} in
299 + *firefox)
300 + localedir+="/browser/locales"
301 + ;;
302 + seamonkey)
303 + localedir+="/suite/locales"
304 + ;;
305 + *thunderbird)
306 + localedir+="/mail/locales"
307 + targets+=( "calendar-langpack" )
308 + ;;
309 + *) die "Building locales for ${PN} is not supported."
310 + esac
311 + pushd "${localedir}" > /dev/null || die
312 + mozlinguas_export
313 + for x in "${mozlinguas[@]}"; do for y in "${targets[@]}"; do
314 + emake ${y}-${x} LOCALE_MERGEDIR="./${y}-${x}"
315 + done; done
316 + popd > /dev/null || die
317 + fi
318 +}
319 +
320 +# For the phase function export
321 +mozlinguas-v2_src_compile() {
322 + mozlinguas_src_compile
323 +}
324 +
325 +# @FUNCTION: mozlinguas_xpistage_langpacks
326 +# @DESCRIPTION:
327 +# Add extra langpacks to the xpi-stage dir for prebuilt plugins
328 +#
329 +# First argument is the path to the extension
330 +# Second argument is the prefix of the source (same as first if unspecified)
331 +# Remaining arguments are the modules in the extension that are localized
332 +# (basename of first if unspecified)
333 +#
334 +# Example - installing extra langpacks for lightning:
335 +# src_install() {
336 +# ... # general installation steps
337 +# mozlinguas_xpistage_langpacks \
338 +# "${BUILD_OBJ_DIR}"/dist/xpi-stage/lightning \
339 +# "${WORKDIR}"/lightning \
340 +# lightning calendar
341 +# ... # proceed with installation from the xpi-stage dir
342 +# }
343 +
344 +mozlinguas_xpistage_langpacks() {
345 + local l c modpath="${1}" srcprefix="${1}" modules=( "${1##*/}" )
346 + shift
347 + if [[ -n ${1} ]] ; then srcprefix="${1}" ; shift ; fi
348 + if [[ -n ${1} ]] ; then modules=( $@ ) ; fi
349 +
350 + mozlinguas_export
351 + mkdir -p "${modpath}/chrome" || die
352 + for l in "${mozlinguas[@]}"; do for c in "${modules[@]}" ; do
353 + if [[ -e "${srcprefix}-${l}/chrome/${c}-${l}" ]]; then
354 + cp -RLp -t "${modpath}/chrome" "${srcprefix}-${l}/chrome/${c}-${l}" || die
355 + grep "locale ${c} ${l} chrome/" "${srcprefix}-${l}/chrome.manifest" \
356 + >>"${modpath}/chrome.manifest" || die
357 + elif [[ -e "${srcprefix}/chrome/${c}-${l}" ]]; then
358 + cp -RLp -t "${modpath}/chrome" "${srcprefix}/chrome/${c}-${l}" || die
359 + grep "locale ${c} ${l} chrome/" "${srcprefix}/chrome.manifest" \
360 + >>"${modpath}/chrome.manifest" || die
361 + else
362 + ewarn "Locale ${l} was not found for ${c}, skipping."
363 + fi
364 + done; done
365 +}
366 +
367 +# @FUNCTION: mozlinguas-v2_src_install
368 +# @DESCRIPTION:
369 +# Install xpi language packs according to the user's L10N settings
370 +# NOTE - uses ${BUILD_OBJ_DIR} or PWD if unset, for source-generated langpacks
371 +mozlinguas_src_install() {
372 + local x
373 + mozlinguas_export
374 + if [[ -n ${MOZ_GENERATE_LANGPACKS} ]]; then
375 + local repopath="${WORKDIR}/${PN}-generated-langpacks"
376 + mkdir -p "${repopath}"
377 + pushd "${BUILD_OBJ_DIR:-.}"/dist/*/xpi > /dev/null || die
378 + for x in "${mozlinguas[@]}"; do
379 + cp "${MOZ_P}.${x}.langpack.xpi" \
380 + "${repopath}/${MOZ_P}-${x}${MOZ_LANGPACK_UNOFFICIAL:+.unofficial}.xpi" || die
381 + xpi_unpack "${repopath}/${MOZ_P}-${x}${MOZ_LANGPACK_UNOFFICIAL:+.unofficial}.xpi"
382 + done
383 + popd > /dev/null || die
384 + fi
385 + for x in "${mozlinguas[@]}"; do
386 + xpi_install "${WORKDIR}/${MOZ_P}-${x}${MOZ_LANGPACK_UNOFFICIAL:+.unofficial}"
387 + done
388 +}
389 +
390 +# For the phase function export
391 +mozlinguas-v2_src_install() {
392 + mozlinguas_src_install
393 +}
394
395 diff --git a/www-client/firefox/firefox-47.0.ebuild b/www-client/firefox/firefox-47.0.ebuild
396 index 04cbc4a..33df1ab 100644
397 --- a/www-client/firefox/firefox-47.0.ebuild
398 +++ b/www-client/firefox/firefox-47.0.ebuild
399 @@ -32,7 +32,7 @@ MOZCONFIG_OPTIONAL_GTK2ONLY=1
400 MOZCONFIG_OPTIONAL_WIFI=1
401 MOZCONFIG_OPTIONAL_JIT="enabled"
402
403 -inherit check-reqs flag-o-matic toolchain-funcs eutils gnome2-utils mozconfig-v6.47 pax-utils fdo-mime autotools virtualx mozlinguas
404 +inherit check-reqs flag-o-matic toolchain-funcs eutils gnome2-utils mozconfig-v6.47 pax-utils fdo-mime autotools virtualx mozlinguas-v2
405
406 DESCRIPTION="Firefox Web Browser"
407 HOMEPAGE="http://www.mozilla.com/firefox"