def _check_locale(silent): """ The inner locale check function. """ libc_fn = find_library("c") if libc_fn is None: return None libc = LoadLibrary(libc_fn) if libc is None: return None lc = list(range(ord('a'), ord('z') + 1)) uc = list(range(ord('A'), ord('Z') + 1)) rlc = [libc.tolower(c) for c in uc] ruc = [libc.toupper(c) for c in lc] if lc != rlc or uc != ruc: if silent: return False msg = ("WARNING: The LC_CTYPE variable is set to a locale " + "that specifies transformation between lowercase " + "and uppercase ASCII characters that is different than " + "the one specified by POSIX locale. This can break " + "ebuilds and cause issues in programs that rely on " + "the common character conversion scheme. " + "Please consider enabling another locale (such as " + "en_US.UTF-8) in /etc/locale.gen and setting it " + "as LC_CTYPE in make.conf.") msg = [l for l in textwrap.wrap(msg, 70)] msg.append("") chars = lambda l: ''.join(chr(x) for x in l) if uc != ruc: msg.extend([ " %s -> %s" % (chars(lc), chars(ruc)), " %28s: %s" % ('expected', chars(uc)) ]) if lc != rlc: msg.extend([ " %s -> %s" % (chars(uc), chars(rlc)), " %28s: %s" % ('expected', chars(lc)) ]) writemsg_level("".join(["!!! %s\n" % l for l in msg]), level=logging.ERROR, noiselevel=-1) return False return True
def _check_locale(silent): """ The inner locale check function. """ libc_fn = find_library("c") if libc_fn is None: return None libc = LoadLibrary(libc_fn) if libc is None: return None lc = list(range(ord('a'), ord('z')+1)) uc = list(range(ord('A'), ord('Z')+1)) rlc = [libc.tolower(c) for c in uc] ruc = [libc.toupper(c) for c in lc] if lc != rlc or uc != ruc: if silent: return False msg = ("WARNING: The LC_CTYPE variable is set to a locale " + "that specifies transformation between lowercase " + "and uppercase ASCII characters that is different than " + "the one specified by POSIX locale. This can break " + "ebuilds and cause issues in programs that rely on " + "the common character conversion scheme. " + "Please consider enabling another locale (such as " + "en_US.UTF-8) in /etc/locale.gen and setting it " + "as LC_CTYPE in make.conf.") msg = [l for l in textwrap.wrap(msg, 70)] msg.append("") chars = lambda l: ''.join(chr(x) for x in l) if uc != ruc: msg.extend([ " %s -> %s" % (chars(lc), chars(ruc)), " %28s: %s" % ('expected', chars(uc))]) if lc != rlc: msg.extend([ " %s -> %s" % (chars(uc), chars(rlc)), " %28s: %s" % ('expected', chars(lc))]) writemsg_level("".join(["!!! %s\n" % l for l in msg]), level=logging.ERROR, noiselevel=-1) return False return True