public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] RFC: New eclass: mozlinguas.eclass
@ 2012-02-01 19:25 Nirbheek Chauhan
  2012-02-01 20:14 ` [gentoo-dev] " Nirbheek Chauhan
  0 siblings, 1 reply; 8+ messages in thread
From: Nirbheek Chauhan @ 2012-02-01 19:25 UTC (permalink / raw
  To: Gentoo Dev

[-- Attachment #1: Type: text/plain, Size: 583 bytes --]

Hello folks,

We in the mozilla team got tired of duplicating the same 50 lines of
code across 6 ebuilds, and decided to consolidate them inside one
eclass.

The eclass is specific to Mozilla products (no one else can or should use it).

It generates SRC_URI using a list of supported language packs
${LANGS[@]}, and exports src_unpack and src_install to install
language packs.

I'd love to have the attached eclass reviewed before I commit it. For
those using gmail, here's a web copy: http://i.cx/ahp
(git.o.g.o/mozilla)

Thanks!

-- 
~Nirbheek Chauhan

Gentoo GNOME+Mozilla Team

[-- Attachment #2: mozlinguas.eclass --]
[-- Type: application/octet-stream, Size: 4005 bytes --]

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: mozlinguas.eclass
# @MAINTAINER: mozilla@gentoo.org
# @AUTHOR: Nirbheek Chauhan <nirbheek@gentoo.org>
# @BLURB: Handle language packs for mozilla products
# @DESCRIPTION:
# Sets IUSE according to LANGS (language packs available). Also exports
# src_unpack and src_install for use in ebuilds.

inherit mozextension

case "${EAPI:-0}" in
	0|1)
		die "EAPI ${EAPI:-0} does not support the '->' SRC_URI operator";;
	2|3|4)
		EXPORT_FUNCTIONS src_unpack src_install;;
	*)
		die "EAPI ${EAPI} is not supported, contact eclass maintainers";;
esac

# @ECLASS-VARIABLE: LANGS
# @DEFAULT-UNSET
# @DESCRIPTION: Array containing the list of language pack xpis available for
# this release. The list can be updated with scripts/get_langs.sh from the
# mozilla overlay.
: ${LANGS:=""}

# @ECLASS-VARIABLE: MOZ_PV
# @DESCRIPTION: Ebuild package version converted to equivalent upstream version.
# Defaults to ${PV}, and should be overridden for alphas, betas, and RCs
: ${MOZ_PV:="${PV}"}

# @ECLASS-VARIABLE: MOZ_PN
# @DESCRIPTION: Ebuild package name converted to equivalent upstream name.
# Defaults to ${PN}, and should be overridden for binary ebuilds.
: ${MOZ_PN:="${PN}"}

# @ECLASS-VARIABLE: MOZ_P
# @DESCRIPTION: Ebuild package name + version converted to upstream equivalent.
# Defaults to ${MOZ_PN}-${MOZ_PV}
: ${MOZ_P:="${MOZ_PN}-${MOZ_PV}"}

# @ECLASS-VARIABLE: FTP_URI
# @DEFAULT-UNSET
# @DESCRIPTION: The ftp URI prefix for the release tarballs and language packs.
: ${FTP_URI:=""}

# @ECLASS-VARIABLE: LANGPACK_PREFIX
# @DESCRIPTION: The relative path till the lang code in the langpack file URI.
# Defaults to ${MOZ_PV}/linux-i686/xpi/
: ${LANGPACK_PREFIX:="${MOZ_PV}/linux-i686/xpi/"}

# @ECLASS-VARIABLE: LANGPACK_SUFFIX
# @DESCRIPTION: The suffix after the lang code in the langpack file URI.
# Defaults to '.xpi'
: ${LANGPACK_SUFFIX:=".xpi"}

# Add linguas_* to IUSE according to available language packs
# No language packs for alphas and betas
if ! [[ ${PV} =~ alpha|beta ]]; then
	for X in "${LANGS[@]}" ; do
		# en and en_US are handled internally
		if [[ ${X} = en ]] || [[ ${X} = en-US ]]; then
			continue
		fi
		SRC_URI="${SRC_URI}
			linguas_${X/-/_}?
				( ${FTP_URI}/${LANGPACK_PREFIX}${X}${LANGPACK_SUFFIX} -> ${MOZ_P}-${X}.xpi )"
		IUSE="${IUSE} linguas_${X/-/_}"
		# We used to do some magic if specific/generic locales were missing, but
		# we stopped doing that due to bug 325195.
	done
fi

linguas() {
	[[ ${PV} =~ alpha|beta ]] && return
	# Generate the list of language packs called "linguas"
	# This list is used to unpack and install the xpi language packs
	local LINGUA
	for LINGUA in ${LINGUAS}; do
		if has ${LINGUA} en en_US; then
			# For mozilla products, en and en_US are handled internally
			continue
		# If this language is supported by ${P},
		elif has ${LINGUA} "${LANGS[@]//-/_}"; then
			# Add the language to linguas, if it isn't already there
			has ${LINGUA//_/-} "${linguas[@]}" || linguas+=(${LINGUA//_/-})
			continue
		# For each short LINGUA that isn't in LANGS,
		# We used to add *all* long LANGS to the linguas list,
		# but we stopped doing that due to bug 325195.
		fi
		ewarn "Sorry, but ${P} does not support the ${LINGUA} locale"
	done
}

# @FUNCTION: mozlinguas_src_unpack
# @DESCRIPTION:
# Unpack xpi language packs according to the user's LINGUAS settings
mozlinguas_src_unpack() {
	local X
	linguas
	for X in "${linguas[@]}"; do
		# FIXME: Add support for unpacking xpis to portage
		xpi_unpack "${MOZ_P}-${X}.xpi"
	done
	if [[ "${linguas[*]}" != "" && "${linguas[*]}" != "en" ]]; then
		einfo "Selected language packs (first will be default): ${linguas[*]}"
	fi
}

# @FUNCTION: mozlinguas_src_install
# @DESCRIPTION:
# Install xpi language packs according to the user's LINGUAS settings
mozlinguas_src_install() {
	local X
	linguas
	for X in "${linguas[@]}"; do
		xpi_install "${WORKDIR}/${MOZ_P}-${X}"
	done
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-01 19:25 [gentoo-dev] RFC: New eclass: mozlinguas.eclass Nirbheek Chauhan
@ 2012-02-01 20:14 ` Nirbheek Chauhan
  2012-02-03  8:28   ` Gilles Dartiguelongue
  2012-02-03  9:56   ` Mike Frysinger
  0 siblings, 2 replies; 8+ messages in thread
