[gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/portage/dep/

2018-03-04 Thread Michał Górny
commit: 9ebd5865559aa17186c23c90c6a90894449dc3ac
Author: Michał Górny  gentoo  org>
AuthorDate: Mon Feb 26 13:09:32 2018 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Mar  4 21:03:52 2018 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9ebd5865

Empty || *DEPEND group no longer satisfy deps in EAPI 7

Bug: https://bugs.gentoo.org/636596

 pym/portage/dep/__init__.py | 3 +++
 pym/portage/tests/resolver/test_eapi.py | 9 -
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 2a081f3d8..3d4bca08f 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -562,6 +562,9 @@ def use_reduce(depstr, uselist=[], masklist=[], 
matchall=False, excludeall=[], i
basestring):
if stack[level][-1] == "||" and not l:
#Optimize: || ( ) -> .
+   if not 
eapi_attrs.empty_groups_always_true:
+   # in EAPI 7+, we need 
to fail here
+   l.append((token_class 
or _unicode)("__const__/empty-any-of"))
stack[level].pop()
elif stack[level][-1][-1] == "?":
#The last token before the '(' 
that matches the current ')'

diff --git a/pym/portage/tests/resolver/test_eapi.py 
b/pym/portage/tests/resolver/test_eapi.py
index 525b58532..fce05890b 100644
--- a/pym/portage/tests/resolver/test_eapi.py
+++ b/pym/portage/tests/resolver/test_eapi.py
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -59,6 +59,10 @@ class EAPITestCase(TestCase):
"dev-libs/A-7.4": { "EAPI": "4", "IUSE": "foo +bar", 
"REQUIRED_USE": "|| ( foo bar )" }, 
 
"dev-libs/B-1": {"EAPI": 1, "IUSE": "+foo"}, 
+
+   #EAPI-7: implicit || ( ) no longer satisfies deps
+   "dev-libs/C-1": { "EAPI": "6", "IUSE": "foo", 
"RDEPEND": "|| ( foo? ( dev-libs/B ) )" }, 
+   "dev-libs/C-2": { "EAPI": "7_pre1", "IUSE": "foo", 
"RDEPEND": "|| ( foo? ( dev-libs/B ) )" }, 
}
 
test_cases = (
@@ -104,6 +108,9 @@ class EAPITestCase(TestCase):
ResolverPlaygroundTestCase(["=dev-libs/A-7.2"], success 
= False),
ResolverPlaygroundTestCase(["=dev-libs/A-7.3"], success 
= False),
ResolverPlaygroundTestCase(["=dev-libs/A-7.4"], success 
= True, mergelist = ["dev-libs/A-7.4"]),
+
+   ResolverPlaygroundTestCase(["=dev-libs/C-1"], success = 
True, mergelist = ["dev-libs/C-1"]),
+   ResolverPlaygroundTestCase(["=dev-libs/C-2"], success = 
False),
)
 
playground = ResolverPlayground(ebuilds=ebuilds)



[gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/portage/dep/

2018-01-20 Thread Zac Medico
commit: 74d0f516a346c7fb6c52a2508ca16b8949b3b65f
Author: Zac Medico  gentoo  org>
AuthorDate: Sun Jan 21 00:00:02 2018 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sun Jan 21 00:09:11 2018 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=74d0f516

dep_zapdeps: exclude virtuals from new_slot_count (bug 645190)

Fix new_slot_count to exclude virtual packages, since they are considered
to have zero-cost. This solves an issue where the catalyst stage1 build
would unexpectedly pull in static-dev to satisfy virtual/dev-manager,
but eudev is the preferred choice.

Bug: https://bugs.gentoo.org/645190
Fixes: 9fdaf9bdbdf5 ("dep_check: use DNF to optimize overlapping virtual || 
deps (bug 632026)")
Reported-by: Ben Kohler  gmail.com>

 pym/portage/dep/dep_check.py   |  3 +-
 .../resolver/test_virtual_minimize_children.py | 61 ++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 7cf338819..c56f545ec 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -499,7 +499,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, 
trees=None):
cp_map[avail_pkg.cp] = avail_pkg
 
new_slot_count = (len(slot_map) if graph_db is None else
-   sum(not graph_db.match_pkgs(slot_atom) for slot_atom in 
slot_map))
+   sum(not graph_db.match_pkgs(slot_atom) for slot_atom in 
slot_map
+   if not slot_atom.cp.startswith("virtual/")))
 
