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/dbapi/, pym/_emerge/
Date: Wed, 23 Jan 2013 16:19:19 +0000 (UTC)	[thread overview]
Message-ID: <1358957946.9ae58b611e7a0d2080f0f48c207c7323dfa06dc3.zmedico@gentoo> (raw)

commit:     9ae58b611e7a0d2080f0f48c207c7323dfa06dc3
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 23 16:19:06 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jan 23 16:19:06 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9ae58b61

Package: filter built USE for bug #453400

The enabled flags must be consistent with implicit IUSE, in order to
avoid potential inconsistencies in USE dep matching (see bug #453400).

---
 pym/_emerge/Package.py        |   65 ++++++++++++++++++++++++-----------------
 pym/portage/dbapi/__init__.py |    4 ++-
 2 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index 09d8b93..eee41eb 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -561,7 +561,7 @@ class Package(Task):
 	@property
 	def use(self):
 		if self._use is None:
-			self._metadata._init_use()
+			self._init_use()
 		return self._use
 
 	def _get_pkgsettings(self):
@@ -570,6 +570,42 @@ class Package(Task):
 		pkgsettings.setcpv(self)
 		return pkgsettings
 
+	def _init_use(self):
+		if self.built:
+			# Use IUSE to validate USE settings for built packages,
+			# in case the package manager that built this package
+			# failed to do that for some reason (or in case of
+			# data corruption). The enabled flags must be consistent
+			# with implicit IUSE, in order to avoid potential
+			# inconsistencies in USE dep matching (see bug #453400).
+			use_str = self._metadata['USE']
+			is_valid_flag = self.iuse.is_valid_flag
+			enabled_flags = [x for x in use_str.split() if is_valid_flag(x)]
+			use_str = " ".join(enabled_flags)
+			self._use = self._use_class(
+				self, use_str)
+		else:
+			try:
+				use_str = _PackageMetadataWrapperBase.__getitem__(
+					self._metadata, 'USE')
+			except KeyError:
+				use_str = None
+			calculated_use = False
+			if not use_str:
+				use_str = self._get_pkgsettings()["PORTAGE_USE"]
+				calculated_use = True
+			_PackageMetadataWrapperBase.__setitem__(
+				self._metadata, 'USE', use_str)
+			self._use = self._use_class(
+				self, use_str)
+			# Initialize these now, since USE access has just triggered
+			# setcpv, and we want to cache the result of the force/mask
+			# calculations that were done.
+			if calculated_use:
+				self._use._init_force_mask()
+
+		return use_str
+
 	class _iuse(object):
 
 		__slots__ = ("__weakref__", "_iuse_implicit_match", "_pkg", "alias_mapping",
@@ -718,31 +754,6 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase):
 
 		self.update(metadata)
 
-	def _init_use(self):
-		if self._pkg.built:
-			use_str = self['USE']
-			self._pkg._use = self._pkg._use_class(
-				self._pkg, use_str)
-		else:
-			try:
-				use_str = _PackageMetadataWrapperBase.__getitem__(self, 'USE')
-			except KeyError:
-				use_str = None
-			calculated_use = False
-			if not use_str:
-				use_str = self._pkg._get_pkgsettings()["PORTAGE_USE"]
-				calculated_use = True
-			_PackageMetadataWrapperBase.__setitem__(self, 'USE', use_str)
-			self._pkg._use = self._pkg._use_class(
-				self._pkg, use_str)
-			# Initialize these now, since USE access has just triggered
-			# setcpv, and we want to cache the result of the force/mask
-			# calculations that were done.
-			if calculated_use:
-				self._pkg._use._init_force_mask()
-
-		return use_str
-
 	def __getitem__(self, k):
 		v = _PackageMetadataWrapperBase.__getitem__(self, k)
 		if k in self._use_conditional_keys:
@@ -760,7 +771,7 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase):
 		elif k == 'USE' and not self._pkg.built:
 			if not v:
 				# This is lazy because it's expensive.
-				v = self._init_use()
+				v = self._pkg._init_use()
 
 		return v
 

diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py
index 3540c6d..79d1e7a 100644
--- a/pym/portage/dbapi/__init__.py
+++ b/pym/portage/dbapi/__init__.py
@@ -217,7 +217,9 @@ class dbapi(object):
 			# Use IUSE to validate USE settings for built packages,
 			# in case the package manager that built this package
 			# failed to do that for some reason (or in case of
-			# data corruption).
+			# data corruption). The enabled flags must be consistent
+			# with implicit IUSE, in order to avoid potential
+			# inconsistencies in USE dep matching (see bug #453400).
 			use = frozenset(x for x in metadata["USE"].split()
 				if x in iuse or iuse_implicit_match(x))
 			missing_enabled = frozenset(x for x in


             reply	other threads:[~2013-01-23 16:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23 16:19 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-04-03 20:03 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/ Zac Medico
2015-08-30 23:44 Zac Medico
2014-11-20  4:08 Zac Medico
2014-02-24  9:23 Alexander Berntsen
2013-03-13  5:56 Zac Medico
2013-01-05 15:20 Zac Medico
2012-12-23  5:33 Arfrever Frehtes Taifersar Arahesis
2012-11-24 21:57 Zac Medico
2012-04-22 18:57 Zac Medico
2012-04-21  6:51 Zac Medico
2012-02-17 22:19 Zac Medico
2012-02-16  0:33 Zac Medico
2012-02-14 23:40 Zac Medico
2012-02-10  1:28 Zac Medico
2012-02-08  1:16 Zac Medico
2012-02-08  0:36 Zac Medico
2011-10-28  2:34 Zac Medico
2011-10-16 20:26 Zac Medico
2011-10-15  5:10 Zac Medico
2011-06-03 10:16 Zac Medico
2011-05-24  5:31 Zac Medico
2011-05-24  0:33 Zac Medico
2011-05-09  5:16 Zac Medico
2011-03-26  7:39 Zac Medico
2011-03-26  3:24 Zac Medico
2011-03-25  4:34 Zac Medico
2011-03-25  4:34 Zac Medico
2011-03-25  4:34 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=1358957946.9ae58b611e7a0d2080f0f48c207c7323dfa06dc3.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