From: Nirbheek Chauhan @ 2012-02-01 20:14 UTC (permalink / raw
  To: Gentoo Dev

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

On Thu, Feb 2, 2012 at 12:55 AM, Nirbheek Chauhan <nirbheek@gentoo.org> wrote:
> I'd love to have the attached eclass reviewed before I commit it. For
> those using gmail, here's a web copy: http://i.cx/ahp
> (git.o.g.o/mozilla)
>

After comments from mgorny on #gentoo-dev, I've made the following changes:

(a) Use mozlinguas() instead of linguas() (namespace)
(b) Use lowercase for local iterator variables

An updated eclass is attached (this time with a fake extension to get
gmail to see it as ascii text!).

Web version: http://git.overlays.gentoo.org/gitweb/?p=proj/mozilla.git;a=blob;f=eclass/mozlinguas.eclass;hb=HEAD

-- 
~Nirbheek Chauhan

Gentoo GNOME+Mozilla Team

[-- Attachment #2: mozlinguas.eclass.txt --]
[-- Type: text/plain, Size: 4014 bytes --]

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: mozlinguas.eclass
# @MAINTAINER: mozilla@gentoo.org
# @AUTHOR: Nirbheek Chauhan <nirbheek@gentoo.org>
# @BLURB: Handle language packs for mozilla products
# @DESCRIPTION:
# Sets IUSE according to LANGS (language packs available). Also exports
# src_unpack and src_install for use in ebuilds.

inherit mozextension

case "${EAPI:-0}" in
	0|1)
		die "EAPI ${EAPI:-0} does not support the '->' SRC_URI operator";;
	2|3|4)
		EXPORT_FUNCTIONS src_unpack src_install;;
	*)
		die "EAPI ${EAPI} is not supported, contact eclass maintainers";;