this_choice = _dep_choice(atoms=atoms, slot_map=slot_map,
cp_map=cp_map, all_available=all_available,

diff --git a/pym/portage/tests/resolver/test_virtual_minimize_children.py 
b/pym/portage/tests/resolver/test_virtual_minimize_children.py
index 6eb0409f2..287445e58 100644
--- a/pym/portage/tests/resolver/test_virtual_minimize_children.py
+++ b/pym/portage/tests/resolver/test_virtual_minimize_children.py
@@ -226,3 +226,64 @@ class VirtualMinimizeChildrenTestCase(TestCase):
finally:
playground.debug = False
playground.cleanup()
+
+   def testVirtualDevManager(self):
+   ebuilds = {
+   'sys-fs/eudev-3.1.5': {},
+   'sys-fs/static-dev-0.1': {},
+   'sys-fs/udev-233': {},
+   'virtual/dev-manager-0': {
+   'RDEPEND': '''
+   || (
+   virtual/udev
+   sys-fs/static-dev
+   )'''
+   },
+   'virtual/udev-0': {
+   'RDEPEND': '''
+   || (
+   >=sys-fs/eudev-2.1.1
+   >=sys-fs/udev-217
+   )'''
+   },
+   }
+
+   test_cases = (
+   # Test bug 645190, where static-dev was pulled in 
instead
+   # of eudev.
+   ResolverPlaygroundTestCase(
+   [
+   'virtual/dev-manager',
+   ],
+   success=True,
+   mergelist=(
+   'sys-fs/eudev-3.1.5',
+   'virtual/udev-0',
+   'virtual/dev-manager-0',
+   ),
+   ),
+   # Test static-dev preference.
+   ResolverPlaygroundTestCase(
+   [
+   'sys-fs/static-dev',
+   'virtual/dev-manager',
+   ],
+   all_permutations=True,
+   success=True,
+   mergelist=(
+   'sys-fs/static-dev-0.1',
+   'virtual/dev-manager-0',
+   ),
+   ),
+   )
+
+   playground = ResolverPlayground(debug=False, ebuilds=ebuilds)
+
+   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
+   

[gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/portage/dep/

2018-01-20 Thread Zac Medico
commit: e2134e9f72a86734552bb67e9414a017cfc4ea51
Author: Zac Medico  gentoo  org>
AuthorDate: Sat Jan 20 00:28:42 2018 +
Commit: Zac Medico  gentoo  org>
CommitDate: Sat Jan 20 23:08:42 2018 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e2134e9f

dep_zapdeps: prefer choices with fewer new slots (bug 645002)

Prefer choices with fewer new slots, rather than choices with the lowest
total number of slots. This fixes a case triggered by the catalyst stage1
build, where paludis was selected to satisfy perl-cleaner dependencies
because that choice happened to have a smaller number of slots:

  || (
( sys-apps/portage app-portage/portage-utils )
sys-apps/pkgcore
sys-apps/paludis
  )

Bug: https://bugs.gentoo.org/645002
Fixes: 9fdaf9bdbdf5 ("dep_check: use DNF to optimize overlapping virtual || 
deps (bug 632026)")
Tested-by: Ben Kohler  gmail.com>

 pym/portage/dep/dep_check.py   | 14 ++--
 .../resolver/test_virtual_minimize_children.py | 85 +-
 2 files changed, 93 insertions(+), 6 deletions(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 291626f56..7cf338819 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2015 Gentoo Foundation
+# Copyright 2010-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -296,7 +296,7 @@ def dep_eval(deplist):
 
 class _dep_choice(SlotObject):
__slots__ = ('atoms', 'slot_map', 'cp_map', 'all_available',
-   'all_installed_slots')
+   'all_installed_slots', 'new_slot_count')
 
 def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
"""
@@ -498,9 +498,13 @@ def dep_zapdeps(unreduced, reduced, myroot, 
use_binaries=0, trees=None):
if current_higher or (all_match_current and not 
all_match_previous):
cp_map[avail_pkg.cp] = avail_pkg
 
+   new_slot_count = (len(slot_map) if graph_db is None else
+   sum(not graph_db.match_pkgs(slot_atom) for slot_atom in 
slot_map))
+
this_choice = _dep_choice(atoms=atoms, slot_map=slot_map,
cp_map=cp_map, all_available=all_available,
-   all_installed_slots=False)
+   all_installed_slots=False,
+   new_slot_count=new_slot_count)
if all_available:
# The "all installed" criterion is not version or slot 
specific.
# If any version of a package is already in the graph 
then we
@@ -655,8 +659,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, 
trees=None):
if len(choices) < 2:
continue
# Prefer choices with all_installed_slots for bug #480736, and
-   # choices with a smaller number of packages for bug #632026.
-   choices.sort(key=lambda x: (not x.all_installed_slots, 
len(x.slot_map)))
+   # choices with a smaller number of new slots for bug #632026.
+   choices.sort(key=lambda x: (not x.all_installed_slots, 
x.new_slot_count))
for choice_1 in choices[1:]:
cps = set(choice_1.cp_map)
for choice_2 in choices:

diff --git a/pym/portage/tests/resolver/test_virtual_minimize_children.py 
b/pym/portage/tests/resolver/test_virtual_minimize_children.py
index 83ae34e77..6eb0409f2 100644
--- a/pym/portage/tests/resolver/test_virtual_minimize_children.py
+++ b/pym/portage/tests/resolver/test_virtual_minimize_children.py
@@ -1,4 +1,4 @@
-# Copyright 2017 Gentoo Foundation
+# Copyright 2017-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -143,3 +143,86 @@ class VirtualMinimizeChildrenTestCase(TestCase):
finally:
playground.debug = False
playground.cleanup()
+
+   def testVirtualPackageManager(self):
+   ebuilds = {
+   'app-admin/perl-cleaner-2.25': {
+   'RDEPEND': '''
+   || (
+   ( sys-apps/portage 
app-portage/portage-utils )
+   sys-apps/pkgcore
+   sys-apps/paludis
+   )'''
+   },
+   'app-portage/portage-utils-0.64': {},
+   'sys-apps/paludis-2.6.0': {},
+   'sys-apps/portage-2.3.19-r1': {},
+   'virtual/package-manager-0': {
+   'RDEPEND': '''
+  

[gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/portage/dep/

2018-01-11 Thread Zac Medico
commit: 86ba22da7a2f34848cdb5a6f1090c22c264e577e
Author: Zac Medico  gentoo  org>
AuthorDate: Tue Jan  9 03:34:22 2018 +
Commit: Zac Medico  gentoo  org>
CommitDate: Thu Jan 11 19:23:34 2018 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=86ba22da

dep_zapdeps: install new package, allow upgrade (bug 643974)

Prefer to install a new package in order to allow upgrade of an
installed package. This generalizes the code from bug 635540 so
that it both allows desirable upgrades and prevents unwanted
downgrades.

Fixes: 7c58e3737616 ("dep_zapdeps: install new package, avoid downgrade (bug 
635540)")
Bug: https://bugs.gentoo.org/643974
Reviewed-by: Alec Warner  gentoo.org>

 pym/portage/dep/dep_check.py   |  11 +--
 .../tests/resolver/test_or_upgrade_installed.py| 101 +
 2 files changed, 106 insertions(+), 6 deletions(-)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 2bb9dc339..291626f56 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -366,10 +366,8 @@ 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:
@@ -465,10 +463,11 @@ 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])):
+   if downgrade_probe is not None:
+   highest_in_slot = mydbapi_match_pkgs(avail_slot)
+   if (avail_pkg and highest_in_slot and
+   avail_pkg < highest_in_slot[-1] and
+   not downgrade_probe(avail_pkg)):
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
new file mode 100644
index 0..6e01d321d
--- /dev/null
+++ b/pym/portage/tests/resolver/test_or_upgrade_installed.py
@@ -0,0 +1,101 @@
+# Copyright 2018 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 OrUpgradeInstalledTestCase(TestCase):
+
+   def testOrUpgradeInstalled(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.24': {
+   'EAPI': '6',
+   'IUSE': '+rpc',
+   'USE': 'rpc',
+   },
+   }
+
+   world = ['sys-libs/glibc']
+
+   test_cases = (
+   # Test bug 643974, where we need to install libtirpc
+   # in order to upgrade glibc.
+   ResolverPlaygroundTestCase(
+   ['net-misc/foo', '@world'],
+   options={'--update': True, '--deep': True},
+   success=True,
+   ambiguous_merge_order=True,
+   mergelist=(
+   (
+   'net-libs/libtirpc-1',
+   

[gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/portage/dep/

2014-09-14 Thread Brian Dolbec
commit: d1e8d3468d0cee24480f6cbe16b2ca82ec7dc9fa
Author: Zac Medico zmedico AT gentoo DOT org
AuthorDate: Sat Sep 13 00:32:53 2014 +
Commit: Brian Dolbec brian.dolbec AT gmail DOT com
CommitDate: Mon Sep 15 04:00:15 2014 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d1e8d346

dep_zapdeps: fix bug #522652

For cases such as || ( X A-2 ), where X is unsatisfiable and A-1 is
installed, fix dep_zapdeps to make the correct choice.

---
 pym/portage/dep/dep_check.py  | 10 
 pym/portage/tests/resolver/test_or_choices.py | 73 +++
 2 files changed, 83 insertions(+)

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 22eed96..4386b5e 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -287,6 +287,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, 
trees=None):
unsat_use_non_installed = []
other_installed = []
other_installed_some = []
+   other_installed_any_slot = []
other = []
 
# unsat_use_* must come after preferred_non_installed
@@ -301,6 +302,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, 
trees=None):
unsat_use_non_installed,
other_installed,
other_installed_some,
+   other_installed_any_slot,
other,
)
 
@@ -504,6 +506,14 @@ def dep_zapdeps(unreduced, reduced, myroot, 
use_binaries=0, trees=None):
other_installed.append(this_choice)
elif some_installed:
other_installed_some.append(this_choice)
+
+   # Use Atom(atom.cp) for a somewhat fuzzy match, since
+   # the whole atom may be too specific. For example, see
+   # bug #522652, where using the whole atom leads to an
+   # unsatisfiable choice.
+   elif any(vardb.match(Atom(atom.cp)) for atom in atoms
+   if not atom.blocker):
+   other_installed_any_slot.append(this_choice)
else:
other.append(this_choice)
 

diff --git a/pym/portage/tests/resolver/test_or_choices.py 
b/pym/portage/tests/resolver/test_or_choices.py
index 90e6814..d9d14f0 100644
--- a/pym/portage/tests/resolver/test_or_choices.py
+++ b/pym/portage/tests/resolver/test_or_choices.py
@@ -132,3 +132,76 @@ class OrChoicesTestCase(TestCase):
self.assertEqual(test_case.test_success, True, 
test_case.fail_msg)
finally:
playground.cleanup()
+
+
+   def testInitiallyUnsatisfied(self):
+
+   ebuilds = {
+
+   app-misc/A-1 : {
+   EAPI: 5,
+   SLOT: 0/1
+   },
+
+   app-misc/A-2 : {
+   EAPI: 5,
+   SLOT: 0/2
+   },
+
+   app-misc/B-0 : {
+   EAPI: 5,
+   RDEPEND: app-misc/A:=
+   },
+
+   app-misc/C-0 : {
+   EAPI: 5,
+   RDEPEND: || ( app-misc/X app-misc/A-2 )
+   },
+
+   }
+
+   installed = {
+
+   app-misc/A-1 : {
+   EAPI: 5,
+   SLOT: 0/1
+   },
+
+   app-misc/B-0 : {
+   EAPI: 5,
+   RDEPEND: app-misc/A:0/1=
+   },
+
+   app-misc/C-0 : {
+   EAPI: 5,
+   RDEPEND: || ( app-misc/X app-misc/A-2 )
+   },
+
+   }
+
+   world = [app-misc/B, app-misc/C]
+
+   test_cases = (
+
+   # Test bug #522652, where the unsatisfiable app-misc/X
+   # atom is selected, and the dependency is placed into
+   # _initially_unsatisfied_deps where it is ignored, 
causing
+   # upgrade to app-misc/A-2 (breaking a dependency of
+   # app-misc/C-0).
+   ResolverPlaygroundTestCase(
+   [app-misc/A],
+   options = {},
+   success = True,
+   mergelist = ['app-misc/A-1']
+   ),
+
+   )
+
+   playground = ResolverPlayground(ebuilds=ebuilds,
+   installed=installed, world=world, debug=False)
+   try:
+