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

Contents of /eclass/mozlinguas.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat Feb 4 18:28:32 2012 UTC (2 years, 8 months ago) by nirbheek
Branch: MAIN
Add mozlinguas.eclass to handle language packs for mozilla products

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

  ViewVC Help
Powered by ViewVC 1.1.20