From c1c52888208a06d1b4983ac9194e512ba4bc481a Mon Sep 17 00:00:00 2001 From: worch Date: Sat, 23 Aug 2008 01:02:09 -0500 Subject: [PATCH] LinkageMap.findConsumers catches shadowed obj keys. --- pym/portage/dbapi/vartree.py | 29 +++++++++++++---------------- vartree.py.2.2_rc8.patch | 44 ++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index d2a9cb6..c96fbac 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -169,6 +169,9 @@ class LinkageMap(object): def __eq__(self, other): return self._key == other._key + def __ne__(self, other): + return self._key != other._key + def _generate_object_key(self, object): """ Generate object key for a given object. @@ -522,10 +525,7 @@ class LinkageMap(object): """ Find consumers of an object or object key. - This method may be called with a key from _obj_properties. If this - method is going to be called with an object key, to avoid not catching - shadowed libraries, do not pass new _ObjectKey instances to this method. - Instead pass the obj as a string. + This method may be called with a key from _obj_properties. In some cases, not all consumers are returned. This may occur when an soname symlink referencing a library is in an object's runpath while @@ -564,19 +564,16 @@ class LinkageMap(object): # same soname and the master link points to that # other version, this lib will be shadowed and won't # have any consumers. - if not isinstance(obj, self._ObjectKey): - soname = self._obj_properties[obj_key][3] - obj_dir = os.path.dirname(obj) + soname = self._obj_properties[obj_key][3] + shadowed_library = True + for obj_dir in objs_dirs: master_link = os.path.join(obj_dir, soname) - try: - master_st = os.stat(master_link) - obj_st = os.stat(obj) - except OSError: - pass - else: - if (obj_st.st_dev, obj_st.st_ino) != \ - (master_st.st_dev, master_st.st_ino): - return set() + master_link_obj_key = self._ObjectKey(master_link) + if obj_key == master_link_obj_key: + shadowed_library = False + break + if shadowed_library: + return set() arch, _, _, soname, _ = self._obj_properties[obj_key] if soname in self._libs and arch in self._libs[soname]: diff --git a/vartree.py.2.2_rc8.patch b/vartree.py.2.2_rc8.patch index b27f09f..9a99658 100644 --- a/vartree.py.2.2_rc8.patch +++ b/vartree.py.2.2_rc8.patch @@ -1,6 +1,6 @@ --- vartree.py.2.2_rc8 2008-08-20 20:49:18.000000000 -0500 -+++ pym/portage/dbapi/vartree.py 2008-08-22 23:57:24.000000000 -0500 -@@ -139,14 +139,74 @@ ++++ pym/portage/dbapi/vartree.py 2008-08-23 01:02:09.000000000 -0500 +@@ -139,14 +139,77 @@ return rValue class LinkageMap(object): @@ -36,6 +36,9 @@ + def __eq__(self, other): + return self._key == other._key + ++ def __ne__(self, other): ++ return self._key != other._key ++ + def _generate_object_key(self, object): + """ + Generate object key for a given object. @@ -77,7 +80,7 @@ obj_properties = {} lines = [] for cpv in self._dbapi.cpv_all(): -@@ -176,97 +236,109 @@ +@@ -176,97 +239,109 @@ # insufficient field length continue arch = fields[0] @@ -236,7 +239,7 @@ validLibraries = set() # It could be the case that the library to satisfy the soname is # not in the obj's runpath, but a symlink to the library is (eg -@@ -274,67 +346,60 @@ +@@ -274,67 +349,60 @@ # does not catalog symlinks, broken or missing symlinks may go # unnoticed. As a result of these cases, check that a file with # the same name as the soname exists in obj's runpath. @@ -333,7 +336,7 @@ providers is a mapping of soname -> set-of-library-paths returned from the findProviders method. -@@ -342,118 +407,189 @@ +@@ -342,118 +410,183 @@ rValue = {} if not self._libs: self.rebuild() @@ -495,10 +498,7 @@ + """ + Find consumers of an object or object key. + -+ This method may be called with a key from _obj_properties. If this -+ method is going to be called with an object key, to avoid not catching -+ shadowed libraries, do not pass new _ObjectKey instances to this method. -+ Instead pass the obj as a string. ++ This method may be called with a key from _obj_properties. + + In some cases, not all consumers are returned. This may occur when + an soname symlink referencing a library is in an object's runpath while @@ -561,7 +561,17 @@ - if (obj_st.st_dev, obj_st.st_ino) != \ - (master_st.st_dev, master_st.st_ino): - return set() -- ++ soname = self._obj_properties[obj_key][3] ++ shadowed_library = True ++ for obj_dir in objs_dirs: ++ master_link = os.path.join(obj_dir, soname) ++ master_link_obj_key = self._ObjectKey(master_link) ++ if obj_key == master_link_obj_key: ++ shadowed_library = False ++ break ++ if shadowed_library: ++ return set() + - rValue = set() - for soname in self._libs: - for arch in self._libs[soname]: @@ -573,20 +583,6 @@ - rValue.add(x) - elif realpath(obj_dir) in path: - rValue.add(x) -+ if not isinstance(obj, self._ObjectKey): -+ soname = self._obj_properties[obj_key][3] -+ obj_dir = os.path.dirname(obj) -+ master_link = os.path.join(obj_dir, soname) -+ try: -+ master_st = os.stat(master_link) -+ obj_st = os.stat(obj) -+ except OSError: -+ pass -+ else: -+ if (obj_st.st_dev, obj_st.st_ino) != \ -+ (master_st.st_dev, master_st.st_ino): -+ return set() -+ + arch, _, _, soname, _ = self._obj_properties[obj_key] + if soname in self._libs and arch in self._libs[soname]: + # For each potential consumer, add it to rValue if an object from the -- 2.11.4.GIT