Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Gentoo: Dev

RFC: New eclass: mozlinguas.eclass

 

 

Gentoo dev RSS feed   Index | Next | Previous | View Threaded


nirbheek at gentoo

Feb 1, 2012, 11:25 AM

Post #1 of 8 (452 views)
Permalink
RFC: New eclass: mozlinguas.eclass

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
Attachments: mozlinguas.eclass (3.91 KB)


nirbheek at gentoo

Feb 1, 2012, 12:14 PM

Post #2 of 8 (447 views)
Permalink
Re: RFC: New eclass: mozlinguas.eclass [In reply to]

On Thu, Feb 2, 2012 at 12:55 AM, Nirbheek Chauhan <nirbheek [at] gentoo> 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
Attachments: mozlinguas.eclass.txt (3.92 KB)


eva at gentoo

Feb 3, 2012, 12:28 AM

Post #3 of 8 (442 views)
Permalink
Re: Re: RFC: New eclass: mozlinguas.eclass [In reply to]

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 [at] gentoo>
Gentoo
Attachments: signature.asc (0.19 KB)


vapier at gentoo

Feb 3, 2012, 1:56 AM

Post #4 of 8 (439 views)
Permalink
Re: Re: RFC: New eclass: mozlinguas.eclass [In reply to]

please post it inline to make review easier

> # @MAINTAINER: mozilla [at] gentoo
> # @AUTHOR: Nirbheek Chauhan <nirbheek [at] gentoo>

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
Attachments: signature.asc (0.82 KB)


nirbheek at gentoo

Feb 3, 2012, 8:44 AM

Post #5 of 8 (436 views)
Permalink
Re: Re: RFC: New eclass: mozlinguas.eclass [In reply to]

On Fri, Feb 3, 2012 at 3:26 PM, Mike Frysinger <vapier [at] gentoo> wrote:
> please post it inline to make review easier
>
>> # @MAINTAINER: mozilla [at] gentoo
>> # @AUTHOR: Nirbheek Chauhan <nirbheek [at] gentoo>
>
> 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
Attachments: mozlinguas.eclass.txt (4.07 KB)


vapier at gentoo

Feb 3, 2012, 11:27 AM

Post #6 of 8 (432 views)
Permalink
Re: Re: RFC: New eclass: mozlinguas.eclass [In reply to]

On Friday 03 February 2012 11:44:42 Nirbheek Chauhan wrote:
> On Fri, Feb 3, 2012 at 3:26 PM, Mike Frysinger <vapier [at] gentoo> 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
Attachments: signature.asc (0.82 KB)


nirbheek at gentoo

Feb 3, 2012, 2:10 PM

Post #7 of 8 (433 views)
Permalink
Re: Re: RFC: New eclass: mozlinguas.eclass [In reply to]

On Sat, Feb 4, 2012 at 12:57 AM, Mike Frysinger <vapier [at] gentoo> wrote:

> On Friday 03 February 2012 11:44:42 Nirbheek Chauhan wrote:
> > On Fri, Feb 3, 2012 at 3:26 PM, Mike Frysinger <vapier [at] gentoo>
> 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


ormaaj at gmail

Feb 3, 2012, 2:14 PM

Post #8 of 8 (433 views)
Permalink
Re: Re: RFC: New eclass: mozlinguas.eclass [In reply to]

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
Attachments: signature.asc (0.19 KB)

Gentoo dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.