From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/resolver/
Date: Wed, 4 Oct 2017 00:30:34 +0000 (UTC) [thread overview]
Message-ID: <1507076816.8fba660fb08ddd468d934c7478dcfc8015330e9b.zmedico@gentoo> (raw)
commit: 8fba660fb08ddd468d934c7478dcfc8015330e9b
Author: Daniel Robbins <drobbins <AT> funtoo <DOT> org>
AuthorDate: Tue Oct 3 20:29:44 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 4 00:26:56 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8fba660f
resolver/package_tracker: new docs
Closes: https://github.com/gentoo/portage/pull/216
pym/_emerge/resolver/package_tracker.py | 87 ++++++++++++++++++++++++++-------
1 file changed, 69 insertions(+), 18 deletions(-)
diff --git a/pym/_emerge/resolver/package_tracker.py b/pym/_emerge/resolver/package_tracker.py
index 398d4cf46..06163574e 100644
--- a/pym/_emerge/resolver/package_tracker.py
+++ b/pym/_emerge/resolver/package_tracker.py
@@ -31,38 +31,89 @@ class PackageConflict(_PackageConflict):
class PackageTracker(object):
"""
- This class tracks packages which are currently
- installed and packages which have been pulled into
- the dependency graph.
+ **Behavior**
- It automatically tracks conflicts between packages.
+ This section is intended to give you a good conceptual overview of the ``PackageTracker`` class and its general
+ behavior -- how you can expect it to behave and how in turn expects to be used successfully by the programmer.
- Possible conflicts:
- 1) Packages that share the same SLOT.
- 2) Packages with the same cpv.
- Not yet implemented:
- 3) Packages that block each other.
+ This class is used to model the behavior of a real Gentoo or other system using Portage for package management,
+ along with the installed and to-be-installed packages. The installed packages are ones that are already on the
+ system and recorded in ``/var/db/pkg``, while the to-be-installed packages are a group of packages that Portage is
+ considering installing on the system, based on the information in Portage's dependency graph. Multiple roots are
+ supported, so that situations can be modeled where ROOT is set to a non-default value (non-``/``).
+
+ You can use the add_pkg() method to add a to-be-merged package to the PackageTracker, and ``add_installed_pkg()``
+ to add an already-installed package to the package tracker. Typical use of the package tracker involves the
+ depgraph.py code populating the package tracker with calls to ``add_installed_pkg()`` to add all installed packages
+ on the system, and then it is initialized and ready for use. At that point, ``depgraph.py`` can use ``add_pkg()``
+ to add to-be-installed packages to the system.
+
+ It's worth mentioning that PackageTracker uses ``Package`` objects as arguments, and stores these objects
+ internally. There are parts of the code that ensure that a ``Package`` instance is added to the PackageTracker
+ only once.
+
+ Note that when a to-be-merged package is added to the package tracker via ``add_pkg()``, it will "cover up"
+ (replace) any installed package that shares the same root-catpkg-slot or root-catpkg-version, meaning that calling
+ the ``all_pkgs()`` or ``match()`` method will not return the installed package in the list. And the code does
+ support the scenario where ``add_installed_pkg(pkg2)`` is called *after* a call to ``add_pkg(pkg1)`` -- in this
+ case, if ``pkg1`` would 'cover up' ``pkg2``, this will be identified and handled correctly.
+
+ But the package tracker is designed to have an important behavior in this regard -- because PackageTracker has a
+ ``remove()`` method, these replaced/covered-up packages are not permanently removed -- so if you ``remove()`` a
+ to-be-installed package that was "replacing" an installed package, the installed package will "reappear". This
+ removal functionality is used by the slot conflict code in ``depgraph.py`` to modify the list of to-be-installed
+ packages as it addresses slot conflicts.
+
+ One of the main purposes of the PackageTracker is to detect conflicts between packages. Conflicts are detected
+ on to-be-installed packages only.
+
+ A slot conflict is a situation where a to-be-installed package is added to the package tracker via ``add_pkg()``,
+ and there is already a to-be-installed package added that has the same root, catpkg and slot. These cannot co-exist.
+
+ A cpv conflict is a situation where a to-be-installed package is added to the package tracker via ``add_pkg()``, and
+ there is already a to-be-installed package add that has the same root, catpkg, and version+revision. These cannot
+ co-exist.
+
+ The package tracker does not prevent slot and cpv conflicts from occurring. Instead, it allows them to be recorded
+ and the ``conflicts()`` and ``slot_conflicts()`` method will cause the package tracker to look at its internal data
+ structures and generate ``PackageConflict()`` objects for each conflict it finds.
+
+ The ``match()`` method is used extensively by ``depgraph.py`` to find packages that match a particular dependency
+ atom. The code now also supports soname dependencies.
+
+ **Future Functionality**
+
+ The package tracker may be extended in the future to track additional useful information:
+
+ * Packages that block one another. This information is not currently injected into the package tracker.
+
+ * Sub-slot conflicts. It is possible to identify situations where a to-be-installed package is in a new sub-slot.
+ In this case, the depgraph can be queried for parents of this dependency, and these parents can be scheduled
+ to be rebuilt.
+
+ :ivar _cp_pkg_map: The collection of to-be-installed (not yet merged) packages. We care about conflicts in these
+ packages.
+ :ivar _cp_vdb_pkg_map: The collection of already-installed packages.
+ :ivar _multi_pkgs: A list of keys in ``self._cp_pkg_map`` that have potential slot and cpv conflicts.
+ :ivar _replacing: The mechanism by which ``PackageTracker`` records to-be-installed packages that 'cover up'
+ already-installed packages. ``self._replacing[cp_key] = [ new_pkg_that_replaced_cp_key... ]``.
+ :ivar _replaced_by: ``self.replaced_by[cp_key] == [ replaced_pkg_1, replaced_pkg_2 ]``
"""
def __init__(self, soname_deps=False):
+
"""
- @param soname_deps: enable soname match support
- @type soname_deps: bool
+ :param soname_deps bool: Determines whether support for soname deps should be enabled or not.
"""
- # Mapping from package keys to set of packages.
+
self._cp_pkg_map = collections.defaultdict(list)
self._cp_vdb_pkg_map = collections.defaultdict(list)
- # List of package keys that may contain conflicts.
- # The insetation order must be preserved.
self._multi_pkgs = []
# Cache for result of conflicts().
self._conflicts_cache = None
- # Records for each pulled package which installed package
- # are replaced.
self._replacing = collections.defaultdict(list)
- # Records which pulled packages replace this package.
self._replaced_by = collections.defaultdict(list)
self._match_cache = collections.defaultdict(dict)
@@ -258,7 +309,7 @@ class PackageTracker(object):
Iterates over present slot conflicts.
This is only intended for consumers that haven't been
updated to deal with other kinds of conflicts.
- This funcion should be removed once all consumers are updated.
+ This function should be removed once all consumers are updated.
"""
return (conflict for conflict in self.conflicts() \
if conflict.description == "slot conflict")
next reply other threads:[~2017-10-04 0:30 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 0:30 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-12-19 5:15 [gentoo-commits] proj/portage:master commit in: pym/_emerge/resolver/ Zac Medico
2016-05-27 8:33 Alexander Berntsen
2015-08-03 18:36 Zac Medico
2015-07-29 18:44 Zac Medico
2014-12-13 14:51 Arfrever Frehtes Taifersar Arahesis
2014-08-23 7:21 Zac Medico
2014-02-23 21:38 Sebastian Luther
2014-02-05 19:42 Sebastian Luther
2014-02-05 19:42 Sebastian Luther
2013-03-20 20:32 Zac Medico
2013-03-20 19:23 Zac Medico
2013-03-18 21:28 Zac Medico
2013-03-18 21:12 Zac Medico
2013-03-18 20:58 Zac Medico
2013-02-28 0:25 Zac Medico
2013-02-28 0:12 Zac Medico
2013-02-27 23:39 Zac Medico
2013-01-24 1:18 Zac Medico
2012-10-15 17:17 Arfrever Frehtes Taifersar Arahesis
2012-10-15 4:06 Arfrever Frehtes Taifersar Arahesis
2012-10-14 20:02 Arfrever Frehtes Taifersar Arahesis
2012-10-14 19:54 Arfrever Frehtes Taifersar Arahesis
2012-10-14 2:53 Zac Medico
2012-10-14 2:44 Zac Medico
2012-09-25 2:00 Zac Medico
2012-09-24 3:12 Zac Medico
2012-09-14 2:08 Zac Medico
2012-09-14 1:04 Zac Medico
2012-06-27 21:56 Zac Medico
2012-06-23 6:00 Zac Medico
2012-06-21 4:43 Zac Medico
2012-06-20 21:24 Zac Medico
2012-04-05 19:37 Zac Medico
2012-03-22 19:00 Zac Medico
2012-03-22 18:10 Zac Medico
2012-03-22 17:38 Zac Medico
2012-03-22 17:15 Zac Medico
2012-03-13 17:22 Zac Medico
2012-01-28 2:23 Arfrever Frehtes Taifersar Arahesis
2012-01-28 1:51 Arfrever Frehtes Taifersar Arahesis
2012-01-23 17:13 Arfrever Frehtes Taifersar Arahesis
2012-01-22 3:57 Arfrever Frehtes Taifersar Arahesis
2012-01-22 3:47 Arfrever Frehtes Taifersar Arahesis
2011-11-18 5:58 Zac Medico
2011-11-18 1:43 Zac Medico
2011-11-07 18:34 Zac Medico
2011-11-07 7:37 Zac Medico
2011-10-19 21:32 Zac Medico
2011-10-19 21:25 Zac Medico
2011-10-02 20:11 Zac Medico
2011-09-17 17:51 Zac Medico
2011-07-27 10:34 Zac Medico
2011-07-10 13:35 Zac Medico
2011-07-10 12:23 Zac Medico
2011-07-10 10:41 Zac Medico
2011-07-10 1:58 Zac Medico
2011-07-10 1:31 Zac Medico
2011-07-09 22:24 Zac Medico
2011-06-21 8:15 Zac Medico
2011-06-11 1:31 Zac Medico
2011-03-15 22:59 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=1507076816.8fba660fb08ddd468d934c7478dcfc8015330e9b.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