public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/package/ebuild/_config/, bin/, ...
Date: Mon, 22 Jul 2013 18:08:27 +0000 (UTC)	[thread overview]
Message-ID: <1374516489.56f416255d0fd5ccf29c08af2eb983080be40dc4.zmedico@gentoo> (raw)

commit:     56f416255d0fd5ccf29c08af2eb983080be40dc4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 22 18:08:09 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 22 18:08:09 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=56f41625

inherit: optimize eclass search

Use PORTAGE_ECLASS_LOCATIONS variable ordered so that we can break out
of the eclass search loop as soon as the first match is found.

---
 bin/ebuild.sh                                          |  8 +++++---
 bin/phase-functions.sh                                 |  1 +
 pym/portage/__init__.py                                |  4 ++++
 pym/portage/eclass_cache.py                            | 14 +++++++++++++-
 pym/portage/package/ebuild/_config/special_env_vars.py |  2 +-
 pym/portage/package/ebuild/config.py                   |  5 +----
 pym/portage/package/ebuild/doebuild.py                 |  1 +
 7 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index fc7fd9e..7ef8a76 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -207,7 +207,6 @@ inherit() {
 			| fmt -w 75 | while read -r ; do eqawarn "$REPLY" ; done
 	fi
 
-	local repo
 	local repo_location
 	local location
 	local potential_location
@@ -246,12 +245,12 @@ inherit() {
 			fi
 		fi
 
-		for repo in $(__repo_key ${PORTAGE_REPO_NAME} masters) ${PORTAGE_REPO_NAME} $(__repo_key ${PORTAGE_REPO_NAME} eclass-overrides); do
-			repo_location="$(__repo_key ${repo} location)"
+		for repo_location in ${PORTAGE_ECLASS_LOCATIONS[@]}; do
 			potential_location="${repo_location}/eclass/${1}.eclass"
 			if [[ -f ${potential_location} ]]; then
 				location="${potential_location}"
 				debug-print "  eclass exists: ${location}"
+				break
 			fi
 		done
 		debug-print "inherit: $1 -> $location"
@@ -515,6 +514,9 @@ if ___eapi_enables_globstar; then
 	shopt -s globstar
 fi
 
+# Convert quoted paths to array.
+eval "PORTAGE_ECLASS_LOCATIONS=(${PORTAGE_ECLASS_LOCATIONS})"
+
 # Source the ebuild every time for FEATURES=noauto, so that ebuild
 # modifications take effect immediately.
 if ! has "$EBUILD_PHASE" clean cleanrm ; then

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 8a52f30..37503bf 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -20,6 +20,7 @@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC \
 	PORTAGE_BUILD_USER PORTAGE_BUNZIP2_COMMAND \
 	PORTAGE_BZIP2_COMMAND PORTAGE_COLORMAP PORTAGE_CONFIGROOT \
 	PORTAGE_DEBUG PORTAGE_DEPCACHEDIR PORTAGE_EBUILD_EXIT_FILE \
+	PORTAGE_ECLASS_LOCATIONS \
 	PORTAGE_GID PORTAGE_GRPNAME PORTAGE_INST_GID PORTAGE_INST_UID \
 	PORTAGE_INTERNAL_CALLER PORTAGE_IPC_DAEMON PORTAGE_IUSE PORTAGE_LOG_FILE \
 	PORTAGE_MUTABLE_FILTERED_VARS PORTAGE_OVERRIDE_EPREFIX \

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 51aa61b..13a34e6 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -404,12 +404,16 @@ def _get_stdin():
 		return sys.__stdin__
 	return sys.stdin
 
+_shell_quote_re = re.compile(r"[\s><=*\\\"'$`]")
+
 def _shell_quote(s):
 	"""
 	Quote a string in double-quotes and use backslashes to
 	escape any backslashes, double-quotes, dollar signs, or
 	backquotes in the string.
 	"""
+	if _shell_quote_re.search(s) is None:
+		return s
 	for letter in "\\\"$`":
 		if letter in s:
 			s = s.replace(letter, "\\" + letter)

diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index cb2cf8a..8c209c8 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -1,7 +1,9 @@
-# Copyright 2005-2011 Gentoo Foundation
+# Copyright 2005-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # Author(s): Nicholas Carpaski (carpaski@gentoo.org), Brian Harring (ferringb@gentoo.org)
 
+from __future__ import unicode_literals
+
 __all__ = ["cache"]
 
 import stat
@@ -12,6 +14,7 @@ import errno
 from portage.exception import FileNotFound, PermissionDenied
 from portage import os
 from portage import checksum
+from portage import _shell_quote
 
 if sys.hexversion >= 0x3000000:
 	long = int
@@ -60,6 +63,7 @@ class cache(object):
 
 		self.eclasses = {} # {"Name": hashed_path}
 		self._eclass_locations = {}
+		self._eclass_locations_str = None
 
 		# screw with the porttree ordering, w/out having bash inherit match it, and I'll hurt you.
 		# ~harring
@@ -98,6 +102,7 @@ class cache(object):
 		self.porttrees = self.porttrees + other.porttrees
 		self.eclasses.update(other.eclasses)
 		self._eclass_locations.update(other._eclass_locations)
+		self._eclass_locations_str = None
 
 	def update_eclasses(self):
 		self.eclasses = {}
@@ -169,3 +174,10 @@ class cache(object):
 			ec_dict[x] = self.eclasses[x]
 
 		return ec_dict
+
+	@property
+	def eclass_locations_string(self):
+		if self._eclass_locations_str is None:
+			self._eclass_locations_str = " ".join(_shell_quote(x)
+				for x in reversed(self.porttrees))
+		return self._eclass_locations_str

diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py
index 35f80e3..2855722 100644
--- a/pym/portage/package/ebuild/_config/special_env_vars.py
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py
@@ -66,7 +66,7 @@ environ_whitelist += [
 	"PORTAGE_GID", "PORTAGE_GRPNAME",
 	"PORTAGE_INTERNAL_CALLER",
 	"PORTAGE_INST_GID", "PORTAGE_INST_UID",
-	"PORTAGE_IPC_DAEMON", "PORTAGE_IUSE",
+	"PORTAGE_IPC_DAEMON", "PORTAGE_IUSE", "PORTAGE_ECLASS_LOCATIONS",
 	"PORTAGE_LOG_FILE", "PORTAGE_OVERRIDE_EPREFIX", "PORTAGE_PIPE_FD",
 	"PORTAGE_PYM_PATH", "PORTAGE_PYTHON",
 	"PORTAGE_PYTHONPATH", "PORTAGE_QUIET",

diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 5066008..6871bdf 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -524,13 +524,10 @@ class config(object):
 
 			new_ov = []
 			if portdir_overlay:
-				shell_quote_re = re.compile(r"[\s\\\"'$`]")
 				for ov in portdir_overlay:
 					ov = normalize_path(ov)
 					if isdir_raise_eaccess(ov):
-						if shell_quote_re.search(ov) is not None:
-							ov = portage._shell_quote(ov)
-						new_ov.append(ov)
+						new_ov.append(portage._shell_quote(ov))
 					else:
 						writemsg(_("!!! Invalid PORTDIR_OVERLAY"
 							" (not a dir): '%s'\n") % ov, noiselevel=-1)

diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 9db600e..00159a5 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -305,6 +305,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
 	if hasattr(mydbapi, 'repositories'):
 		repo = mydbapi.repositories.get_repo_for_location(mytree)
 		mysettings['PORTDIR'] = repo.eclass_db.porttrees[0]
+		mysettings['PORTAGE_ECLASS_LOCATIONS'] = repo.eclass_db.eclass_locations_string
 		mysettings['PORTAGE_REPOSITORIES'] = mydbapi.repositories.config_string()
 		mysettings.configdict["pkg"]["PORTAGE_REPO_NAME"] = repo.name
 


             reply	other threads:[~2013-07-22 18:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 18:08 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-07-13  5:33 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/package/ebuild/_config/, bin/, Arfrever Frehtes Taifersar Arahesis
2012-11-16  4:38 Arfrever Frehtes Taifersar Arahesis
2012-08-29 16:28 Zac Medico
2012-01-08  6:22 Arfrever Frehtes Taifersar Arahesis
2011-12-11  6:52 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374516489.56f416255d0fd5ccf29c08af2eb983080be40dc4.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox