glibc-external: rename charsets to align with glibc-locale

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
This commit is contained in:
Christopher Larson
2015-07-29 12:56:09 -07:00
parent 00cafb795f
commit 140fed8a83

View File

@@ -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 () {