1 # Copyright 2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 from portage
.sets
.libs
import LibraryConsumerSet
6 #from portage.dbapi.vartree import LinkageMap
7 from portage
.sets
import get_boolean
8 from portage
.dbapi
.vartree
import dblink
9 from portage
.versions
import catsplit
11 __all__
= ["MissingLibraryConsumerSet"]
13 class MissingLibraryConsumerSet(LibraryConsumerSet
):
14 description
= "set of packages to emerge due to missing libraries"
15 _operations
= ["merge"]
17 # TODO Redefine __init__() to accept user parameters.
21 # brokenDependencies: binary -> list-of-unsatisfied-sonames,
22 # where binary is an installed binary/library and
23 # list-of-unsatisfied-sonames are sonames required by the binary but
24 # have no corresponding libraries to fulfill the dependency.
25 brokenDependencies
= {}
27 # The following iterates over the contents of all installed packages
28 # in order to find providers for all binaries.
29 for cpv
in self
.dbapi
.cpv_all():
33 mysplit
= catsplit(cpv
)
34 link
= dblink(mysplit
[0], mysplit
[1], myroot
=self
.dbapi
.root
, \
35 mysettings
=self
.dbapi
.settings
, treetype
='vartree', \
36 vartree
=self
.dbapi
.vartree
)
37 for path
in link
.getcontents():
39 providers
= self
.dbapi
.linkmap
.findProviders(path
)
41 # For now, the KeyError will be ignored for non-binaries.
42 # Once the LinkageMap method is implemented, this will be
43 # unnecessary. See below.
47 print '\t', "providers for %s:" % path
48 # Iterate over all providers
49 for key
, value
in providers
.items():
51 print '\t'*2, key
, value
52 # TODO Check that the library exists on the filesystem.
54 # If there are no libraries to satisfy the soname (empty set),
55 # add the soname to the set of missing sonames for that
57 if value
== set() and key
!= '':
58 # key != '' catches cases where findProviders(path)
59 # returns {'': set([])}, which means path has consumers
60 # but no providers eg /lib/ld-2.6.1.so.
61 brokenDependencies
.setdefault(path
, set()).add(key
)
63 print '\t'*3, "Added", path
, "->", key
64 # print '\t'*3, providers
66 # TODO Rather than iterate over the contents of all packages, implement
67 # similar functionality as a new methond in the LinkageMap class by
68 # accessing _obj_properties and _libs.
69 # brokenDependencies = self.dbapi.linkmap.listBrokenDependencies()
71 # FIXME Currently, too many atoms are being emerged because binary
72 # packages are not being handled properly eg openoffice, nvidia-drivers,
73 # sun-jdk. I have to determine if libraries and lib paths should be
74 # masked using /etc/revdep-rebuild/* as done in revdep-rebuild or if
75 # there is a better way to identify and deal with these problematic
78 atoms
= self
.mapPathsToAtoms(set(brokenDependencies
.keys()))
82 print "brokenDependencies:"
83 for x
in sorted(brokenDependencies
.keys()):
84 print x
, "->", brokenDependencies
[x
]
87 for x
in sorted(atoms
):
90 # print "brokenDependencies' atoms:"
91 # # Warning: This might take forever.
92 # for x in sorted(brokenDependencies.keys()):
93 # print x, "->", self.mapPathsToAtoms(set([x]))
97 def singleBuilder(self
, options
, settings
, trees
):
98 debug
= get_boolean(options
, "debug", True)
99 return MissingLibraryConsumerSet(trees
["vartree"].dbapi
, debug
)
100 singleBuilder
= classmethod(singleBuilder
)