esac

# @ECLASS-VARIABLE: LANGS
# @DEFAULT-UNSET
# @DESCRIPTION: Array containing the list of language pack xpis available for
# this release. The list can be updated with scripts/get_langs.sh from the
# mozilla overlay.
: ${LANGS:=""}

# @ECLASS-VARIABLE: MOZ_PV
# @DESCRIPTION: Ebuild package version converted to equivalent upstream version.
# Defaults to ${PV}, and should be overridden for alphas, betas, and RCs
: ${MOZ_PV:="${PV}"}

# @ECLASS-VARIABLE: MOZ_PN
# @DESCRIPTION: Ebuild package name converted to equivalent upstream name.
# Defaults to ${PN}, and should be overridden for binary ebuilds.
: ${MOZ_PN:="${PN}"}

# @ECLASS-VARIABLE: MOZ_P
# @DESCRIPTION: Ebuild package name + version converted to upstream equivalent.
# Defaults to ${MOZ_PN}-${MOZ_PV}
: ${MOZ_P:="${MOZ_PN}-${MOZ_PV}"}

# @ECLASS-VARIABLE: FTP_URI
# @DEFAULT-UNSET
# @DESCRIPTION: The ftp URI prefix for the release tarballs and language packs.
: ${FTP_URI:=""}

# @ECLASS-VARIABLE: LANGPACK_PREFIX
# @DESCRIPTION: The relative path till the lang code in the langpack file URI.
# Defaults to ${MOZ_PV}/linux-i686/xpi/
: ${LANGPACK_PREFIX:="${MOZ_PV}/linux-i686/xpi/"}

# @ECLASS-VARIABLE: LANGPACK_SUFFIX
# @DESCRIPTION: The suffix after the lang code in the langpack file URI.
# Defaults to '.xpi'
: ${LANGPACK_SUFFIX:=".xpi"}

# Add linguas_* to IUSE according to available language packs
# No language packs for alphas and betas
if ! [[ ${PV} =~ alpha|beta ]]; then
	for x in "${LANGS[@]}" ; do
		# en and en_US are handled internally
		if [[ ${x} = en ]] || [[ ${x} = en-US ]]; then
			continue
		fi
		SRC_URI="${SRC_URI}
			linguas_${x/-/_}?
				( ${FTP_URI}/${LANGPACK_PREFIX}${x}${LANGPACK_SUFFIX} -> ${MOZ_P}-${x}.xpi )"
		IUSE="${IUSE} linguas_${x/-/_}"
		# We used to do some magic if specific/generic locales were missing, but
		# we stopped doing that due to bug 325195.
	done
fi

mozlinguas() {
	[[ ${PV} =~ alpha|beta ]] && return
	# Generate the list of language packs called "linguas"
	# This list is used to unpack and install the xpi language packs
	local lingua
	for lingua in ${LINGUAS}; do
		if has ${lingua} en en_US; then
			# For mozilla products, en and en_US are handled internally
			continue
		# If this language is supported by ${P},
		elif has ${lingua} "${LANGS[@]//-/_}"; then
			# Add the language to linguas, if it isn't already there
			has ${lingua//_/-} "${linguas[@]}" || linguas+=(${lingua//_/-})
			continue
		# For each short lingua that isn't in LANGS,
		# We used to add *all* long LANGS to the linguas list,
		# but we stopped doing that due to bug 325195.
		fi
		ewarn "Sorry, but ${P} does not support the ${lingua} locale"
	done
}

# @FUNCTION: mozlinguas_src_unpack
# @DESCRIPTION:
# Unpack xpi language packs according to the user's LINGUAS settings
mozlinguas_src_unpack() {
	local x
	mozlinguas
	for x in "${linguas[@]}"; do
		# FIXME: Add support for unpacking xpis to portage
		xpi_unpack "${MOZ_P}-${x}.xpi"
	done
	if [[ "${linguas[*]}" != "" && "${linguas[*]}" != "en" ]]; then
		einfo "Selected language packs (first will be default): ${linguas[*]}"
	fi
}

# @FUNCTION: mozlinguas_src_install
# @DESCRIPTION:
# Install xpi language packs according to the user's LINGUAS settings
mozlinguas_src_install() {
	local x
	mozlinguas
	for x in "${linguas[@]}"; do
		xpi_install "${WORKDIR}/${MOZ_P}-${x}"
	done
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-01 20:14 ` [gentoo-dev] " Nirbheek Chauhan
@ 2012-02-03  8:28   ` Gilles Dartiguelongue
  2012-02-03  9:56   ` Mike Frysinger
  1 sibling, 0 replies; 8+ messages in thread
From: Gilles Dartiguelongue @ 2012-02-03  8:28 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

Le jeudi 02 février 2012 à 01:44 +0530, Nirbheek Chauhan a écrit :
> ECLASS-VARIABLE: FTP_URI
> # @DEFAULT-UNSET
> # @DESCRIPTION: The ftp URI prefix for the release tarballs and
> language packs.
> : ${FTP_URI:=""} 

It might be a good idea to prefix this "generic" variable by MOZ_ as
well.

-- 
Gilles Dartiguelongue <eva@gentoo.org>
Gentoo

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-01 20:14 ` [gentoo-dev] " Nirbheek Chauhan
  2012-02-03  8:28   ` Gilles Dartiguelongue
@ 2012-02-03  9:56   ` Mike Frysinger
  2012-02-03 16:44     ` Nirbheek Chauhan
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-02-03  9:56 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: Text/Plain, Size: 2216 bytes --]

please post it inline to make review easier

> # @MAINTAINER: mozilla@gentoo.org
> # @AUTHOR: Nirbheek Chauhan <nirbheek@gentoo.org>

goes on newline, not inlined

> # @DESCRIPTION: Array containing the list of language pack xpis available

text starts on the next line, not the existing line

> # @ECLASS-VARIABLE: LANGS
> # @ECLASS-VARIABLE: LANGPACK_PREFIX
> # @ECLASS-VARIABLE: LANGPACK_SUFFIX

these prob could use MOZ prefixes as well

> : ${LANGS:=""}

you say it's an array but then you initialize it to a string ...

> if ! [[ ${PV} =~ alpha|beta ]]; then
> 	for x in "${LANGS[@]}" ; do

x is a global variable here ... one reason to write this as an internal func 
and then call it so you can use `local`

>		if [[ ${x} = en ]] || [[ ${x} = en-US ]]; then

should be == imo

>		SRC_URI="${SRC_URI}

SRC_URI+="...

>		IUSE="${IUSE} linguas_${x/-/_}"

IUSE+="...

> mozlinguas() {

missing eclass documentation

>	# Generate the list of language packs called "linguas"
>	# This list is used to unpack and install the xpi language packs

shouldn't this initialize linguas=() ?

and shouldn't it name the return value mozlinguas ?

>		# If this language is supported by ${P},
>		elif has ${lingua} "${LANGS[@]//-/_}"; then
>			# Add the language to linguas, if it isn't already there
>			has ${lingua//_/-} "${linguas[@]}" || linguas+=(${lingua//_/-})
>			continue
>		# For each short lingua that isn't in LANGS,
>		# We used to add *all* long LANGS to the linguas list,
>		# but we stopped doing that due to bug 325195.
>		fi

indentation on these comments seem to be off

> 		# FIXME: Add support for unpacking xpis to portage
> 		xpi_unpack "${MOZ_P}-${x}.xpi"

or, add it to the new unpacker.eclass ;)

also, seems to be missing `use linguas_${x} && xpi_unpack ...` ?  otherwise, 
you just unpack all linguas and not just the ones the user has requested ... 
same goes for the install ...

>	if [[ "${linguas[*]}" != "" && "${linguas[*]}" != "en" ]]; then
>		einfo "Selected language packs (first will be default): ${linguas[*]}"

since linguas[*] will be big by default, i'd put the variable expansion into 
its own einfo
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-03  9:56   ` Mike Frysinger
@ 2012-02-03 16:44     ` Nirbheek Chauhan
  2012-02-03 19:27       ` Mike Frysinger
  2012-02-03 22:14       ` Dan Douglas
  0 siblings, 2 replies; 8+ messages in thread
From: Nirbheek Chauhan @ 2012-02-03 16:44 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 3552 bytes --]

On Fri, Feb 3, 2012 at 3:26 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> please post it inline to make review easier
>
>> # @MAINTAINER: mozilla@gentoo.org
>> # @AUTHOR: Nirbheek Chauhan <nirbheek@gentoo.org>
>
> goes on newline, not inlined
>

Fixed

>> # @DESCRIPTION: Array containing the list of language pack xpis available
>
> text starts on the next line, not the existing line
>

Fixed

>> # @ECLASS-VARIABLE: LANGS
>> # @ECLASS-VARIABLE: LANGPACK_PREFIX
>> # @ECLASS-VARIABLE: LANGPACK_SUFFIX
>
> these prob could use MOZ prefixes as well
>

Fixed

>> : ${LANGS:=""}
>
> you say it's an array but then you initialize it to a string ...
>

Meh, no real difference. :p

Changed anyway!

>> if ! [[ ${PV} =~ alpha|beta ]]; then
>>       for x in "${LANGS[@]}" ; do
>
> x is a global variable here ... one reason to write this as an internal func
> and then call it so you can use `local`
>

I just added an "unset x" at the end of the chunk, that should be
sufficient I think.

>>               if [[ ${x} = en ]] || [[ ${x} = en-US ]]; then
>
> should be == imo
>

Fixed

>>               SRC_URI="${SRC_URI}
>
> SRC_URI+="...
>

Fixed

>>               IUSE="${IUSE} linguas_${x/-/_}"
>
> IUSE+="...
>

Fixed

>> mozlinguas() {
>
> missing eclass documentation
>

Is it really needed for private functions? Nothing should ever call this.

>>       # Generate the list of language packs called "linguas"
>>       # This list is used to unpack and install the xpi language packs
>
> shouldn't this initialize linguas=() ?
>
> and shouldn't it name the return value mozlinguas ?
>

Fixed, and renamed the function to mozlinguas_export()

>>               # If this language is supported by ${P},
>>               elif has ${lingua} "${LANGS[@]//-/_}"; then
>>                       # Add the language to linguas, if it isn't already there
>>                       has ${lingua//_/-} "${linguas[@]}" || linguas+=(${lingua//_/-})
>>                       continue
>>               # For each short lingua that isn't in LANGS,
>>               # We used to add *all* long LANGS to the linguas list,
>>               # but we stopped doing that due to bug 325195.
>>               fi
>
> indentation on these comments seem to be off
>

No, that's on purpose. There used to be an `else` statement there.
That comment doesn't belong to the previous `elif` block. I've added
it outside a blank else block to clarify that.

>>               # FIXME: Add support for unpacking xpis to portage
>>               xpi_unpack "${MOZ_P}-${x}.xpi"
>
> or, add it to the new unpacker.eclass ;)
>
> also, seems to be missing `use linguas_${x} && xpi_unpack ...` ?  otherwise,
> you just unpack all linguas and not just the ones the user has requested ...
> same goes for the install ...
>

No, "${mozlinguas[@]}" is already the intersection of MOZ_LANGS and LINGUAS.

>>       if [[ "${linguas[*]}" != "" && "${linguas[*]}" != "en" ]]; then
>>               einfo "Selected language packs (first will be default): ${linguas[*]}"
>
> since linguas[*] will be big by default, i'd put the variable expansion into
> its own einfo

It's actually really small by default since it's the list of enabled langpacks.

Fixed version attached, thanks for the review!

-- 
~Nirbheek Chauhan

Gentoo GNOME+Mozilla Team

[-- Attachment #2: mozlinguas.eclass.txt --]
[-- Type: text/plain, Size: 4169 bytes --]

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: mozlinguas.eclass
# @MAINTAINER:
# mozilla@gentoo.org
# @AUTHOR:
# Nirbheek Chauhan <nirbheek@gentoo.org>
# @BLURB: Handle language packs for mozilla products
# @DESCRIPTION:
# Sets IUSE according to MOZ_LANGS (language packs available). Also exports
# src_unpack and src_install for use in ebuilds.

inherit mozextension

case "${EAPI:-0}" in
	0|1)
		die "EAPI ${EAPI:-0} does not support the '->' SRC_URI operator";;
	2|3|4)
		EXPORT_FUNCTIONS src_unpack src_install;;
	*)
		die "EAPI ${EAPI} is not supported, contact eclass maintainers";;
esac

# @ECLASS-VARIABLE: MOZ_LANGS
# @DEFAULT-UNSET
# @DESCRIPTION:
# Array containing the list of language pack xpis available for
# this release. The list can be updated with scripts/get_langs.sh from the
# mozilla overlay.
: ${MOZ_LANGS:=()}

# @ECLASS-VARIABLE: MOZ_PV
# @DESCRIPTION:
# Ebuild package version converted to equivalent upstream version.
# Defaults to ${PV}, and should be overridden for alphas, betas, and RCs
: ${MOZ_PV:="${PV}"}

# @ECLASS-VARIABLE: MOZ_PN
# @DESCRIPTION:
# Ebuild package name converted to equivalent upstream name.
# Defaults to ${PN}, and should be overridden for binary ebuilds.
: ${MOZ_PN:="${PN}"}

# @ECLASS-VARIABLE: MOZ_P
# @DESCRIPTION:
# Ebuild package name + version converted to upstream equivalent.
# Defaults to ${MOZ_PN}-${MOZ_PV}
: ${MOZ_P:="${MOZ_PN}-${MOZ_PV}"}

# @ECLASS-VARIABLE: MOZ_FTP_URI
# @DEFAULT-UNSET
# @DESCRIPTION:
# The ftp URI prefix for the release tarballs and language packs.
: ${MOZ_FTP_URI:=""}

# @ECLASS-VARIABLE: MOZ_LANGPACK_PREFIX
# @DESCRIPTION:
# The relative path till the lang code in the langpack file URI.
# Defaults to ${MOZ_PV}/linux-i686/xpi/
: ${MOZ_LANGPACK_PREFIX:="${MOZ_PV}/linux-i686/xpi/"}

# @ECLASS-VARIABLE: MOZ_LANGPACK_SUFFIX
# @DESCRIPTION:
# The suffix after the lang code in the langpack file URI.
# Defaults to '.xpi'
: ${MOZ_LANGPACK_SUFFIX:=".xpi"}

# Add linguas_* to IUSE according to available language packs
# No language packs for alphas and betas
if ! [[ ${PV} =~ alpha|beta ]]; then
	for x in "${MOZ_LANGS[@]}" ; do
		# en and en_US are handled internally
		if [[ ${x} == en ]] || [[ ${x} == en-US ]]; then
			continue
		fi
		SRC_URI+="
			linguas_${x/-/_}?
				( ${MOZ_FTP_URI}/${MOZ_LANGPACK_PREFIX}${x}${MOZ_LANGPACK_SUFFIX} -> ${MOZ_P}-${x}.xpi )"
		IUSE+=" linguas_${x/-/_}"
		# We used to do some magic if specific/generic locales were missing, but
		# we stopped doing that due to bug 325195.
	done
fi
unset x

mozlinguas_export() {
	[[ ${PV} =~ alpha|beta ]] && return
	# Generate the list of language packs called "mozlinguas"
	# This list is used to unpack and install the xpi language packs
	local lingua
	mozlinguas=()
	for lingua in ${LINGUAS}; do
		if has ${lingua} en en_US; then
			# For mozilla products, en and en_US are handled internally
			continue
		# If this language is supported by ${P},
		elif has ${lingua} "${MOZ_LANGS[@]//-/_}"; then
			# Add the language to mozlinguas, if it isn't already there
			has ${lingua//_/-} "${mozlinguas[@]}" || mozlinguas+=(${lingua//_/-})
			continue
		# For each short lingua that isn't in MOZ_LANGS,
		# We used to add *all* long MOZ_LANGS to the mozlinguas list,
		# but we stopped doing that due to bug 325195.
		else
			:
		fi
		ewarn "Sorry, but ${P} does not support the ${lingua} locale"
	done
}

# @FUNCTION: mozlinguas_src_unpack
# @DESCRIPTION:
# Unpack xpi language packs according to the user's LINGUAS settings
mozlinguas_src_unpack() {
	local x
	mozlinguas_export
	for x in "${mozlinguas[@]}"; do
		# FIXME: Add support for unpacking xpis to portage
		xpi_unpack "${MOZ_P}-${x}.xpi"
	done
	if [[ "${mozlinguas[*]}" != "" && "${mozlinguas[*]}" != "en" ]]; then
		einfo "Selected language packs (first will be default): ${mozlinguas[*]}"
	fi
}

# @FUNCTION: mozlinguas_src_install
# @DESCRIPTION:
# Install xpi language packs according to the user's LINGUAS settings
mozlinguas_src_install() {
	local x
	mozlinguas_export
	for x in "${mozlinguas[@]}"; do
		xpi_install "${WORKDIR}/${MOZ_P}-${x}"
	done
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-03 16:44     ` Nirbheek Chauhan
@ 2012-02-03 19:27       ` Mike Frysinger
  2012-02-03 22:10         ` Nirbheek Chauhan
  2012-02-03 22:14       ` Dan Douglas
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-02-03 19:27 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: Text/Plain, Size: 459 bytes --]

On Friday 03 February 2012 11:44:42 Nirbheek Chauhan wrote:
> On Fri, Feb 3, 2012 at 3:26 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> >> mozlinguas() {
> > 
> > missing eclass documentation
> 
> Is it really needed for private functions? Nothing should ever call this.

needed ?  no.  nice ?  sure.  up to you as the maintainer, but the eclass doc 
format does support @INTERNAL on functions so it doesn't get exported to the 
man page.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-03 19:27       ` Mike Frysinger
@ 2012-02-03 22:10         ` Nirbheek Chauhan
  0 siblings, 0 replies; 8+ messages in thread
From: Nirbheek Chauhan @ 2012-02-03 22:10 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 739 bytes --]

On Sat, Feb 4, 2012 at 12:57 AM, Mike Frysinger <vapier@gentoo.org> wrote:

> On Friday 03 February 2012 11:44:42 Nirbheek Chauhan wrote:
> > On Fri, Feb 3, 2012 at 3:26 PM, Mike Frysinger <vapier@gentoo.org>
> wrote:
> > >> mozlinguas() {
> > >
> > > missing eclass documentation
> >
> > Is it really needed for private functions? Nothing should ever call this.
>
> needed ?  no.  nice ?  sure.  up to you as the maintainer, but the eclass
> doc
> format does support @INTERNAL on functions so it doesn't get exported to
> the
> man page.
>

Okay, that was my only concern (eclass doc). The function itself is
documented in the second line of the function body. I just moved that up
now.

-- 
~Nirbheek Chauhan

Gentoo GNOME+Mozilla Team

[-- Attachment #2: Type: text/html, Size: 1206 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] Re: RFC: New eclass: mozlinguas.eclass
  2012-02-03 16:44     ` Nirbheek Chauhan
  2012-02-03 19:27       ` Mike Frysinger
@ 2012-02-03 22:14       ` Dan Douglas
  1 sibling, 0 replies; 8+ messages in thread
From: Dan Douglas @ 2012-02-03 22:14 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 576 bytes --]

On Friday, February 03, 2012 10:14:42 PM Nirbheek Chauhan wrote:
> >>               if [[ ${x} = en ]] || [[ ${x} = en-US ]]; then
> > 
> > should be == imo
> 
> Fixed

I prefer == for [[ too, but no difference. = is required for [ by POSIX but 
Bash allows either (bad though). The real issue is executing two commands 
since [[ can short-circuit and works as you expect. Two are only needed with [ 
because -a and -o are so unpredictable.

[[ $x == en || $x == en-US ]]
or
case $x in  en|en-US) ...;; esac;
or 
[[ $x == @(en|en-US) ]]
or
[[ $x == en?(-US) ]]
-- 
Dan Douglas

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-03 22:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01 19:25 [gentoo-dev] RFC: New eclass: mozlinguas.eclass Nirbheek Chauhan
2012-02-01 20:14 ` [gentoo-dev] " Nirbheek Chauhan
2012-02-03  8:28   ` Gilles Dartiguelongue
2012-02-03  9:56   ` Mike Frysinger
2012-02-03 16:44     ` Nirbheek Chauhan
2012-02-03 19:27       ` Mike Frysinger
2012-02-03 22:10         ` Nirbheek Chauhan
2012-02-03 22:14       ` Dan Douglas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox