Patchwork [RFC] libc-package.bbclass: Improve handling of GLIBC_GENERATE_LOCALES

login
register
mail settings
Submitter Jacob Kroon
Date June 9, 2014, 7:19 a.m.
Message ID <1402298384-23611-1-git-send-email-jacob.kroon@mikrodidakt.se>
Download mbox | patch
Permalink /patch/73481/
State New
Headers show

Comments

Jacob Kroon - June 9, 2014, 7:19 a.m.
Currently, setting GLIBC_GENERATE_LOCALES to the empty string means that
all supported binary locales are generated.

Improve the situation by adding a weak assignment to "all",
in order to keep current default behaviour when GLIBC_GENERATE_LOCALES
is not set by the user, and change the code to do no special handling of
the empty string value. This makes it possible to skip generating
binary locales altogether by setting GLIBC_GENERATE_LOCALES = "".

Since locales directory can now be empty, make sure it is not packaged
in this situation.

Signed-off-by: Jacob Kroon <jacob.kroon@mikrodidakt.se>
---
 meta/classes/libc-package.bbclass | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Patch

diff --git a/meta/classes/libc-package.bbclass b/meta/classes/libc-package.bbclass
index c1bc399..c2f7f2f 100644
--- a/meta/classes/libc-package.bbclass
+++ b/meta/classes/libc-package.bbclass
@@ -2,11 +2,15 @@ 
 # This class knows how to package up [e]glibc. Its shared since prebuild binary toolchains
 # may need packaging and its pointless to duplicate this code.
 #
+# Caller should set GLIBC_GENERATE_LOCALES to a space-separated list of
+# locales to generate. "all" will generate all supported locales
+#
 # Caller should set GLIBC_INTERNAL_USE_BINARY_LOCALE to one of:
 #  "compile" - Use QEMU to generate the binary locale files
 #  "precompiled" - The binary locale files are pregenerated and already present
 #  "ondevice" - The device will build the locale files upon first boot through the postinst
 
+GLIBC_GENERATE_LOCALES ?= "all"
 GLIBC_INTERNAL_USE_BINARY_LOCALE ?= "ondevice"
 
 python __anonymous () {
@@ -111,6 +115,12 @@  do_prep_locale_tree() {
 do_collect_bins_from_locale_tree() {
 	treedir=${WORKDIR}/locale-tree
 
+	# When no binary locales are generated we return early in order
+	# to skip creating empty directories that QA will warn about.
+	if [ -z "$(ls $treedir/${localedir})" ]; then
+		return
+	fi
+
 	parent=$(dirname ${localedir})
 	mkdir -p ${PKGD}/$parent
 	tar -cf - -C $treedir/$parent -p $(basename ${localedir}) | tar -xf - -C ${PKGD}$parent
@@ -220,9 +230,8 @@  python package_do_split_gconvs () {
                 continue
             supported[locale] = charset
 
-    # GLIBC_GENERATE_LOCALES var specifies which locales to be generated. empty or "all" means all locales
     to_generate = d.getVar('GLIBC_GENERATE_LOCALES', True)
-    if not to_generate or to_generate == 'all':
+    if to_generate == 'all':
         to_generate = supported.keys()
     else:
         to_generate = to_generate.split()