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

Contents of /eclass/mozlinguas.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Tue Feb 7 15:17:47 2012 UTC (2 years, 9 months ago) by polynomial-c
Branch: MAIN
Changes since 1.1: +7 -3 lines
Fixed eclass for usage with seamonkey (which has langpacks in beta releases)

1 nirbheek 1.1 # Copyright 1999-2012 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 polynomial-c 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/mozlinguas.eclass,v 1.1 2012/02/04 18:28:32 nirbheek 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     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 polynomial-c 1.2 if ! [[ ${PV} =~ alpha|beta ]]|| { [[ ${PN} == seamonkey ]] && ! [[ ${PV} =~ alpha ]] ; } ; then
73 nirbheek 1.1 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 polynomial-c 1.2 if [[ ${PN} == seamonkey ]] ; then
95     [[ ${PV} =~ alpha ]] && return
96     else
97     [[ ${PV} =~ alpha|beta ]] && return
98     fi
99 nirbheek 1.1 local lingua
100     mozlinguas=()
101     for lingua in ${LINGUAS}; do
102     if has ${lingua} en en_US; then
103     # For mozilla products, en and en_US are handled internally
104     continue
105     # If this language is supported by ${P},
106     elif has ${lingua} "${MOZ_LANGS[@]//-/_}"; then
107     # Add the language to mozlinguas, if it isn't already there
108     has ${lingua//_/-} "${mozlinguas[@]}" || mozlinguas+=(${lingua//_/-})
109     continue
110     # For each short lingua that isn't in MOZ_LANGS,
111     # We used to add *all* long MOZ_LANGS to the mozlinguas list,
112     # but we stopped doing that due to bug 325195.
113     else
114     :
115     fi
116     ewarn "Sorry, but ${P} does not support the ${lingua} locale"
117     done
118     }
119    
120     # @FUNCTION: mozlinguas_src_unpack
121     # @DESCRIPTION:
122     # Unpack xpi language packs according to the user's LINGUAS settings
123     mozlinguas_src_unpack() {
124     local x
125     mozlinguas_export
126     for x in "${mozlinguas[@]}"; do
127     # FIXME: Add support for unpacking xpis to portage
128     xpi_unpack "${MOZ_P}-${x}.xpi"
129     done
130     if [[ "${mozlinguas[*]}" != "" && "${mozlinguas[*]}" != "en" ]]; then
131     einfo "Selected language packs (first will be default): ${mozlinguas[*]}"
132     fi
133     }
134    
135     # @FUNCTION: mozlinguas_src_install
136     # @DESCRIPTION:
137     # Install xpi language packs according to the user's LINGUAS settings
138     mozlinguas_src_install() {
139     local x
140     mozlinguas_export
141     for x in "${mozlinguas[@]}"; do
142     xpi_install "${WORKDIR}/${MOZ_P}-${x}"
143     done
144     }

  ViewVC Help
Powered by ViewVC 1.1.20