public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/resolver/
@ 2014-10-28  8:36 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2014-10-28  8:36 UTC (permalink / raw
  To: gentoo-commits

commit:     f883c84b36902afb3aecdd05c96ce6e6cd2394a6
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 27 01:39:12 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 28 08:34:33 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f883c84b

dep_zapdeps: handle circular deps with --onlydeps

This fixes a case with --onlydeps were dep_zapdeps would pull in an
avoidable direct circular dependency on an onlydeps node. The logic
changes only apply to --onlydeps, so there's no chance of regressions
for cases when --onlydeps is not enabled.

X-Gentoo-Bug: 524916
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524916
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>

---
 pym/portage/dep/dep_check.py                       |  9 ++--
 .../tests/resolver/test_onlydeps_circular.py       | 51 ++++++++++++++++++++++
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 4386b5e..9f48713 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -429,11 +429,10 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 						all_in_graph = False
 						break
 				circular_atom = None
-				if all_in_graph:
-					if parent is None or priority is None:
-						pass
-					elif priority.buildtime and \
-						not (priority.satisfied or priority.optional):
+				if not (parent is None or priority is None) and \
+					(parent.onlydeps or
+					(all_in_graph and priority.buildtime and
+					not (priority.satisfied or priority.optional))):
 						# Check if the atom would result in a direct circular
 						# dependency and try to avoid that if it seems likely
 						# to be unresolvable. This is only relevant for

diff --git a/pym/portage/tests/resolver/test_onlydeps_circular.py b/pym/portage/tests/resolver/test_onlydeps_circular.py
new file mode 100644
index 0000000..ce35cee
--- /dev/null
+++ b/pym/portage/tests/resolver/test_onlydeps_circular.py
@@ -0,0 +1,51 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import \
+	ResolverPlayground, ResolverPlaygroundTestCase
+
+class OnlydepsTestCase(TestCase):
+
+	def testOnlydeps(self):
+		ebuilds = {
+			"app-misc/A-1": {
+				"EAPI": "5",
+				"SLOT": "1",
+				"DEPEND": "|| ( app-misc/B app-misc/A:1 )"
+			},
+			"app-misc/A-2": {
+				"EAPI": "5",
+				"SLOT": "2",
+			},
+			"app-misc/B-0": {
+				"EAPI": "5",
+			}
+		}
+
+		installed = {
+			"app-misc/A-2": {
+				"EAPI": "5",
+				"SLOT": "2",
+			}
+		}
+
+		test_cases = (
+			# bug 524916 - direct circular dep should not pull
+			# in an onlydeps node when possible
+			ResolverPlaygroundTestCase(
+				["app-misc/A:1"],
+				success = True,
+				options = { "--onlydeps": True },
+				mergelist = ["app-misc/B-0"]),
+		)
+
+		playground = ResolverPlayground(ebuilds=ebuilds,
+			installed=installed, debug=False)
+		try:
+			for test_case in test_cases:
+				playground.run_TestCase(test_case)
+				self.assertEqual(test_case.test_success,
+					True, test_case.fail_msg)
+		finally:
+			playground.cleanup()


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/resolver/
@ 2014-11-18  7:21 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2014-11-18  7:21 UTC (permalink / raw
  To: gentoo-commits

commit:     20ff16e8941af389cd1fc80e10aef1a90f3b5aa8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 11 09:08:20 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Nov 18 07:15:18 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=20ff16e8

dep_zapdeps: avoid use.mask/force changes (515584)

This patch causes dep_zapdeps to check which USE flags cause a match
to fail, and uses that information to prioritize choices that do not
require changes to use.mask or use.force.

X-Gentoo-Bug: 515584
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=515584
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

---
 pym/portage/dep/dep_check.py                  | 36 +++++++++++++++-
 pym/portage/tests/resolver/test_or_choices.py | 59 ++++++++++++++++++++++++++-
 2 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 62f42ac..ccdda59 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -317,6 +317,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 	priority = trees[myroot].get("priority")
 	graph_db = trees[myroot].get("graph_db")
 	graph    = trees[myroot].get("graph")
+	pkg_use_enabled = trees[myroot].get("pkg_use_enabled")
 	want_update_pkg = trees[myroot].get("want_update_pkg")
 	vardb = None
 	if "vartree" in trees[myroot]:
@@ -349,6 +350,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 
 		all_available = True
 		all_use_satisfied = True
+		all_use_unmasked = True
 		slot_map = {}
 		cp_map = {}
 		for atom in atoms:
@@ -369,6 +371,32 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 				avail_pkg_use = mydbapi_match_pkgs(atom)
 				if not avail_pkg_use:
 					all_use_satisfied = False
+
+					if pkg_use_enabled is not None:
+						# Check which USE flags cause the match to fail,
+						# so we can prioritize choices that do not
+						# require changes to use.mask or use.force
+						# (see bug #515584).
+						violated_atom = atom.violated_conditionals(
+							pkg_use_enabled(avail_pkg),
+							avail_pkg.iuse.is_valid_flag)
+
+						# Note that violated_atom.use can be None here,
+						# since evaluation can collapse conditional USE
+						# deps that cause the match to fail due to
+						# missing IUSE (match uses atom.unevaluated_atom
+						# to detect such missing IUSE).
+						if violated_atom.use is not None:
+							for flag in violated_atom.use.enabled:
+								if flag in avail_pkg.use.mask:
+									all_use_unmasked = False
+									break
+							else:
+								for flag in violated_atom.use.disabled:
+									if flag in avail_pkg.use.force and \
+										flag not in avail_pkg.use.mask:
+										all_use_unmasked = False
+										break
 				else:
 					# highest (ascending order)
 					avail_pkg_use = avail_pkg_use[-1]
@@ -416,7 +444,9 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 					else:
 						preferred_non_installed.append(this_choice)
 				else:
-					if all_installed_slots:
+					if not all_use_unmasked:
+						other.append(this_choice)
+					elif all_installed_slots:
 						unsat_use_installed.append(this_choice)
 					else:
 						unsat_use_non_installed.append(this_choice)
@@ -490,7 +520,9 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 						else:
 							preferred_non_installed.append(this_choice)
 					else:
-						if all_in_graph:
+						if not all_use_unmasked:
+							other.append(this_choice)
+						elif all_in_graph:
 							unsat_use_in_graph.append(this_choice)
 						elif all_installed_slots:
 							unsat_use_installed.append(this_choice)

diff --git a/pym/portage/tests/resolver/test_or_choices.py b/pym/portage/tests/resolver/test_or_choices.py
index d9d14f0..4aae0b2 100644
--- a/pym/portage/tests/resolver/test_or_choices.py
+++ b/pym/portage/tests/resolver/test_or_choices.py
@@ -1,4 +1,4 @@
-# Copyright 2013 Gentoo Foundation
+# Copyright 2013-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -205,3 +205,60 @@ class OrChoicesTestCase(TestCase):
 				self.assertEqual(test_case.test_success, True, test_case.fail_msg)
 		finally:
 			playground.cleanup()
+
+
+	def testUseMask(self):
+
+		profile = {
+			"use.mask":
+			(
+				"abi_ppc_32",
+			),
+		}
+
+		ebuilds = {
+
+			"sys-libs/A-1" : {
+				"EAPI": "5",
+				"RDEPEND": "|| ( sys-libs/zlib[abi_ppc_32(-)] " + \
+					"sys-libs/zlib[abi_x86_32(-)] )"
+			},
+
+			"sys-libs/zlib-1.2.8-r1" : {
+				"EAPI": "5",
+				"IUSE": "abi_ppc_32 abi_x86_32"
+			},
+
+			"sys-libs/zlib-1.2.8" : {
+				"EAPI": "5",
+				"IUSE": ""
+			},
+		}
+
+		test_cases = (
+
+			# bug #515584: We want to prefer choices that do
+			# not require changes to use.mask or use.force.
+			# In this case, abi_ppc_32 is use.masked in the
+			# profile, so we want to avoid that choice.
+			ResolverPlaygroundTestCase(
+				["sys-libs/A"],
+				options = {},
+				success = False,
+				use_changes = {
+					'sys-libs/zlib-1.2.8-r1': {'abi_x86_32': True}
+				},
+				mergelist = ["sys-libs/zlib-1.2.8-r1", "sys-libs/A-1"]
+			),
+
+		)
+
+		playground = ResolverPlayground(ebuilds=ebuilds,
+			profile=profile, debug=False)
+		try:
+			for test_case in test_cases:
+				playground.run_TestCase(test_case)
+				self.assertEqual(test_case.test_success, True,
+					test_case.fail_msg)
+		finally:
+			playground.cleanup()


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/resolver/
@ 2017-11-02 19:44 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2017-11-02 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     7c58e37376166b787abae4713c398feee8abf902
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Nov  2 08:29:11 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Nov  2 19:41:56 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7c58e373

dep_zapdeps: install new package, avoid downgrade (bug 635540)

Prefer to install a new package rather than to downgrade an
installed package. If the installed package should be
downgraded due to it being masked, then allow the downgrade.

Bug: https://bugs.gentoo.org/635540
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/dep/dep_check.py                       | 11 ++-
 .../tests/resolver/test_or_downgrade_installed.py  | 97 ++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 35caecc74..b33f7e5db 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -323,8 +323,10 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 	want_update_pkg = trees[myroot].get("want_update_pkg")
 	downgrade_probe = trees[myroot].get("downgrade_probe")
 	vardb = None
+	vardb_match_pkgs = None
 	if "vartree" in trees[myroot]:
 		vardb = trees[myroot]["vartree"].dbapi
+		vardb_match_pkgs = getattr(vardb, 'match_pkgs', None)
 	if use_binaries:
 		mydbapi = trees[myroot]["bintree"].dbapi
 	else:
@@ -355,6 +357,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 		all_use_satisfied = True
 		all_use_unmasked = True
 		conflict_downgrade = False
+		installed_downgrade = False
 		slot_atoms = collections.defaultdict(list)
 		slot_map = {}
 		cp_map = {}
@@ -419,6 +422,12 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 						avail_pkg = avail_pkg_use
 					avail_slot = Atom("%s:%s" % (atom.cp, avail_pkg.slot))
 
+			if vardb_match_pkgs is not None and downgrade_probe is not None:
+				inst_pkg = vardb_match_pkgs(avail_slot)
+				if (inst_pkg and avail_pkg < inst_pkg[-1] and
+					not downgrade_probe(inst_pkg[-1])):
+					installed_downgrade = True
+
 			slot_map[avail_slot] = avail_pkg
 			slot_atoms[avail_slot].append(atom)
 			highest_cpv = cp_map.get(avail_pkg.cp)
@@ -487,7 +496,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 						unsat_use_installed.append(this_choice)
 					else:
 						unsat_use_non_installed.append(this_choice)
-			elif conflict_downgrade:
+			elif conflict_downgrade or installed_downgrade:
 				other.append(this_choice)
 			else:
 				all_in_graph = True

diff --git a/pym/portage/tests/resolver/test_or_downgrade_installed.py b/pym/portage/tests/resolver/test_or_downgrade_installed.py
new file mode 100644
index 000000000..22307a5bc
--- /dev/null
+++ b/pym/portage/tests/resolver/test_or_downgrade_installed.py
@@ -0,0 +1,97 @@
+# Copyright 2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import (
+	ResolverPlayground,
+	ResolverPlaygroundTestCase,
+)
+
+class OrDowngradeInstalledTestCase(TestCase):
+
+	def testOrDowngradeInstalled(self):
+		ebuilds = {
+			'net-misc/foo-1': {
+				'EAPI': '6',
+				'RDEPEND': '|| ( sys-libs/glibc[rpc(-)]  net-libs/libtirpc )'
+			},
+			'net-libs/libtirpc-1': {
+				'EAPI': '6',
+			},
+			'sys-libs/glibc-2.26': {
+				'EAPI': '6',
+				'IUSE': ''
+			},
+			'sys-libs/glibc-2.24': {
+				'EAPI': '6',
+				'IUSE': '+rpc'
+			},
+		}
+
+		installed = {
+			'sys-libs/glibc-2.26': {
+				'EAPI': '6',
+				'IUSE': ''
+			},
+		}
+
+		world = ['sys-libs/glibc']
+
+		test_cases = (
+			# Test bug 635540, where we need to install libtirpc
+			# rather than downgrade glibc.
+			ResolverPlaygroundTestCase(
+				['net-misc/foo'],
+				success=True,
+				mergelist=[
+					'net-libs/libtirpc-1',
+					'net-misc/foo-1',
+				],
+			),
+		)
+
+		playground = ResolverPlayground(debug=False,
+			ebuilds=ebuilds, installed=installed, world=world)
+
+		try:
+			for test_case in test_cases:
+				playground.run_TestCase(test_case)
+				self.assertEqual(test_case.test_success, True,
+					test_case.fail_msg)
+		finally:
+			playground.debug = False
+			playground.cleanup()
+
+		# In some cases it's necessary to downgrade due to
+		# the installed package being masked (glibc is a
+		# not an ideal example because it's usually not
+		# practical to downgrade it).
+		user_config = {
+			"package.mask" : (
+				">=sys-libs/glibc-2.26",
+			),
+		}
+
+		test_cases = (
+			ResolverPlaygroundTestCase(
+				['net-misc/foo'],
+				success=True,
+				mergelist=[
+					'sys-libs/glibc-2.24',
+					'net-misc/foo-1',
+				],
+			),
+		)
+
+		playground = ResolverPlayground(debug=False,
+			ebuilds=ebuilds, installed=installed, world=world,
+			user_config=user_config)
+
+		try:
+			for test_case in test_cases:
+				playground.run_TestCase(test_case)
+				self.assertEqual(test_case.test_success, True,
+					test_case.fail_msg)
+		finally:
+			playground.debug = False
+			playground.cleanup()


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/resolver/
@ 2018-01-27 20:53 Zac Medico
  0 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2018-01-27 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     5c888fcd2e87270523f55fb180ced5c3c8689f76
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 23 06:08:10 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jan 27 20:52:53 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5c888fcd

dep_zapdeps: fix virtual/rust handling (bug 645416)

Fix the code from bug 643974 to set the installed_downgrade flag only
if the selected newer package is either installed or in the graph. This
is currently needed for appropriate handling of virtual/rust-1.19.0,
since there's an upgrade to dev-lang/rust-1.23.0 available which may
not be desired since it would mean that dev-lang/rust-bin-1.19.0 has
to be installed in order to satisfy virtual/rust-1.19.0:

 || ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )

