From aab8d3dca843e07866755fc821b9bc9d5004bde5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 27 Apr 2010 23:48:24 -0700 Subject: Bug #315741 and bug #315709 - Handle whitespace and unicode in PORTDIR_OVERLAY paths. --- bin/ebuild | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'bin/ebuild') 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) -- cgit v1.2.3-1-g7c22