lib/oe/package: allow to scan extra directories for locale files
v2 cover lib/oe/package: allow to scan extra directories for locale files
Ok, let's try it one more time with suggestions proposed:
- Add "Signed-off-by" to the commits ;
- Fix the subject of the cover letter.
----
Just playing with cups and observe the main packages includes localized HTML templates in /usr/share/cups/templates. Locale packages were only looking for files in /usr/locale. This serie of patches allows to add extra directories to be scanned. For a next patch, I would also like possible FILES:${PN}-locale-* variables defined in recipe not to be overriden by the split_locales() function.
It is my first patch proposal on this project. Thanks in advance for your feedbacks.
Regards,
Jonathan GUILLOT
Jonathan GUILLOT (3):
lib/oe/package: replace in place PN-locale-* packages in PACKAGES lib/oe/package: add LOCALEEXTRADIRS to define extra locations for
locales
cups: use LOCALEEXTRADIRS to split localized HTML templates
meta/lib/oe/package.py | 33 ++++++++++++++++++++++------- meta/recipes-extended/cups/cups.inc | 2 ++ 2 files changed, 27 insertions(+), 8 deletions(-)
base-commit: 41390f5202a6ee7472cb82d12c7c32f89d6e52ff
Signature · 1 line
2.43.0
PATCH v2 1/3 lib/oe/package: replace in place PN-locale-* packages in PACKAGES
split_locales() removes PN-locale from PACKAGES and adds PN-locale-* to the end. As the PN-locale package typically appears before PN base package, it may result in paths not installed in PN-locale-* packages if already catched by PN. Now insert PN-locale-* exactly where PN-locale was existing in list to avoid such an issue.
--- meta/lib/oe/package.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
meta/lib/oe/package.py +7 -3
@@ -647,8 +647,11 @@ def split_locales(d): dvar = d.getVar('PKGD') pn = d.getVar('LOCALEBASEPN') - if pn + '-locale' in packages: - packages.remove(pn + '-locale') + try: + locale_index = packages.index(pn + '-locale') + packages.pop(locale_index) + except ValueError: + locale_index = len(packages) localedir = os.path.join(dvar + datadir, 'locale')
@@ -665,7 +668,8 @@ def split_locales(d): for l in sorted(locales): ln = legitimize_package_name(l) pkg = pn + '-locale-' + ln - packages.append(pkg) + packages.insert(locale_index, pkg) + locale_index += 1 d.setVar('FILES:' + pkg, os.path.join(datadir, 'locale', l)) d.setVar('RRECOMMENDS:' + pkg, '%svirtual-locale-%s' % (mlprefix, ln)) d.setVar('RPROVIDES:' + pkg, '%s-locale %s%s-translation' % (pn, mlprefix, ln))
Signature · 1 line
2.43.0
PATCH v2 2/3 lib/oe/package: add LOCALEEXTRADIRS to define extra locations for locales
In reply to Jonathan GUILLOTSome packages may contain localized files not located in /usr/share/locale. This new variables allows to add these directories in dedicated locale packages.
--- meta/lib/oe/package.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
meta/lib/oe/package.py +18 -5
@@ -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('LOCALEEXTRADIRS') 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))
Signature · 1 line
2.43.0
Re: [OE-core] [PATCH v2 2/3] lib/oe/package: add LOCALEEXTRADIRS to define extra locations for locales
Quoted 4 lines · Jonathan GUILLOT
Some packages may contain localized files not located in
/usr/share/locale. This new variables allows to add these directories in dedicated locale packages.
I think using _ to separate the words would make it more readable so call it LOCALE_EXTRA_PATHS or something.
secondly, it needs to be documented as well.
Quoted 66 lines
Signed-off-by Jonathan GUILLOT <[email protected]>--- meta/lib/oe/package.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)meta/lib/oe/package.py +18
-6@@ -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('LOCALEEXTRADIRS') 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 (#192302): https://lists.openembedded.org/g/openembedded-core/message/192302
Mute This Topic: https://lists.openembedded.org/mt/103150560/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [OE-core] [PATCH v2 2/3] lib/oe/package: add LOCALEEXTRADIRS to define extra locations for locales
Hi Khem Raj,
Quoted 3 lines · Khem Raj
I think using _ to separate the words would make it more readable so call it
LOCALE_EXTRA_PATHSor something.
secondly, it needs to be documented as well.
The naming LOCALEEXTRADIRS is inspired from existing FILESEXTRAPATHS. Is there some guidelines for variable naming?
Definitely, I should add a bit of documentation.
Re: [OE-core] [PATCH v2 2/3] lib/oe/package: add LOCALEEXTRADIRS to define extra locations for locales
Quoted 10 lines · Jonathan GUILLOT
Hi Khem Raj,
Quoted 3 lines · Khem Raj
I think using _ to separate the words would make it more readable so call it
LOCALE_EXTRA_PATHSor something.
secondly, it needs to be documented as well.The naming LOCALEEXTRADIRS is inspired from existing FILESEXTRAPATHS. Is there some guidelines for variable naming?
We used this convention when we used '_' as an override separator. That constainst is no more as we use ':' now.
Quoted 1 line
Definitely, I should add a bit of documentation.
Re: [OE-core] [PATCH v2 2/3] lib/oe/package: add LOCALEEXTRADIRS to define extra locations for locales
Hi,
I am just looking to existing variables to add documentation for LOCALE_EXTRA_PATHS and it makes me think about separator to use. FILESEXTRAPATHS use ':' between each path, PACKAGE_FEED_BASE_PATHS uses simple space ' ' and PSEUDO_IGNORE_PATHS is comma-separated list. What is the best option here?
Regards,
Jonathan GUILLOT
Quoted 4 lines · Khem Raj
We used this convention when we used '_' as an override separator. That constainst is no more as we use ':' now.
PATCH v2 3/3 cups: use LOCALEEXTRADIRS to split localized HTML templates
In reply to Jonathan GUILLOTLocalized HTML templates in /usr/share/cups/templates are now part of locale packages.
--- meta/recipes-extended/cups/cups.inc | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-extended/cups/cups.inc +2 -0
@@ -110,6 +110,8 @@ CONFFILES:${PN} += "${sysconfdir}/cups/cupsd.conf" MULTILIB_SCRIPTS = "${PN}-dev:${bindir}/cups-config" +LOCALEEXTRADIRS = "${datadir}/cups/templates/" + SYSROOT_PREPROCESS_FUNCS += "cups_sysroot_preprocess" cups_sysroot_preprocess () { sed -i ${SYSROOT_DESTDIR}${bindir_crossscripts}/cups-config -e 's:cups_datadir=.*:cups_datadir=${datadir}/cups:' -e 's:cups_serverbin=.*:cups_serverbin=${libexecdir}/cups:'
Signature · 1 line
2.43.0