So, the rust-bin choice is desirable only if the rust-1.23.0 package is
already installed or in the graph.

Fixes: 86ba22da7a2f ("dep_zapdeps: install new package, allow upgrade (bug 643974)")
Bug: https://bugs.gentoo.org/645416

 pym/portage/dep/dep_check.py                       | 10 ++--
 .../tests/resolver/test_or_upgrade_installed.py    | 59 ++++++++++++++++++++++
 2 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index c56f545ec..7e5a3186e 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -463,11 +463,15 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
 						avail_pkg = avail_pkg_use
 					avail_slot = Atom("%s:%s" % (atom.cp, avail_pkg.slot))
 
-			if downgrade_probe is not None:
+			if downgrade_probe is not None and graph is not None:
 				highest_in_slot = mydbapi_match_pkgs(avail_slot)
+				highest_in_slot = (highest_in_slot[-1]
+					if highest_in_slot else None)
 				if (avail_pkg and highest_in_slot and
-					avail_pkg < highest_in_slot[-1] and
-					not downgrade_probe(avail_pkg)):
+					avail_pkg < highest_in_slot and
+					not downgrade_probe(avail_pkg) and
+					(highest_in_slot.installed or
+					highest_in_slot in graph)):
 					installed_downgrade = True
 
 			slot_map[avail_slot] = avail_pkg

