/[gentoo-x86]/eclass/mozlinguas.eclass
Gentoo

Contents of /eclass/mozlinguas.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Fri Apr 5 15:27:40 2013 UTC (17 months, 2 weeks ago) by floppym
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +2 -4 lines
Fix eclass docs.

1 floppym 1.6 # Copyright 1999-2013 Gentoo Foundation
2 nirbheek 1.1 # Distributed under the terms of the GNU General Public License v2
3 floppym 1.6 # $Header: /var/cvsroot/gentoo-x86/eclass/mozlinguas.eclass,v 1.5 2012/09/27 16:35:41 axs Exp $
4 nirbheek 1.1
5     # @ECLASS: mozlinguas.eclass
6     # @MAINTAINER:
7     # mozilla@gentoo.org
8     # @AUTHOR:
9     # Nirbheek Chauhan <nirbheek@gentoo.org>
10     # @BLURB: Handle language packs for mozilla products
11     # @DESCRIPTION:
12     # Sets IUSE according to MOZ_LANGS (language packs available). Also exports
13     # src_unpack and src_install for use in ebuilds.
14    
15     inherit mozextension
16    
17     case "${EAPI:-0}" in
18     0|1)
19     die "EAPI ${EAPI:-0} does not support the '->' SRC_URI operator";;
20 axs 1.5 2|3|4|5)
21 nirbheek 1.1 EXPORT_FUNCTIONS src_unpack src_install;;
22     *)
23     die "EAPI ${EAPI} is not supported, contact eclass maintainers";;
24     esac
25    
26     # @ECLASS-VARIABLE: MOZ_LANGS
27     # @DESCRIPTION:
28     # Array containing the list of language pack xpis available for
29     # this release. The list can be updated with scripts/get_langs.sh from the
30     # mozilla overlay.
31     : ${MOZ_LANGS:=()}
32    
33     # @ECLASS-VARIABLE: MOZ_PV
34     # @DESCRIPTION:
35     # Ebuild package version converted to equivalent upstream version.
36     # Defaults to ${PV}, and should be overridden for alphas, betas, and RCs
37     : ${MOZ_PV:="${PV}"}
38    
39     # @ECLASS-VARIABLE: MOZ_PN
40     # @DESCRIPTION:
41     # Ebuild package name converted to equivalent upstream name.
42     # Defaults to ${PN}, and should be overridden for binary ebuilds.
43     : ${MOZ_PN:="${PN}"}
44    
45     # @ECLASS-VARIABLE: MOZ_P
46     # @DESCRIPTION:
47     # Ebuild package name + version converted to upstream equivalent.
48     # Defaults to ${MOZ_PN}-${MOZ_PV}
49     : ${MOZ_P:="${MOZ_PN}-${MOZ_PV}"}
50    
51     # @ECLASS-VARIABLE: MOZ_FTP_URI
52     # @DESCRIPTION:
53     # The ftp URI prefix for the release tarballs and language packs.
54     : ${MOZ_FTP_URI:=""}
55    
56     # @ECLASS-VARIABLE: MOZ_LANGPACK_PREFIX
57     # @DESCRIPTION:
58     # The relative path till the lang code in the langpack file URI.
59     # Defaults to ${MOZ_PV}/linux-i686/xpi/
60     : ${MOZ_LANGPACK_PREFIX:="${MOZ_PV}/linux-i686/xpi/"}
61    
62     # @ECLASS-VARIABLE: MOZ_LANGPACK_SUFFIX
63     # @DESCRIPTION:
64     # The suffix after the lang code in the langpack file URI.
65     # Defaults to '.xpi'
66     : ${MOZ_LANGPACK_SUFFIX:=".xpi"}
67    
68     # Add linguas_* to IUSE according to available language packs
69     # No language packs for alphas and betas
70 polynomial-c 1.3 if ! [[ ${PV} =~ alpha|beta ]] || { [[ ${PN} == seamonkey ]] && ! [[ ${PV} =~ alpha ]] ; } ; then
71 nirbheek 1.1 for x in "${MOZ_LANGS[@]}" ; do
72     # en and en_US are handled internally
73     if [[ ${x} == en ]] || [[ ${x} == en-US ]]; then
74     continue
75     fi
76     SRC_URI+="
77     linguas_${x/-/_}?
78     ( ${MOZ_FTP_URI}/${MOZ_LANGPACK_PREFIX}${x}${MOZ_LANGPACK_SUFFIX} -> ${MOZ_P}-${x}.xpi )"
79     IUSE+=" linguas_${x/-/_}"
80     # We used to do some magic if specific/generic locales were missing, but
81     # we stopped doing that due to bug 325195.
82     done
83     fi
84     unset x
85    
86     # @FUNCTION: mozlinguas_export
87     # @INTERNAL
88     # @DESCRIPTION:
89     # Generate the list of language packs called "mozlinguas"
90     # This list is used to unpack and install the xpi language packs
91     mozlinguas_export() {
92 polynomial-c 1.2 if [[ ${PN} == seamonkey ]] ; then
93     [[ ${PV} =~ alpha ]] && return
94     else
95     [[ ${PV} =~ alpha|beta ]] && return
96     fi
97 nirbheek 1.1 local lingua
98     mozlinguas=()
99     for lingua in ${LINGUAS}; do
100     if has ${lingua} en en_US; then
101     # For mozilla products, en and en_US are handled internally
102     continue
103     # If this language is supported by ${P},
104     elif has ${lingua} "${MOZ_LANGS[@]//-/_}"; then
105     # Add the language to mozlinguas, if it isn't already there
106     has ${lingua//_/-} "${mozlinguas[@]}" || mozlinguas+=(${lingua//_/-})
107     continue
108     # For each short lingua that isn't in MOZ_LANGS,
109     # We used to add *all* long MOZ_LANGS to the mozlinguas list,
110     # but we stopped doing that due to bug 325195.
111     else
112     :
113     fi
114     ewarn "Sorry, but ${P} does not support the ${lingua} locale"
115     done
116     }
117    
118     # @FUNCTION: mozlinguas_src_unpack
119     # @DESCRIPTION:
120     # Unpack xpi language packs according to the user's LINGUAS settings
121     mozlinguas_src_unpack() {
122     local x
123     mozlinguas_export
124     for x in "${mozlinguas[@]}"; do
125     # FIXME: Add support for unpacking xpis to portage
126     xpi_unpack "${MOZ_P}-${x}.xpi"
127     done
128     if [[ "${mozlinguas[*]}" != "" && "${mozlinguas[*]}" != "en" ]]; then
129     einfo "Selected language packs (first will be default): ${mozlinguas[*]}"
130     fi
131     }
132    
133     # @FUNCTION: mozlinguas_src_install
134     # @DESCRIPTION:
135     # Install xpi language packs according to the user's LINGUAS settings
136     mozlinguas_src_install() {
137     local x
138     mozlinguas_export
139     for x in "${mozlinguas[@]}"; do
140     xpi_install "${WORKDIR}/${MOZ_P}-${x}"
141     done
142     }

  ViewVC Help
Powered by ViewVC 1.1.20