locale packages patch

Submitted by Colin Walters on Jan. 2, 2013, 10:50 p.m.


Message ID 1357167014.14851.18.camel@localhost
State New
Headers show

Commit Message

Colin Walters Jan. 2, 2013, 10:50 p.m.

A GNOME contributor submitted the following patch to the gnome-ostree
system (Yocto-derived base):


Any comments on whether this could be upstreamable?  While we're already
carrying a few patches to oe-core, I'd obviously like to keep them as
minimal as possible.

Hmmm...in our case, we may be able to set PACKAGE_NO_LOCALE globally to
avoid split locales?  But this patch may be more broadly useful if there
are projects that want say just all eglibc locales, but not translations
for everything.

For convenience, the full patch is attached.

Patch hide | download patch | download mbox

From 171a0fc3c034a8c723263f785c8524c263af8c4b Mon Sep 17 00:00:00 2001
From: Giovanni Campagna <gcampagna@src.gnome.org>
Date: Sun, 30 Dec 2012 18:15:14 +0100
Subject: [PATCH] Fix locale package generation

The package class has code to generate split language pack packages,
one, and each of those provides ${PN}-locale, so installing ${PN}-locale
ends up installing a language at random. Make ${PN}-locale a meta package
instead, and have it RDEPEND on the actual locale packages.
This allows a distro to install all translations without caring of which
are actually shipped by a particular package.
The dependency for individual locale packages on virtual-locale-* is
removed, to allow installing eglibc-locale-locale.alias (otherwise depending
on a non-existing virtual-locale-locale.alias)

 meta/classes/package.bbclass | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 73c4358..4258dee 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -446,17 +446,28 @@  python package_do_split_locales() {
     locale_section = d.getVar('LOCALE_SECTION', True)
     mlprefix = d.getVar('MLPREFIX', True) or ""
     pndep = base_contains('PACKAGES', pn, '%s ' % pn, '', d)
+    base_locale_pkg = pn + '-locale'
+    packages.append(base_locale_pkg)
+    d.setVar('ALLOW_EMPTY_' + base_locale_pkg, '1')
+    d.setVar('SUMMARY_' + base_locale_pkg, '%s - all translations' % (summary,))
+    d.setVar('DESCRIPTION_' + base_locale_pkg, '%s  This metapackage depends on packages providing language translation files.' % (description,))
+    d.setVar('RDEPENDS_' + base_locale_pkg, '')
+    d.setVar('FILES_' + base_locale_pkg, '')
+    if locale_section:
+        d.setVar('SECTION_' + pkg, locale_section)
     for l in sorted(locales):
         ln = legitimize_package_name(l)
         pkg = pn + '-locale-' + ln
         d.setVar('FILES_' + pkg, os.path.join(datadir, 'locale', l))
-        d.setVar('RDEPENDS_' + pkg, '%s%svirtual-locale-%s' % (pndep, mlprefix, ln))
-        d.setVar('RPROVIDES_' + pkg, '%s-locale %s%s-translation' % (pn, mlprefix, ln))
+        d.setVar('RDEPENDS_' + pkg, pndep)
         d.setVar('SUMMARY_' + pkg, '%s - %s translations' % (summary, l))
         d.setVar('DESCRIPTION_' + pkg, '%s  This package contains language translation files for the %s locale.' % (description, l))
         if locale_section:
             d.setVar('SECTION_' + pkg, locale_section)
+        d.setVar('RDEPENDS_' + base_locale_pkg, '%s %s' % (d.getVar('RDEPENDS_' + base_locale_pkg, True), pkg))
     d.setVar('PACKAGES', ' '.join(packages))