diff --git a/pym/portage/tests/resolver/test_or_upgrade_installed.py b/pym/portage/tests/resolver/test_or_upgrade_installed.py
index 6e01d321d..7018e08de 100644
--- a/pym/portage/tests/resolver/test_or_upgrade_installed.py
+++ b/pym/portage/tests/resolver/test_or_upgrade_installed.py
@@ -99,3 +99,62 @@ class OrUpgradeInstalledTestCase(TestCase):
 		finally:
 			playground.debug = False
 			playground.cleanup()
+
+	def testVirtualRust(self):
+		ebuilds = {
+			'dev-lang/rust-1.19.0': {},
+			'dev-lang/rust-1.23.0': {},
+			'dev-lang/rust-bin-1.19.0': {},
+			'virtual/rust-1.19.0': {
+				'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )'
+			},
+		}
+
+		installed = {
+			'dev-lang/rust-1.19.0': {},
+			'virtual/rust-1.19.0': {
+				'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )'
+			},
+		}
+
+		world = ['virtual/rust']
+
+		test_cases = (
+			# Test bug 645416, where rust-bin-1.19.0 was pulled in
+			# inappropriately due to the rust-1.23.0 update being
+			# available.
+			ResolverPlaygroundTestCase(
+				['virtual/rust'],
+				options={'--update': True, '--deep': True},
+				success=True,
+				mergelist=[]
+			),
+			# Test upgrade to rust-1.23.0, which is only possible
+			# if rust-bin-1.19.0 is installed in order to satisfy
+			# virtual/rust-1.19.0.
+			ResolverPlaygroundTestCase(
+				['=dev-lang/rust-1.23.0', 'virtual/rust'],
+				options={'--update': True, '--deep': True},
+				all_permutations=True,
+				success=True,
+				ambiguous_merge_order=True,
+				mergelist=(
+					(
+						'dev-lang/rust-1.23.0',
+						'dev-lang/rust-bin-1.19.0',
+					),
+				),
+			),
+		)
+
+		playground = ResolverPlayground(debug=False,
+			ebuilds=ebuilds, installed=installed, world=world)
+
+		try:
+			for test_case in test_cases:
+				playground.run_TestCase(test_case)
+				self.assertEqual(test_case.test_success, True,
+					test_case.fail_msg)
+		finally:
+			playground.debug = False
+			playground.cleanup()


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-27 20:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-18  7:21 [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/resolver/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2018-01-27 20:53 Zac Medico
2017-11-02 19:44 Zac Medico
2014-10-28  8:36 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox