All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Patches and discussions about the oe-core layer
	<openembedded-core@lists.openembedded.org>
Subject: Re: [CONSOLIDATED PULL 10/20] package.bbclass: add support to split Qt translation files
Date: Mon, 06 Jun 2011 18:14:33 +0100	[thread overview]
Message-ID: <1307380473.7672.30.camel@rex> (raw)
In-Reply-To: <e66fee724ac6efa49cb941a59b2fc7c61bf14405.1307342214.git.sgw@linux.intel.com>

On Sun, 2011-06-05 at 23:44 -0700, Saul Wold wrote:
> From: Otavio Salvador <otavio@ossystems.com.br>
> 
> There're many Qt applications that provide translation files in '.qm'
> format however those weren't being splitted as GetText based
> ones.
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>

Am I right in assuming all these qt applications use one of the qt
classes?

I do wonder if this shouldn't be part of one of the qt classes as part
of a package_do_split_locales_append() or prepend() style function from
a code separation point of view. I do appreciate the need to influence
the list of locales although you could do that through directory
creation or an extra variable but we could enhance package.bbclass to
support that.

> ---
>  meta/classes/package.bbclass |   41 +++++++++++++++++++++++++++++++++++++----
>  1 files changed, 37 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index 1e6a872..e4be20f 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -343,6 +343,8 @@ python package_do_split_locales() {
>  		bb.debug(1, "package requested not splitting locales")
>  		return
>  
> +	import re
> +
>  	packages = (bb.data.getVar('PACKAGES', d, True) or "").split()
>  
>  	datadir = bb.data.getVar('datadir', d, True)
> @@ -358,12 +360,29 @@ python package_do_split_locales() {
>  
>  	localedir = os.path.join(dvar + datadir, 'locale')
>  
> -	if not os.path.isdir(localedir):
> +	locales = []
> +	if os.path.isdir(localedir):
> +		locales = os.listdir(localedir)
> +
> +	# Check of Qt translation files
> +	qm_re = re.compile("(.*)\.qm$")
> +	qm_files = {}
> +	for root, dirs, files in os.walk(dvar):
> +		for file in files:
> +			qm_file = qm_re.match(file)
> +			if qm_file:
> +				locale = qm_file.group(1)
> +				relpath = os.path.join(root, file).replace(dvar, '', 1)
> +				if relpath:
> +					if not qm_files.has_key(locale):
> +						qm_files[locale] = []
> +
> +					qm_files[locale].append(relpath)
> +
> +	if len(locales) == 0 and len(qm_files) == 0:
>  		bb.debug(1, "No locale files in this package")
>  		return
>  
> -	locales = os.listdir(localedir)
> -
>  	# This is *really* broken
>  	mainpkg = packages[0]
>  	# At least try and patch it up I guess...
> @@ -372,13 +391,27 @@ python package_do_split_locales() {
>  	if mainpkg.find('-dev'):
>  		mainpkg = mainpkg.replace('-dev', '')
>  
> +	# Queue Qt locales for spliting
> +	for l in qm_files.keys():
> +		if l not in locales:
> +			locales.append(l)
> +
> +	# Split the locales into different packages
>  	summary = bb.data.getVar('SUMMARY', d, True) or pn
>  	description = bb.data.getVar('DESCRIPTION', d, True) or "" 
>  	for l in locales:
>  		ln = legitimize_package_name(l)
>  		pkg = pn + '-locale-' + ln
>  		packages.append(pkg)
> -		bb.data.setVar('FILES_' + pkg, os.path.join(datadir, 'locale', l), d)
> +		files = []
> +		files.append(os.path.join(datadir, 'locale', l))
> +
> +		if qm_files.has_key(l):
> +			locale_re = re.compile("^.*([a-z]{2}(_[A-Z]{2})?)$")
> +			ln = legitimize_package_name(locale_re.match(l).group(1))
> +			files += qm_files[l]

Regardless, this is changing ln under some weird circumstances.
Shouldn't the code adding this to the locales list be handling this
translation? I can see potential duplication between the arrays and a
host of other nasty bugs with this code as it stands :/. Please take
that regexp out of this loop at the very least.


Cheers,

Richard


> +
> +		bb.data.setVar('FILES_' + pkg, " ".join(files), d)
>  		bb.data.setVar('RDEPENDS_' + pkg, '%s virtual-locale-%s' % (mainpkg, ln), d)
>  		bb.data.setVar('RPROVIDES_' + pkg, '%s-locale %s-translation' % (pn, ln), d)
>  		bb.data.setVar('SUMMARY_' + pkg, '%s - %s translations' % (summary, l), d)





  reply	other threads:[~2011-06-06 17:18 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06  6:44 [CONSOLIDATED PULL 00/20] 05-June-2011 Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 01/20] bitbake.conf: Create staticlibs pacakge for static libraries Saul Wold
2011-06-06  6:55   ` Phil Blundell
2011-06-06 10:50     ` Richard Purdie
2011-06-06 16:50       ` Saul Wold
2011-06-06 17:31         ` Otavio Salvador
2011-06-06 19:00           ` Richard Purdie
2011-06-06 19:07             ` Otavio Salvador
2011-06-06 19:31               ` Richard Purdie
2011-06-07 10:08               ` Phil Blundell
2011-06-06 19:34         ` Koen Kooi
2011-06-06 14:59     ` Saul Wold
2011-06-06 17:03   ` Khem Raj
2011-06-06 19:01     ` Richard Purdie
2011-06-06  6:44 ` [CONSOLIDATED PULL 02/20] m4: upgrade from 1.4.15 to 1.4.16 Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 03/20] autoconf: upgrade from 2.65 to 2.68 Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 04/20] bison: upgrade from 2.4.3 to 2.5 Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 05/20] allarch.bbclass: Define BASE_PACKAGE_ARCH = "all" Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 06/20] util-linux_2.19.1.bb: Fix compliation on uclibc Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 07/20] base.bbclass: add cleansstate task between clean and cleanall Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 08/20] gnutls: use INC_PR on 2.12.5 version recipe Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 09/20] gnutls: add p11tool into gnutls-bin Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 10/20] package.bbclass: add support to split Qt translation files Saul Wold
2011-06-06 17:14   ` Richard Purdie [this message]
2011-06-06 17:27     ` Otavio Salvador
2011-06-06 19:29       ` Richard Purdie
2011-06-06  6:44 ` [CONSOLIDATED PULL 11/20] xf86-driver-common.inc: remove .la files to avoid unpackaged warning Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 12/20] gcc-package-cross: also install the symlinks in libexec with target prefix Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 13/20] shadow: recipe and patch cleanup Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 14/20] shadow: add a -native recipe with customized utilities Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 15/20] base-passwd: populate the target sysroot with passwd/group/login.defs Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 16/20] useradd.bbclass: new class for managing user/group permissions Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 17/20] useradd-example: example recipe for using inherit useradd Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 18/20] bitbake.conf: set PSEUDO_PASSWD within FAKEROOTENV Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 19/20] package_rpm.bbclass: make RPM use on-disk permissions Saul Wold
2011-06-06  6:44 ` [CONSOLIDATED PULL 20/20] tzcode: Update to 2011g Saul Wold
2011-06-07 20:40 ` [CONSOLIDATED PULL 00/20] 05-June-2011 Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307380473.7672.30.camel@rex \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.