summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-04-27 23:48:24 -0700
committerZac Medico <zmedico@gentoo.org>2010-04-27 23:48:24 -0700
commitaab8d3dca843e07866755fc821b9bc9d5004bde5 (patch)
tree487f37f0b6950c12a2a3f9a27498c5b61607553f
parentc07dfc43dd426962e44ae3bd46ade3fac2acb362 (diff)
downloadportage-aab8d3dca843e07866755fc821b9bc9d5004bde5.tar.gz
portage-aab8d3dca843e07866755fc821b9bc9d5004bde5.tar.bz2
portage-aab8d3dca843e07866755fc821b9bc9d5004bde5.zip
Bug #315741 and bug #315709 - Handle whitespace and unicode in
PORTDIR_OVERLAY paths.
-rwxr-xr-xbin/ebuild26
1 files changed, 21 insertions, 5 deletions
diff --git a/bin/ebuild b/bin/ebuild
index 40a2ba968..7d543a109 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -70,6 +70,10 @@ except ImportError:
import portage
from portage import os
+from portage import _encodings
+from portage import _shell_quote
+from portage import _unicode_decode
+from portage import _unicode_encode
if not opts.ignore_default_opts:
default_opts = portage.settings.get("EBUILD_DEFAULT_OPTS", "").split()
@@ -116,9 +120,13 @@ if not os.path.isabs(ebuild):
# Try to get the non-canonical path from the PWD evironment variable, since
# the canonical path returned from os.getcwd() may may be unusable in
# cases where the directory stucture is built from symlinks.
- if "PWD" in os.environ and os.environ["PWD"] != mycwd and \
- os.path.realpath(os.environ["PWD"]) == mycwd:
- mycwd = portage.normalize_path(os.environ["PWD"])
+ pwd = os.environ.get('PWD', '')
+ if sys.hexversion < 0x3000000:
+ pwd = _unicode_decode(pwd, encoding=_encodings['content'],
+ errors='strict')
+ if pwd and pwd != mycwd and \
+ os.path.realpath(pwd) == mycwd:
+ mycwd = portage.normalize_path(pwd)
ebuild = os.path.join(mycwd, ebuild)
ebuild = portage.normalize_path(ebuild)
# portdbapi uses the canonical path for the base of the portage tree, but
@@ -129,8 +137,16 @@ ebuild = os.path.join(ebuild_portdir, *ebuild.split(os.path.sep)[-3:])
# Make sure that portdb.findname() returns the correct ebuild.
if ebuild_portdir not in portage.portdb.porttrees:
- os.environ["PORTDIR_OVERLAY"] = \
- os.environ.get("PORTDIR_OVERLAY","") + " " + ebuild_portdir
+ if sys.hexversion >= 0x3000000:
+ os.environ["PORTDIR_OVERLAY"] = \
+ os.environ.get("PORTDIR_OVERLAY","") + \
+ " " + _shell_quote(ebuild_portdir)
+ else:
+ os.environ["PORTDIR_OVERLAY"] = \
+ os.environ.get("PORTDIR_OVERLAY","") + \
+ " " + _unicode_encode(_shell_quote(ebuild_portdir),
+ encoding=_encodings['content'], errors='strict')
+
print("Appending %s to PORTDIR_OVERLAY..." % ebuild_portdir)
portage.close_portdbapi_caches()
imp.reload(portage)