public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: "Jonathan GUILLOT" <jonathan@joggee.fr>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH v4 2/3] lib/oe/package: add LOCALE_PATHS to add define all locations for locales
Date: Wed, 6 Dec 2023 16:03:47 +0000	[thread overview]
Message-ID: <CZ36N8IH1M2X.3592B6MOWXLE9@joggee.fr> (raw)
In-Reply-To: <CZ36N8IH0R6J.ZIQATXFYOO0W@joggee.fr>

Some packages may contain localized files not located in default path
${datadir}/locale. Add the new variable LOCALE_PATHS to allow a recipe
to define extra paths or even fully override the scanned directories.
LOCALE_PATHS is set at ${datadir}/locale by default to keep the exact
same behavior for the recipes which did not need modification.

Signed-off-by: Jonathan GUILLOT <jonathan@joggee.fr>
---
 meta/classes-global/package.bbclass |  1 +
 meta/conf/documentation.conf        |  1 +
 meta/lib/oe/package.py              | 24 ++++++++++++++----------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index f56bca3542..aa1eb5e901 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -335,6 +335,7 @@ python package_convert_pr_autoinc() {
 }
 
 LOCALEBASEPN ??= "${PN}"
+LOCALE_PATHS ?= "${datadir}/locale"
 
 python package_do_split_locales() {
     oe.package.split_locales(d)
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 486c62b6e8..90d8e82932 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -271,6 +271,7 @@ LICENSE_PATH[doc] = "Path to additional licenses used during the build."
 LINUX_KERNEL_TYPE[doc] = "Defines the kernel type to be used in assembling the configuration."
 LINUX_VERSION[doc] = "The Linux version from kernel.org on which the Linux kernel image being built using the OpenEmbedded build system is based. You define this variable in the kernel recipe."
 LINUX_VERSION_EXTENSION[doc] = "A string extension compiled into the version string of the Linux kernel built with the OpenEmbedded build system. You define this variable in the kernel recipe."
+LOCALE_PATHS[doc] = "Whitespace separated list of paths that are scanned to construct locale packages. The list already contains ${datadir}/locale by default."
 LOCALE_UTF8_IS_DEFAULT[doc] = "If set, locale names are renamed such that those lacking an explicit encoding (e.g. en_US) will always be UTF-8, and non-UTF-8 encodings are renamed to, e.g., en_US.ISO-8859-1. Otherwise, the encoding is specified by glibc's SUPPORTED file. Not supported for precompiled locales."
 LOG_DIR[doc] = "Specifies the directory to which the OpenEmbedded build system writes overall log files. The default directory is ${TMPDIR}/log"
 
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index cb6893f3c2..d1738d3b61 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -639,11 +639,6 @@ def split_locales(d):
 
     packages = (d.getVar('PACKAGES') or "").split()
 
-    datadir = d.getVar('datadir')
-    if not datadir:
-        bb.note("datadir not defined")
-        return
-
     dvar = d.getVar('PKGD')
     pn = d.getVar('LOCALEBASEPN')
 
@@ -653,14 +648,20 @@ def split_locales(d):
     except ValueError:
         locale_index = len(packages)
 
-    localedir = os.path.join(dvar + datadir, 'locale')
+    localepaths = []
+    locales = set()
+    for localepath in (d.getVar('LOCALE_PATHS') or "").split():
+        localedir = dvar + localepath
+        if cpath.isdir(localedir):
+            locales.update(os.listdir(localedir))
+            localepaths.append(localepath)
+        else:
+            bb.debug(1, "No locale files in %s" % localepath)
 
-    if not cpath.isdir(localedir):
+    if len(locales) == 0:
         bb.debug(1, "No locale files in this package")
         return
 
-    locales = os.listdir(localedir)
-
     summary = d.getVar('SUMMARY') or pn
     description = d.getVar('DESCRIPTION') or ""
     locale_section = d.getVar('LOCALE_SECTION')
@@ -670,7 +671,10 @@ def split_locales(d):
         pkg = pn + '-locale-' + ln
         packages.insert(locale_index, pkg)
         locale_index += 1
-        d.setVar('FILES:' + pkg, os.path.join(datadir, 'locale', l))
+        files = []
+        for localepath in localepaths:
+            files.append(os.path.join(localepath, l))
+        d.setVar('FILES:' + pkg, " ".join(files))
         d.setVar('RRECOMMENDS:' + pkg, '%svirtual-locale-%s' % (mlprefix, ln))
         d.setVar('RPROVIDES:' + pkg, '%s-locale %s%s-translation' % (pn, mlprefix, ln))
         d.setVar('SUMMARY:' + pkg, '%s - %s translations' % (summary, l))
-- 
2.43.0




  parent reply	other threads:[~2024-02-12 14:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 14:50 [PATCH v4 0/3] lib/oe/package: allow to scan extra directories for locale files Jonathan GUILLOT
2023-11-30 12:49 ` [PATCH v4 1/3] lib/oe/package: replace in place PN-locale-* packages in PACKAGES Jonathan GUILLOT
2023-12-06 16:03 ` Jonathan GUILLOT [this message]
2023-12-06 16:06 ` [PATCH v4 3/3] cups: use LOCALE_PATHS to split localized HTML templates Jonathan GUILLOT
2024-02-15 16:27   ` [OE-core] " Ross Burton
2024-02-19 10:00     ` Jonathan GUILLOT
2024-02-19 15:10       ` 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=CZ36N8IH1M2X.3592B6MOWXLE9@joggee.fr \
    --to=jonathan@joggee.fr \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox