diff options
-rw-r--r-- | meta/classes/libc-package.bbclass | 96 |
1 files changed, 45 insertions, 51 deletions
diff --git a/meta/classes/libc-package.bbclass b/meta/classes/libc-package.bbclass index bb4ba682dc..51edba2e3f 100644 --- a/meta/classes/libc-package.bbclass +++ b/meta/classes/libc-package.bbclass | |||
@@ -207,40 +207,30 @@ python package_do_split_gconvs () { | |||
207 | 207 | ||
208 | dot_re = re.compile("(.*)\.(.*)") | 208 | dot_re = re.compile("(.*)\.(.*)") |
209 | 209 | ||
210 | #GLIBC_GENERATE_LOCALES var specifies which locales to be supported, empty or "all" means all locales | 210 | # Read in supported locales and associated encodings |
211 | if use_bin != "precompiled": | 211 | supported = {} |
212 | supported = d.getVar('GLIBC_GENERATE_LOCALES', True) | 212 | with open(base_path_join(d.getVar('WORKDIR', True), "SUPPORTED")) as f: |
213 | if not supported or supported == "all": | 213 | for line in f.readlines(): |
214 | f = open(base_path_join(d.getVar('WORKDIR', True), "SUPPORTED"), "r") | 214 | try: |
215 | supported = f.readlines() | 215 | locale, charset = line.rstrip().split() |
216 | f.close() | 216 | except ValueError: |
217 | else: | 217 | continue |
218 | supported = supported.split() | 218 | supported[locale] = charset |
219 | supported = map(lambda s:s.replace(".", " ") + "\n", supported) | 219 | |
220 | # GLIBC_GENERATE_LOCALES var specifies which locales to be generated. empty or "all" means all locales | ||
221 | to_generate = d.getVar('GLIBC_GENERATE_LOCALES', True) | ||
222 | if not to_generate or to_generate == 'all': | ||
223 | to_generate = supported.keys() | ||
220 | else: | 224 | else: |
221 | supported = [] | 225 | to_generate = to_generate.split() |
222 | full_bin_path = d.getVar('PKGD', True) + binary_locales_dir | 226 | for locale in to_generate: |
223 | for dir in os.listdir(full_bin_path): | 227 | if locale not in supported: |
224 | dbase = dir.split(".") | 228 | if '.' in locale: |
225 | d2 = " " | 229 | charset = locale.split('.')[1] |
226 | if len(dbase) > 1: | 230 | else: |
227 | d2 = "." + dbase[1].upper() + " " | 231 | charset = 'UTF-8' |
228 | supported.append(dbase[0] + d2) | 232 | bb.warn("Unsupported locale '%s', assuming encoding '%s'" % (locale, charset)) |
229 | 233 | supported[locale] = charset | |
230 | # Collate the locales by base and encoding | ||
231 | utf8_only = int(d.getVar('LOCALE_UTF8_ONLY', True) or 0) | ||
232 | encodings = {} | ||
233 | for l in supported: | ||
234 | l = l[:-1] | ||
235 | (locale, charset) = l.split(" ") | ||
236 | if utf8_only and charset != 'UTF-8': | ||
237 | continue | ||
238 | m = dot_re.match(locale) | ||
239 | if m: | ||
240 | locale = m.group(1) | ||
241 | if not encodings.has_key(locale): | ||
242 | encodings[locale] = [] | ||
243 | encodings[locale].append(charset) | ||
244 | 234 | ||
245 | def output_locale_source(name, pkgname, locale, encoding): | 235 | def output_locale_source(name, pkgname, locale, encoding): |
246 | d.setVar('RDEPENDS_%s' % pkgname, 'localedef %s-localedata-%s %s-charmap-%s' % \ | 236 | d.setVar('RDEPENDS_%s' % pkgname, 'localedef %s-localedata-%s %s-charmap-%s' % \ |
@@ -271,7 +261,7 @@ python package_do_split_gconvs () { | |||
271 | 261 | ||
272 | use_cross_localedef = d.getVar("LOCALE_GENERATION_WITH_CROSS-LOCALEDEF", True) or "0" | 262 | use_cross_localedef = d.getVar("LOCALE_GENERATION_WITH_CROSS-LOCALEDEF", True) or "0" |
273 | if use_cross_localedef == "1": | 263 | if use_cross_localedef == "1": |
274 | target_arch = d.getVar('TARGET_ARCH', True) | 264 | target_arch = d.getVar('TARGET_ARCH', True) |
275 | locale_arch_options = { \ | 265 | locale_arch_options = { \ |
276 | "arm": " --uint32-align=4 --little-endian ", \ | 266 | "arm": " --uint32-align=4 --little-endian ", \ |
277 | "powerpc": " --uint32-align=4 --big-endian ", \ | 267 | "powerpc": " --uint32-align=4 --big-endian ", \ |
@@ -334,25 +324,29 @@ python package_do_split_gconvs () { | |||
334 | bb.note("preparing tree for binary locale generation") | 324 | bb.note("preparing tree for binary locale generation") |
335 | bb.build.exec_func("do_prep_locale_tree", d) | 325 | bb.build.exec_func("do_prep_locale_tree", d) |
336 | 326 | ||
337 | # Reshuffle names so that UTF-8 is preferred over other encodings | 327 | utf8_only = int(d.getVar('LOCALE_UTF8_ONLY', True) or 0) |
338 | non_utf8 = [] | 328 | encodings = {} |
339 | for l in encodings.keys(): | 329 | for locale in to_generate: |
340 | if len(encodings[l]) == 1: | 330 | charset = supported[locale] |
341 | output_locale(l, l, encodings[l][0]) | 331 | if utf8_only and charset != 'UTF-8': |
342 | if encodings[l][0] != "UTF-8": | 332 | continue |
343 | non_utf8.append(l) | 333 | |
334 | m = dot_re.match(locale) | ||
335 | if m: | ||
336 | base = m.group(1) | ||
344 | else: | 337 | else: |
345 | if "UTF-8" in encodings[l]: | 338 | base = locale |
346 | output_locale(l, l, "UTF-8") | ||
347 | encodings[l].remove("UTF-8") | ||
348 | else: | ||
349 | non_utf8.append(l) | ||
350 | for e in encodings[l]: | ||
351 | output_locale('%s.%s' % (l, e), l, e) | ||
352 | 339 | ||
353 | if non_utf8 != [] and use_bin != "precompiled": | 340 | # Precompiled locales are kept as is, obeying SUPPORTED, while |
354 | bb.note("the following locales are supported only in legacy encodings:") | 341 | # others are adjusted, ensuring that the non-suffixed locales |
355 | bb.note(" " + " ".join(non_utf8)) | 342 | # are utf-8, while the suffixed are not. |
343 | if use_bin == "precompiled": | ||
344 | output_locale(locale, base, charset) | ||
345 | else: | ||
346 | if charset == 'UTF-8': | ||
347 | output_locale(base, base, charset) | ||
348 | else: | ||
349 | output_locale('%s.%s' % (base, charset), base, charset) | ||
356 | 350 | ||
357 | if use_bin == "compile": | 351 | if use_bin == "compile": |
358 | makefile = base_path_join(d.getVar("WORKDIR", True), "locale-tree", "Makefile") | 352 | makefile = base_path_join(d.getVar("WORKDIR", True), "locale-tree", "Makefile") |