commit: 60dba091ce559d787cdcebe731f4c010aa830ac0
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 15 20:46:16 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Nov 15 21:18:48 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=60dba091
EAPI 6: Enforce LC_COLLATE=C in ebuild environment
pym/portage/eapi.py | 9 +++++++--
pym/portage/package/ebuild/config.py | 5 +++++
pym/portage/util/locale.py | 21 +++++++++++++++++++++
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 4f77910..1709026 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Gentoo Foundation
+# Copyright 2010-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import collections
@@ -68,6 +68,10 @@ def eapi_has_required_use_at_most_one_of(eapi):
def eapi_has_use_dep_defaults(eapi):
return eapi not in ("0", "1", "2", "3")
+def eapi_requires_posixish_locale(eapi):
+ return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi",
+ "5", "5-progress", "5-hdepend")
+
def eapi_has_repo_deps(eapi):
return eapi in ("4-python", "5-progress")
@@ -98,7 +102,7 @@ def eapi_has_targetroot(eapi):
_eapi_attrs = collections.namedtuple('_eapi_attrs',
'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
'feature_flag_test feature_flag_targetroot '
- 'hdepend iuse_defaults iuse_effective '
+ 'hdepend iuse_defaults iuse_effective posixish_locale '
'repo_deps required_use required_use_at_most_one_of slot_operator
slot_deps '
'src_uri_arrows strong_blocks use_deps use_dep_defaults')
@@ -129,6 +133,7 @@ def _get_eapi_attrs(eapi):
hdepend = (eapi is not None and eapi_has_hdepend(eapi)),
iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)),
iuse_effective = (eapi is not None and
eapi_has_iuse_effective(eapi)),
+ posixish_locale = (eapi is not None and
eapi_requires_posixish_locale(eapi)),
repo_deps = (eapi is None or eapi_has_repo_deps(eapi)),
required_use = (eapi is None or eapi_has_required_use(eapi)),
required_use_at_most_one_of = (eapi is None or
eapi_has_required_use_at_most_one_of(eapi)),
diff --git a/pym/portage/package/ebuild/config.py
b/pym/portage/package/ebuild/config.py
index 40aa99d..095de37 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -24,6 +24,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.dep.soname.SonameAtom:SonameAtom',
'portage.dbapi.vartree:vartree',
'portage.package.ebuild.doebuild:_phase_func_map',
+ 'portage.util.locale:split_LC_ALL',
)
from portage import bsd_chflags, \
load_mod, os, selinux, _unicode_decode
@@ -2769,6 +2770,10 @@ class config(object):
if phase_func is not None:
mydict["EBUILD_PHASE_FUNC"] = phase_func
+ if eapi_attrs.posixish_locale:
+ split_LC_ALL(mydict)
+ mydict["LC_COLLATE"] = "C"
+
return mydict
def thirdpartymirrors(self):
diff --git a/pym/portage/util/locale.py b/pym/portage/util/locale.py
index 12161eb..d902db8 100644
--- a/pym/portage/util/locale.py
+++ b/pym/portage/util/locale.py
@@ -17,6 +17,15 @@ from portage.util import writemsg_level
from portage.util._ctypes import find_library, LoadLibrary
+locale_categories = (
+ 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_MESSAGES',
+ 'LC_NUMERIC', 'LC_TIME',
+ # GNU extensions
+ 'LC_ADDRESS', 'LC_IDENTIFICATION', 'LC_MEASUREMENT', 'LC_NAME',
+ 'LC_PAPER', 'LC_TELEPHONE',
+)
+
+
def _check_locale():
"""
The inner locale check function.
@@ -88,3 +97,15 @@ def check_locale():
if ret != 2:
return ret == 0
return None
+
+
+def split_LC_ALL(env):
+ """
+ Replace LC_ALL with split-up LC_* variables if it is defined.
+ Works on the passed environment (or settings instance).
+ """
+ lc_all = env.get("LC_ALL")
+ if lc_all is not None:
+ for c in locale_categories:
+ env[c] = lc_all
+ del env["LC_ALL"]