Commit 3d0da5e5 authored by Michael Schaller's avatar Michael Schaller

apt_pkg.Dependency.all_targets: Fix the documentation

The documentation for apt_pkg.Dependency.all_targets had the following issues:
1) The underlying Apt method pkgCache::DepIterator::AllTargets does not check
   for conflicts. The Apt documentation for all_targets reads as follows:
   "It includes every possible package-version that could satisfy the
   dependency."

2) The assumption with regards to target selection is wrong.  The last Version
   returned by all_targets is often of foreign architecture and hence selecting
   the last Version in the list doesn't lead "to results being very close to
   the normal package installation".

   Example code that highlights the issue:
    for pkg in (cache["bidentd"], cache["bidentd:i386"]):
        print("Package: %s" % pkg)
        for ver in pkg.versions:
            print("  Version: %s" % ver)
            for dep in ver.get_dependencies("PreDepends", "Depends"):
                print("    Dependency: %s" % dep)
                for bdep in dep:
                    print("      BaseDependency: %s" % bdep)
                    for tver in bdep._dep.all_targets():
                        print("        Target: %s=%s" % (
                            tver.parent_pkg.get_fullname(True), tver.ver_str))

   Output:
    Package: bidentd
      Version: bidentd=1.1.4-1.1
        Dependency: Depends: libc6 >= 2.4
          BaseDependency: Depends: libc6 >= 2.4
            Target: libc6=2.21-0ubuntu4
        Dependency: Depends: libstdc++6 >= 4.1.1
          BaseDependency: Depends: libstdc++6 >= 4.1.1
            Target: libstdc++6=4.9.2-10ubuntu13
        Dependency: Depends: debconf >= 0.5 | debconf-2.0
          BaseDependency: Depends: debconf >= 0.5
            Target: debconf=1.5.55ubuntu2
          BaseDependency: Depends: debconf-2.0
            Target: debconf=1.5.55ubuntu2
            Target: cdebconf=0.192ubuntu1
        Dependency: Depends: netbase
          BaseDependency: Depends: netbase
            Target: netbase=5.3
        Dependency: Depends: debconf
          BaseDependency: Depends: debconf
            Target: debconf=1.5.55ubuntu2
        Dependency: Depends: openbsd-inetd | inet-superserver
          BaseDependency: Depends: openbsd-inetd
            Target: openbsd-inetd=0.20091229-2ubuntu3
            Target: openbsd-inetd:i386=0.20091229-2ubuntu3
          BaseDependency: Depends: inet-superserver
            Target: openbsd-inetd:i386=0.20091229-2ubuntu3
            Target: rlinetd=0.9-3
            Target: inetutils-inetd=2:1.9.2.39.3a460-3
            Target: xinetd=1:2.3.15-3ubuntu1
            Target: openbsd-inetd=0.20091229-2ubuntu3
    Package: bidentd:i386
      Version: bidentd:i386=1.1.4-1.1
        Dependency: Depends: libc6 >= 2.4
          BaseDependency: Depends: libc6 >= 2.4
            Target: libc6:i386=2.21-0ubuntu4
        Dependency: Depends: libstdc++6 >= 4.1.1
          BaseDependency: Depends: libstdc++6 >= 4.1.1
            Target: libstdc++6:i386=4.9.2-10ubuntu13
        Dependency: Depends: debconf >= 0.5 | debconf-2.0
          BaseDependency: Depends: debconf >= 0.5
            Target: debconf=1.5.55ubuntu2
          BaseDependency: Depends: debconf-2.0
            Target: cdebconf:i386=0.192ubuntu1
            Target: debconf=1.5.55ubuntu2
        Dependency: Depends: netbase
          BaseDependency: Depends: netbase
            Target: netbase=5.3
        Dependency: Depends: debconf
          BaseDependency: Depends: debconf
            Target: debconf=1.5.55ubuntu2
        Dependency: Depends: openbsd-inetd | inet-superserver
          BaseDependency: Depends: openbsd-inetd
            Target: openbsd-inetd:i386=0.20091229-2ubuntu3
            Target: openbsd-inetd=0.20091229-2ubuntu3
          BaseDependency: Depends: inet-superserver
            Target: rlinetd:i386=0.9-3
            Target: inetutils-inetd:i386=2:1.9.2.39.3a460-3
            Target: xinetd:i386=1:2.3.15-3ubuntu1
            Target: openbsd-inetd:i386=0.20091229-2ubuntu3
            Target: openbsd-inetd=0.20091229-2ubuntu3
parent c577c7ca
......@@ -1004,13 +1004,8 @@ Example:
.. method:: all_targets
A list of :class:`Version` objects which satisfy the dependency,
and do not conflict with already installed ones.
From my experience, if you use this method to select the target
version, it is the best to select the last item unless any of the
other candidates is already installed. This leads to results being
very close to the normal package installation.
A list of all possible target :class:`Version` objects which satisfy
this dependency.
.. method:: smart_target_pkg
......
......@@ -1388,7 +1388,8 @@ static PyMethodDef DependencyMethods[] =
"of the target package."},
{"all_targets",DepAllTargets,METH_VARARGS,
"all_targets() -> list\n\n"
"A list of all apt_pkg.Version objects satisfying the dependency."},
"A list of all possible apt_pkg.Version objects which satisfy this\n"
"dependency."},
{}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment