From c2a7c008e17248edaf454c0911fcbb6acc513e5e Mon Sep 17 00:00:00 2001 From: Jonathan GUILLOT Date: Wed, 6 Dec 2023 16:03:47 +0000 Subject: lib/oe/package: add LOCALE_PATHS to add define all locations for locales 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. (From OE-Core rev: 0ffc7cf01225743789ac30dd325fca05b9203be1) Signed-off-by: Jonathan GUILLOT Signed-off-by: Richard Purdie --- 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)) -- cgit v1.2.3-54-g00ecf