Some packages may contain localized files not located in
${datadir}/locale. This new variables allows to add these directories in
dedicated locale packages.

Signed-off-by: Jonathan GUILLOT <[email protected]>
---
 meta/conf/documentation.conf |  1 +
 meta/lib/oe/package.py       | 23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 486c62b6e8..336bddc9d8 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_EXTRA_PATHS[doc] = "Whitespace separated list of paths extending base 
${datadir}/locale that are scanned to construct locale packages."
 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 2f7a50e144..4718082bcd 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -653,24 +653,37 @@ def split_locales(d):
     except ValueError:
         locale_index = len(packages)
 
-    localedir = os.path.join(dvar + datadir, 'locale')
+    localedirs = [os.path.join(dvar + datadir, 'locale')]
 
-    if not cpath.isdir(localedir):
+    for localedir in (d.getVar('LOCALE_EXTRA_PATHS') or "").split():
+        localedirs.append(dvar + localedir)
+
+    locales = set()
+    locale_found = False
+    for localedir in localedirs:
+        if cpath.isdir(localedir):
+            locale_found = True
+            locales.update(os.listdir(localedir))
+
+    if not locale_found:
         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')
     mlprefix = d.getVar('MLPREFIX') or ""
+    dvar_len = len(dvar)
     for l in sorted(locales):
         ln = legitimize_package_name(l)
         pkg = pn + '-locale-' + ln
         packages.insert(locale_index, pkg)
         locale_index += 1
-        d.setVar('FILES:' + pkg, os.path.join(datadir, 'locale', l))
+        files = []
+        for localedir in localedirs:
+            # Remove dvar prefix
+            files.append(os.path.join(localedir[dvar_len:], 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


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#193326): 
https://lists.openembedded.org/g/openembedded-core/message/193326
Mute This Topic: https://lists.openembedded.org/mt/103522631/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to