1 |
Author: genone |
2 |
Date: 2008-04-26 01:10:52 +0000 (Sat, 26 Apr 2008) |
3 |
New Revision: 9978 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dbapi/vartree.py |
7 |
Log: |
8 |
add LibraryPackageMap replacement using NEEDED.2 files |
9 |
|
10 |
Modified: main/trunk/pym/portage/dbapi/vartree.py |
11 |
=================================================================== |
12 |
--- main/trunk/pym/portage/dbapi/vartree.py 2008-04-25 22:26:23 UTC (rev 9977) |
13 |
+++ main/trunk/pym/portage/dbapi/vartree.py 2008-04-26 01:10:52 UTC (rev 9978) |
14 |
@@ -125,6 +125,76 @@ |
15 |
rValue[self._data[cps][0]] = self._data[cps][2] |
16 |
return rValue |
17 |
|
18 |
+class LinkageMap(object): |
19 |
+ def __init__(self, vardbapi): |
20 |
+ self._dbapi = vardbapi |
21 |
+ self._libs = {} |
22 |
+ self._obj_properties = {} |
23 |
+ self._defpath = getlibpaths() |
24 |
+ |
25 |
+ def rebuild(self): |
26 |
+ libs = {} |
27 |
+ obj_properties = {} |
28 |
+ for cpv in self._dbapi.cpv_all(): |
29 |
+ lines = grabfile(self._dbapi.getpath(cpv, filename="NEEDED.2")) |
30 |
+ for l in lines: |
31 |
+ fields = l.strip("\n").split(";") |
32 |
+ if len(fields) < 5: |
33 |
+ print "Error", fields |
34 |
+ # insufficient field length |
35 |
+ continue |
36 |
+ arch = fields[0] |
37 |
+ obj = fields[1] |
38 |
+ soname = fields[2] |
39 |
+ path = fields[3].replace("${ORIGIN}", os.path.dirname(obj)).replace("$ORIGIN", os.path.dirname(obj)).split(":") |
40 |
+ needed = fields[4].split(",") |
41 |
+ if soname: |
42 |
+ libs.setdefault(soname, {arch: {"providers": [], "consumers": []}}) |
43 |
+ libs[soname].setdefault(arch, {"providers": [], "consumers": []}) |
44 |
+ libs[soname][arch]["providers"].append(obj) |
45 |
+ for x in needed: |
46 |
+ libs.setdefault(x, {arch: {"providers": [], "consumers": []}}) |
47 |
+ libs[x].setdefault(arch, {"providers": [], "consumers": []}) |
48 |
+ libs[x][arch]["consumers"].append(obj) |
49 |
+ obj_properties[obj] = (arch, path, needed, soname) |
50 |
+ |
51 |
+ self._libs = libs |
52 |
+ self._obj_properties = obj_properties |
53 |
+ |
54 |
+ def findProviders(self, obj): |
55 |
+ obj = os.path.realpath(obj) |
56 |
+ rValue = {} |
57 |
+ if obj not in self._obj_properties: |
58 |
+ raise KeyError("%s not in object list" % obj) |
59 |
+ arch, path, needed, soname = self._obj_properties[obj] |
60 |
+ path.extend(self._defpath) |
61 |
+ path = [os.path.realpath(x) for x in path] |
62 |
+ for x in needed: |
63 |
+ rValue[x] = set() |
64 |
+ if x not in self._libs or arch not in self._libs[x]: |
65 |
+ continue |
66 |
+ for y in self._libs[x][arch]["providers"]: |
67 |
+ if x[0] == os.sep and os.path.realpath(x) == os.path.realpath(y): |
68 |
+ rValue[x].add(y) |
69 |
+ elif os.path.realpath(os.path.dirname(y)) in path: |
70 |
+ rValue[x].add(y) |
71 |
+ return rValue |
72 |
+ |
73 |
+ def findConsumers(self, obj): |
74 |
+ obj = os.path.realpath(obj) |
75 |
+ rValue = set() |
76 |
+ for soname in self._libs: |
77 |
+ for arch in self._libs[soname]: |
78 |
+ if obj in self._libs[soname][arch]["providers"]: |
79 |
+ for x in self._libs[soname][arch]["consumers"]: |
80 |
+ path = self._obj_properties[x][1] |
81 |
+ path = [os.path.realpath(y) for y in path+self._defpath] |
82 |
+ if soname[0] == os.sep and os.path.realpath(soname) == os.path.realpath(obj): |
83 |
+ rValue.add(x) |
84 |
+ elif os.path.realpath(os.path.dirname(obj)) in path: |
85 |
+ rValue.add(x) |
86 |
+ return rValue |
87 |
+ |
88 |
class LibraryPackageMap(object): |
89 |
""" This class provides a library->consumer mapping generated from VDB data """ |
90 |
def __init__(self, filename, vardbapi): |
91 |
@@ -1608,7 +1678,7 @@ |
92 |
# only preserve the lib if there is no other copy in the search path |
93 |
for path in getlibpaths(): |
94 |
fullname = os.path.join(path, lib) |
95 |
- if fullname not in old_contents and os.path.exists(fullname): |
96 |
+ if fullname not in old_contents and os.path.exists(fullname) and lib in preserve_libs: |
97 |
preserve_libs.remove(lib) |
98 |
|
99 |
# get the real paths for the libs |
100 |
|
101 |
-- |
102 |
gentoo-commits@l.g.o mailing list |