• Michael Schaller's avatar
    apt_pkg.Dependency.all_targets: Fix the documentation · 3d0da5e5
    Michael Schaller authored
    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
    3d0da5e5
Name
Last commit
Last update
..
examples Loading commit data...
source Loading commit data...
Makefile Loading commit data...
client-example.cc Loading commit data...