From 0f8d3897ffdd3e63f5c3b45d2aedbdcc5fd83b3c Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 26 Mar 2009 20:36:48 +0000 Subject: [PATCH] Merged from trunk -r13139:13144 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit | 13140 | Fix argument validation to allow file paths. Thanks to | | zmedico | Arfrever for reporting. | | 13141 | Add a temporary workaround for bug #263081 (partially | | zmedico | reverts r12757). | | 13142 | Remove pointless usage of xrange(). Thanks to Douglass | | zmedico | Anderson for this patch. | | 13143 | Inside config.environ(), skip stat call on $T/environment | | zmedico | for phases such as 'clean' and 'depend' where environment | | | filtering isn't needed. Thanks to Piotr Jaroszyński | | | for reporting. | | 13144 | Inside spawn(), avoid redundant os.access() and stat() calls | | zmedico | on commonly spawned binaries such as BASH_BINARY, | | | SANDBOX_BINARY, and FAKEROOT_BINARY. Thanks to Piotr | | | Jaroszyński for reporting. | svn path=/main/branches/prefix/; revision=13191 --- pym/_emerge/__init__.py | 7 +++++++ pym/portage/__init__.py | 15 ++++++++------- pym/portage/cache/sqlite.py | 12 ++++++++++++ pym/portage/process.py | 3 ++- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 04da57442..d78dea91a 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -15759,6 +15759,13 @@ def emerge_main(): if x.startswith(SETPREFIX) or \ is_valid_package_atom(x): continue + if x[:1] == os.sep: + continue + try: + os.lstat(x) + continue + except OSError: + pass msg = [] msg.append("'%s' is not a valid package atom." % (x,)) msg.append("Please check ebuild(5) for full details.") diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index a4f0c39dd..1d5c0b482 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1365,9 +1365,9 @@ class config(object): rawpkeywords = [grabdict_package( os.path.join(x, "package.keywords"), recursive=1) \ for x in self.profiles] - for i in xrange(len(self.profiles)): + for pkeyworddict in rawpkeywords: cpdict = {} - for k, v in rawpkeywords[i].iteritems(): + for k, v in pkeyworddict.iteritems(): cpdict.setdefault(dep_getkey(k), {})[k] = v self._pkeywords_list.append(cpdict) @@ -3006,11 +3006,13 @@ class config(object): mydict={} environ_filter = self._environ_filter + phase = self.get('EBUILD_PHASE') filter_calling_env = False - temp_dir = self.get("T") - if temp_dir is not None and \ - os.path.exists(os.path.join(temp_dir, "environment")): - filter_calling_env = True + if phase not in ('clean', 'cleanrm', 'depend'): + temp_dir = self.get('T') + if temp_dir is not None and \ + os.path.exists(os.path.join(temp_dir, 'environment')): + filter_calling_env = True environ_whitelist = self._environ_whitelist env_d = self.configdict["env.d"] @@ -3036,7 +3038,6 @@ class config(object): mydict["HOME"]=mydict["BUILD_PREFIX"][:] if filter_calling_env: - phase = self.get("EBUILD_PHASE") if phase: whitelist = [] if "rpm" == phase: diff --git a/pym/portage/cache/sqlite.py b/pym/portage/cache/sqlite.py index aa5c30468..6588b3cc7 100644 --- a/pym/portage/cache/sqlite.py +++ b/pym/portage/cache/sqlite.py @@ -164,6 +164,18 @@ class database(fs_template.FsBased): if k not in internal_columns: d[k] = result[0][column_index] + # As a temporary workaround for bug #263081, convert unicode strings + # to raw byte strings. This helps to potential unicode errors that can + # be triggered elsewhere when attempting to join unicode strings with + # raw byte strings. TODO: Convert all string handling code to use + # unicode strings instead of raw byte strings (required for py3k + # compatibility). + for k, v in d.iteritems(): + try: + d[k] = str(v) + except UnicodeEncodeError: + pass + return d def _setitem(self, cpv, values): diff --git a/pym/portage/process.py b/pym/portage/process.py index 6f449c3d6..a88f5bf28 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -181,7 +181,8 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, # If an absolute path to an executable file isn't given # search for it unless we've been told not to. binary = mycommand[0] - if (not os.path.isabs(binary) or not os.path.isfile(binary) + if binary not in (BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY) and \ + (not os.path.isabs(binary) or not os.path.isfile(binary) or not os.access(binary, os.X_OK)): binary = path_lookup and find_binary(binary) or None if not binary: -- 2.26.2