From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/_emerge/
Date: Fri, 2 Jun 2017 05:41:28 +0000 (UTC) [thread overview]
Message-ID: <1496381882.60af7e2696b96b47b0cd9e70caabd10546206b8b.zmedico@gentoo> (raw)
commit: 60af7e2696b96b47b0cd9e70caabd10546206b8b
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 29 08:22:40 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun 2 05:38:02 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=60af7e26
depgraph: prune unnecessary rebuilds for --autounmask-continue (bug 619626)
When there are autounmask USE changes, avoid unnecessary rebuilds
by accepting binary packages that were rejected due to the preexisting
USE configuration. This reuses the prune_rebuilds backtracker support
which was added for bug 439688.
X-Gentoo-bug: 619626
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=619626
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/_emerge/depgraph.py | 96 ++++++++++++++++++----
.../tests/resolver/test_autounmask_binpkg_use.py | 64 +++++++++++++++
2 files changed, 142 insertions(+), 18 deletions(-)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 2dc432431..abe2cb1bd 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -5,6 +5,7 @@ from __future__ import division, print_function, unicode_literals
import collections
import errno
+import functools
import io
import logging
import stat
@@ -856,17 +857,11 @@ class depgraph(object):
for parent in self._forced_rebuilds[root][child]:
writemsg_stdout(" %s\n" % (parent,), noiselevel=-1)
- def _show_ignored_binaries(self):
+ def _eliminate_ignored_binaries(self):
"""
- Show binaries that have been ignored because their USE didn't
- match the user's config.
+ Eliminate any package from self._dynamic_config.ignored_binaries
+ for which a more optimal alternative exists.
"""
- if not self._dynamic_config.ignored_binaries \
- or '--quiet' in self._frozen_config.myopts:
- return
-
- ignored_binaries = {}
-
for pkg in list(self._dynamic_config.ignored_binaries):
for selected_pkg in self._dynamic_config._package_tracker.match(
@@ -894,10 +889,67 @@ class depgraph(object):
self._dynamic_config.ignored_binaries.pop(pkg)
break
- else:
- for reason, info in self._dynamic_config.\
- ignored_binaries[pkg].items():
- ignored_binaries.setdefault(reason, {})[pkg] = info
+ def _ignored_binaries_autounmask_backtrack(self):
+ """
+ Check if there are ignored binaries that would have been
+ accepted with the current autounmask USE changes.
+
+ @rtype: bool
+ @return: True if there are unnecessary rebuilds that
+ can be avoided by backtracking
+ """
+ if not all([
+ self._dynamic_config._allow_backtracking,
+ self._dynamic_config._needed_use_config_changes,
+ self._dynamic_config.ignored_binaries]):
+ return False
+
+ self._eliminate_ignored_binaries()
+
+ # _eliminate_ignored_binaries may have eliminated
+ # all of the ignored binaries
+ if not self._dynamic_config.ignored_binaries:
+ return False
+
+ use_changes = collections.defaultdict(
+ functools.partial(collections.defaultdict, dict))
+ for pkg, (new_use, changes) in self._dynamic_config._needed_use_config_changes.items():
+ if pkg in self._dynamic_config.digraph:
+ use_changes[pkg.root][pkg.slot_atom] = (pkg, new_use)
+
+ for pkg in self._dynamic_config.ignored_binaries:
+ selected_pkg, new_use = use_changes[pkg.root].get(
+ pkg.slot_atom, (None, None))
+ if new_use is None:
+ continue
+
+ if new_use != pkg.use.enabled:
+ continue
+
+ if selected_pkg > pkg:
+ continue
+
+ return True
+
+ return False
+
+ def _show_ignored_binaries(self):
+ """
+ Show binaries that have been ignored because their USE didn't
+ match the user's config.
+ """
+ if not self._dynamic_config.ignored_binaries \
+ or '--quiet' in self._frozen_config.myopts:
+ return
+
+ self._eliminate_ignored_binaries()
+
+ ignored_binaries = {}
+
+ for pkg in self._dynamic_config.ignored_binaries:
+ for reason, info in self._dynamic_config.\
+ ignored_binaries[pkg].items():
+ ignored_binaries.setdefault(reason, {})[pkg] = info
if self._dynamic_config.myparams.get(
"binpkg_respect_use") in ("y", "n"):
@@ -4254,6 +4306,13 @@ class depgraph(object):
self._dynamic_config._skip_restart = True
return False, myfavorites
+ if (not self._dynamic_config._prune_rebuilds and
+ self._ignored_binaries_autounmask_backtrack()):
+ config = self._dynamic_config._backtrack_infos.setdefault("config", {})
+ config["prune_rebuilds"] = True
+ self._dynamic_config._need_restart = True
+ return False, myfavorites
+
# Any failures except those due to autounmask *alone* should return
# before this point, since the success_without_autounmask flag that's
# set below is reserved for cases where there are *zero* other
@@ -6233,13 +6292,14 @@ class depgraph(object):
iuses = pkg.iuse.all
old_use = self._pkg_use_enabled(pkg)
if myeb:
- pkgsettings.setcpv(myeb)
+ now_use = self._pkg_use_enabled(myeb)
+ forced_flags = set(chain(
+ myeb.use.force, myeb.use.mask))
else:
pkgsettings.setcpv(pkg)
- now_use = pkgsettings["PORTAGE_USE"].split()
- forced_flags = set()
- forced_flags.update(pkgsettings.useforce)
- forced_flags.update(pkgsettings.usemask)
+ now_use = pkgsettings["PORTAGE_USE"].split()
+ forced_flags = set(chain(
+ pkgsettings.useforce, pkgsettings.usemask))
cur_iuse = iuses
if myeb and not usepkgonly and not useoldpkg:
cur_iuse = myeb.iuse.all
diff --git a/pym/portage/tests/resolver/test_autounmask_binpkg_use.py b/pym/portage/tests/resolver/test_autounmask_binpkg_use.py
new file mode 100644
index 000000000..1ca4bf3d9
--- /dev/null
+++ b/pym/portage/tests/resolver/test_autounmask_binpkg_use.py
@@ -0,0 +1,64 @@
+# 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 AutounmaskBinpkgUseTestCase(TestCase):
+
+ def testAutounmaskBinpkgUse(self):
+ ebuilds = {
+ "dev-libs/A-1": {
+ "EAPI": "6",
+ "DEPEND": "dev-libs/B[foo]",
+ "RDEPEND": "dev-libs/B[foo]",
+ },
+ "dev-libs/B-1": {
+ "EAPI": "6",
+ "IUSE": "foo",
+ },
+ }
+ binpkgs = {
+ "dev-libs/A-1": {
+ "EAPI": "6",
+ "DEPEND": "dev-libs/B[foo]",
+ "RDEPEND": "dev-libs/B[foo]",
+ },
+ "dev-libs/B-1": {
+ "EAPI": "6",
+ "IUSE": "foo",
+ "USE": "foo",
+ },
+ }
+ installed = {
+ }
+
+ test_cases = (
+ # Bug 619626: Test for unnecessary rebuild due
+ # to rejection of binary packages that would
+ # be acceptable after appplication of autounmask
+ # USE changes.
+ ResolverPlaygroundTestCase(
+ ["dev-libs/A"],
+ all_permutations = True,
+ success = True,
+ options = {
+ "--usepkg": True,
+ },
+ mergelist = [
+ "[binary]dev-libs/B-1",
+ "[binary]dev-libs/A-1",
+ ],
+ use_changes = {"dev-libs/B-1": {"foo": True}}
+ ),
+ )
+
+ playground = ResolverPlayground(ebuilds=ebuilds,
+ binpkgs=binpkgs, 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.debug = False
+ playground.cleanup()
next reply other threads:[~2017-06-02 5:41 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 5:41 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-05-04 17:12 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/_emerge/ Zac Medico
2018-04-12 2:45 Zac Medico
2017-09-29 17:24 Zac Medico
2017-04-01 5:48 Zac Medico
2017-03-22 8:59 Zac Medico
2017-03-16 4:51 Zac Medico
2017-03-09 19:36 Zac Medico
2016-08-07 17:55 Zac Medico
2015-11-24 16:45 Zac Medico
2014-11-16 9:04 Zac Medico
2014-10-27 9:26 Zac Medico
2014-09-19 9:28 Zac Medico
2014-09-19 9:17 Zac Medico
2014-09-17 16:35 Zac Medico
2014-09-16 21:04 Brian Dolbec
2014-09-11 21:37 Zac Medico
2014-04-26 19:44 Sebastian Luther
2014-02-16 17:25 Sebastian Luther
2014-02-15 12:40 Sebastian Luther
2014-02-05 19:42 Sebastian Luther
2014-01-07 22:22 Arfrever Frehtes Taifersar Arahesis
2013-12-05 15:38 Brian Dolbec
2013-12-01 10:19 Brian Dolbec
2013-11-27 7:44 Mike Frysinger
2013-08-02 8:26 Zac Medico
2013-07-07 19:16 Zac Medico
2013-07-06 21:45 Zac Medico
2013-03-19 21:06 Zac Medico
2013-03-05 0:56 Zac Medico
2013-02-14 4:45 Zac Medico
2013-02-12 2:50 Zac Medico
2013-02-11 22:51 Zac Medico
2013-02-11 1:58 Zac Medico
2012-12-01 23:23 Zac Medico
2012-10-26 6:06 Zac Medico
2012-10-26 4:57 Zac Medico
2012-07-05 3:16 Zac Medico
2012-06-15 23:04 Zac Medico
2012-02-26 10:00 Zac Medico
2011-11-18 1:26 Zac Medico
2011-09-30 8:30 Zac Medico
2011-09-19 3:05 Zac Medico
2011-09-18 20:08 Zac Medico
2011-09-18 19:42 Zac Medico
2011-09-15 5:10 Zac Medico
2011-09-11 20:43 Zac Medico
2011-06-12 22:13 Zac Medico
2011-05-24 23:59 Zac Medico
2011-05-23 5:40 Zac Medico
2011-05-22 23:49 Zac Medico
2011-05-21 3:49 Zac Medico
2011-05-03 22:59 Zac Medico
2011-04-27 20:40 Zac Medico
2011-02-13 13:55 Zac Medico
2011-02-13 10:23 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=1496381882.60af7e2696b96b47b0cd9e70caabd10546206b8b.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