2008/9/25 James <[EMAIL PROTECTED]>:

> Do you have any further advice, more detail or some more formalized 
> methodology
> to 'clean' the world file, in addition to what you have stated above?
>

Every entry in the world file that has a reverse dependency could be
removed. Unfortunately there is no tool I know which can calculate
reverse dependencies correctly. Maybe there is some functionality in
pkgcore or paludis which I am not aware of. So others need to inform
us about this.

However, this question has already been raised and Alber Hopkins
attached a python script in an earlier thread which should show
unneeded entries in the world file. It did not work for me but I have
attached it, maybe you have more luck than I.

The solution I use is app-portage/udept. It is not maintained anymore
so I recommend to use the ebuild from this bug [1] which at least has
a few advantages over the ebuild in the tree. Udept used to be a
powerful script but a few functions do not work properly anymore. The
option for cleaning the world file works reliable though. Just invoke
it with "dep -w"

[1] http://bugs.gentoo.org/show_bug.cgi?id=172611

Regards,

Daniel
#!/usr/bin/python
"""
Report any packages in world which have direct dependencies also in world
"""

__version__ = (0,3,0)

import os
import sys
sys.path.insert(0, '/usr/lib/gentoolkit/pym')
os.environ['PORTAGE_CALLER'] = 'repoman'

import portage
TREE = portage.db["/"]["vartree"]

import gentoolkit


def get_versions_installed(pkg):
    """
    Return a list containt versions of pkg installed (in cpv format)
    may be an empty list.
    """
    return TREE.dbapi.match(pkg)


def get_world():
    """Return a list of all packages in world"""
    _file = sys.stdin
    _list = [line.strip() for line in _file]
    return _list

def get_deps(pkg):
    """Return a list of all packages depending on pkg (directly)"""
    deps = set()
    for cpv in get_versions_installed(pkg):
        gentoolkit_pkg = gentoolkit.Package(cpv)
        rdeps = [i[2] for i in gentoolkit_pkg.get_runtime_deps() if not
                i[2].startswith('virtual/')]
        for rdep in rdeps:
            split = portage.pkgsplit(rdep)
            if split is not None:
                deps.add(split[0])
            else:
                deps.add(rdep)

        pdeps = [i[2] for i in gentoolkit_pkg.get_postmerge_deps() if not
                i[2].startswith('virtual/')]
        for pdep in pdeps:
            split = portage.pkgsplit(pdep)
            if split is not None:
                deps.add(split[0])
            else:
                deps.add(pdep)
        #print deps
    #command= '/usr/bin/equery -q -C d %s' % pkg
    #pipe = os.popen(command, 'r')
    #_list = [portage.pkgsplit(line.strip())[0] for line in pipe]
    return deps

if __name__ == '__main__':
    world = get_world()
    for pkg in world:
        deps = get_deps(pkg)
        for dep in deps:
            if (dep != pkg) and (dep in world):
                print '%(pkg)s already depends on %(dep)s' % locals()

Reply via email to