aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bersenev <bay@hackerdom.ru>2014-02-17 17:55:51 +0600
committerAlexander Bersenev <bay@hackerdom.ru>2014-02-17 17:55:51 +0600
commit5a3f506c9ef1cfd78940b0509f10ef94b4434e29 (patch)
tree147c35a17a8bcd8ff467bb3063adab623da51fac /portage_with_autodep/pym/portage/__init__.py
parentfixed a deadlock (diff)
downloadautodep-5a3f506c9ef1cfd78940b0509f10ef94b4434e29.tar.gz
autodep-5a3f506c9ef1cfd78940b0509f10ef94b4434e29.tar.bz2
autodep-5a3f506c9ef1cfd78940b0509f10ef94b4434e29.zip
updated portage to 2.2.8-r1
Diffstat (limited to 'portage_with_autodep/pym/portage/__init__.py')
-rw-r--r--portage_with_autodep/pym/portage/__init__.py132
1 files changed, 89 insertions, 43 deletions
diff --git a/portage_with_autodep/pym/portage/__init__.py b/portage_with_autodep/pym/portage/__init__.py
index 2a2eb99..431dc26 100644
--- a/portage_with_autodep/pym/portage/__init__.py
+++ b/portage_with_autodep/pym/portage/__init__.py
@@ -2,7 +2,7 @@
# Copyright 1998-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-VERSION="HEAD"
+VERSION="2.2.0_alpha108"
# ===========================================================================
# START OF IMPORTS -- START OF IMPORTS -- START OF IMPORTS -- START OF IMPORT
@@ -148,20 +148,35 @@ if sys.hexversion >= 0x3000000:
basestring = str
long = int
-# Assume utf_8 fs encoding everywhere except in merge code, where the
-# user's locale is respected.
+# We use utf_8 encoding everywhere. Previously, we used
+# sys.getfilesystemencoding() for the 'merge' encoding, but that had
+# various problems:
+#
+# 1) If the locale is ever changed then it can cause orphan files due
+# to changed character set translation.
+#
+# 2) Ebuilds typically install files with utf_8 encoded file names,
+# and then portage would be forced to rename those files to match
+# sys.getfilesystemencoding(), possibly breaking things.
+#
+# 3) Automatic translation between encodings can lead to nonsensical
+# file names when the source encoding is unknown by portage.
+#
+# 4) It's inconvenient for ebuilds to convert the encodings of file
+# names to match the current locale, and upstreams typically encode
+# file names with utf_8 encoding.
+#
+# So, instead of relying on sys.getfilesystemencoding(), we avoid the above
+# problems by using a constant utf_8 'merge' encoding for all locales, as
+# discussed in bug #382199 and bug #381509.
_encodings = {
'content' : 'utf_8',
'fs' : 'utf_8',
- 'merge' : sys.getfilesystemencoding(),
+ 'merge' : 'utf_8',
'repo.content' : 'utf_8',
'stdio' : 'utf_8',
}
-# This can happen if python is built with USE=build (stage 1).
-if _encodings['merge'] is None:
- _encodings['merge'] = 'ascii'
-
if sys.hexversion >= 0x3000000:
def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):
if isinstance(s, str):
@@ -215,7 +230,7 @@ class _unicode_func_wrapper(object):
rval = self._func(*wrapped_args, **wrapped_kwargs)
# Don't use isinstance() since we don't want to convert subclasses
- # of tuple such as posix.stat_result in python-3.2.
+ # of tuple such as posix.stat_result in Python >=3.2.
if rval.__class__ in (list, tuple):
decoded_rval = []
for x in rval:
@@ -320,6 +335,16 @@ _python_interpreter = os.path.realpath(sys.executable)
_bin_path = PORTAGE_BIN_PATH
_pym_path = PORTAGE_PYM_PATH
+if sys.hexversion >= 0x3030000:
+ # Workaround for http://bugs.python.org/issue14007
+ def _test_xml_etree_ElementTree_TreeBuilder_type():
+ import subprocess
+ p = subprocess.Popen([_python_interpreter, "-c",
+ "import sys, xml.etree.ElementTree; sys.exit(not isinstance(xml.etree.ElementTree.TreeBuilder, type))"])
+ if p.wait() != 0:
+ sys.modules["_elementtree"] = None
+ _test_xml_etree_ElementTree_TreeBuilder_type()
+
def _shell_quote(s):
"""
Quote a string in double-quotes and use backslashes to
@@ -380,9 +405,12 @@ def getcwd():
return "/"
getcwd()
-def abssymlink(symlink):
+def abssymlink(symlink, target=None):
"This reads symlinks, resolving the relative symlinks, and returning the absolute."
- mylink=os.readlink(symlink)
+ if target is not None:
+ mylink = target
+ else:
+ mylink = os.readlink(symlink)
if mylink[0] != '/':
mydir=os.path.dirname(symlink)
mylink=mydir+"/"+mylink
@@ -417,29 +445,25 @@ def eapi_is_supported(eapi):
return False
return eapi <= portage.const.EAPI
-# Generally, it's best not to assume that cache entries for unsupported EAPIs
-# can be validated. However, the current package manager specification does not
-# guarantee that the EAPI can be parsed without sourcing the ebuild, so
-# it's too costly to discard existing cache entries for unsupported EAPIs.
-# Therefore, by default, assume that cache entries for unsupported EAPIs can be
-# validated. If FEATURES=parse-eapi-* is enabled, this assumption is discarded
-# since the EAPI can be determined without the incurring the cost of sourcing
-# the ebuild.
-_validate_cache_for_unsupported_eapis = True
-
-_parse_eapi_ebuild_head_re = re.compile(r'^EAPI=[\'"]?([^\'"#]*)')
-_parse_eapi_ebuild_head_max_lines = 30
+# This pattern is specified by PMS section 7.3.1.
+_pms_eapi_re = re.compile(r"^[ \t]*EAPI=(['\"]?)([A-Za-z0-9+_.-]*)\1[ \t]*([ \t]#.*)?$")
+_comment_or_blank_line = re.compile(r"^\s*(#.*)?$")
def _parse_eapi_ebuild_head(f):
- count = 0
+ eapi = None
+ eapi_lineno = None
+ lineno = 0
for line in f:
- m = _parse_eapi_ebuild_head_re.match(line)
- if m is not None:
- return m.group(1).strip()
- count += 1
- if count >= _parse_eapi_ebuild_head_max_lines:
+ lineno += 1
+ m = _comment_or_blank_line.match(line)
+ if m is None:
+ eapi_lineno = lineno
+ m = _pms_eapi_re.match(line)
+ if m is not None:
+ eapi = m.group(2)
break
- return '0'
+
+ return (eapi, eapi_lineno)
def _movefile(src, dest, **kwargs):
"""Calls movefile and raises a PortageException if an error occurs."""
@@ -461,10 +485,16 @@ def portageexit():
if data.secpass > 1 and os.environ.get("SANDBOX_ON") != "1":
close_portdbapi_caches()
-def create_trees(config_root=None, target_root=None, trees=None):
- if trees is None:
- trees = {}
- else:
+class _trees_dict(dict):
+ __slots__ = ('_running_eroot', '_target_eroot',)
+ def __init__(self, *pargs, **kargs):
+ dict.__init__(self, *pargs, **kargs)
+ self._running_eroot = None
+ self._target_eroot = None
+
+def create_trees(config_root=None, target_root=None, trees=None, env=None,
+ eprefix=None):
+ if trees is not None:
# clean up any existing portdbapi instances
for myroot in trees:
portdb = trees[myroot]["porttree"].dbapi
@@ -472,12 +502,25 @@ def create_trees(config_root=None, target_root=None, trees=None):
portdbapi.portdbapi_instances.remove(portdb)
del trees[myroot]["porttree"], myroot, portdb
+ if trees is None:
+ trees = _trees_dict()
+ elif not isinstance(trees, _trees_dict):
+ # caller passed a normal dict or something,
+ # but we need a _trees_dict instance
+ trees = _trees_dict(trees)
+
+ if env is None:
+ env = os.environ
+
settings = config(config_root=config_root, target_root=target_root,
- config_incrementals=portage.const.INCREMENTALS)
+ env=env, eprefix=eprefix)
settings.lock()
- myroots = [(settings["ROOT"], settings)]
- if settings["ROOT"] != "/":
+ trees._target_eroot = settings['EROOT']
+ myroots = [(settings['EROOT'], settings)]
+ if settings["ROOT"] == "/":
+ trees._running_eroot = trees._target_eroot
+ else:
# When ROOT != "/" we only want overrides from the calling
# environment to apply to the config that's associated
@@ -485,24 +528,27 @@ def create_trees(config_root=None, target_root=None, trees=None):
clean_env = {}
for k in ('PATH', 'PORTAGE_GRPNAME', 'PORTAGE_USERNAME',
'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'TERM',
- 'ftp_proxy', 'http_proxy', 'no_proxy'):
+ 'ftp_proxy', 'http_proxy', 'no_proxy',
+ '__PORTAGE_TEST_HARDLINK_LOCKS'):
v = settings.get(k)
if v is not None:
clean_env[k] = v
- settings = config(config_root=None, target_root="/", env=clean_env)
+ settings = config(config_root=None, target_root="/",
+ env=clean_env, eprefix=eprefix)
settings.lock()
- myroots.append((settings["ROOT"], settings))
+ trees._running_eroot = settings['EROOT']
+ myroots.append((settings['EROOT'], settings))
for myroot, mysettings in myroots:
trees[myroot] = portage.util.LazyItemsDict(trees.get(myroot, {}))
trees[myroot].addLazySingleton("virtuals", mysettings.getvirtuals)
trees[myroot].addLazySingleton(
- "vartree", vartree, myroot, categories=mysettings.categories,
+ "vartree", vartree, categories=mysettings.categories,
settings=mysettings)
trees[myroot].addLazySingleton("porttree",
- portagetree, myroot, settings=mysettings)
+ portagetree, settings=mysettings)
trees[myroot].addLazySingleton("bintree",
- binarytree, myroot, mysettings["PKGDIR"], settings=mysettings)
+ binarytree, pkgdir=mysettings["PKGDIR"], settings=mysettings)
return trees
if VERSION == 'HEAD':