From 140fed8a8391ea4d8fe397e4b39d869ed034bbb6 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Wed, 29 Jul 2015 12:56:09 -0700 Subject: [PATCH] glibc-external: rename charsets to align with glibc-locale Signed-off-by: Christopher Larson --- recipes-external/glibc/glibc-external.bb | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/recipes-external/glibc/glibc-external.bb b/recipes-external/glibc/glibc-external.bb index abfd558..3a21225 100644 --- a/recipes-external/glibc/glibc-external.bb +++ b/recipes-external/glibc/glibc-external.bb @@ -59,6 +59,51 @@ FILES_MIRRORS .= "\ python do_install () { bb.build.exec_func('external_toolchain_do_install', d) bb.build.exec_func('glibc_external_do_install_extra', d) + bb.build.exec_func('adjust_locale_names', d) +} + +python adjust_locale_names () { + """Align locale charset names with glibc-locale expectations.""" + # Read in supported locales and associated encodings + supported = {} + with open(base_path_join(d.getVar('WORKDIR', True), "SUPPORTED")) as f: + for line in f.readlines(): + try: + locale, charset = line.rstrip().split() + except ValueError: + 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': + to_generate = supported.keys() + else: + to_generate = to_generate.split() + for locale in to_generate: + if locale not in supported: + if '.' in locale: + charset = locale.split('.')[1] + else: + charset = 'UTF-8' + bb.warn("Unsupported locale '%s', assuming encoding '%s'" % (locale, charset)) + supported[locale] = charset + + localedir = oe.path.join(d.getVar('D', True), d.getVar('localedir', True)) + for locale in to_generate: + if '.' not in locale: + continue + + locale, charset = locale.split('.', 1) + if '-' not in charset: + continue + + oe_name = locale + '.' + charset.lower() + existing_name = locale + '.' + charset.lower().replace('-', '') + this_localedir = oe.path.join(localedir, existing_name) + if os.path.exists(this_localedir): + bb.debug(1, '%s -> %s' % (this_localedir, oe.path.join(localedir, oe_name))) + os.rename(this_localedir, oe.path.join(localedir, oe_name)) } glibc_external_do_install_extra () {