Implemented the missing part in preserve-libs for Mach-O systems.
authorFabian Groffen <grobian@gentoo.org>
Fri, 20 Jun 2008 11:26:08 +0000 (11:26 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 20 Jun 2008 11:26:08 +0000 (11:26 -0000)
Unfortunately we have to call otool twice for each lib we have
preserved.  Fortunately, it is to be expected that the number of
preserved libs remains low.  Still avoiding the calls to otool and
scanelf at this stage would be really preferable, especially since bash
can do the magic we need to do here a lot easier than python can.

svn path=/main/branches/prefix/; revision=10737

pym/portage/dbapi/vartree.py

index 70348ded68e9a05d19871cbd79703f836b23b298..3cbc8dee76e7b405af76dd8ca85067779e9ee9e8 100644 (file)
@@ -260,14 +260,26 @@ class LinkageMapMachO(object):
 
                # have to call otool for preserved libs here as they aren't 
                # registered in NEEDED.MACHO.2 files
-# TODO: FIXME: ETC.
-#              if self._dbapi.plib_registry and self._dbapi.plib_registry.getPreservedLibs():
-#                      args = [EPREFIX+"/usr/bin/scanelf", "-qF", "%a;%F;%S;%r;%n"]
-#                      for items in self._dbapi.plib_registry.getPreservedLibs().values():
-#                              args += [x.lstrip(".") for x in items]
-#                      proc = subprocess.Popen(args, stdout=subprocess.PIPE)
-#                      output = [l[3:] for l in proc.communicate()[0].split("\n")]
-#                      lines += output
+               if self._dbapi.plib_registry and self._dbapi.plib_registry.getPreservedLibs():
+                       otool = EPREFIX+"/usr/bin/otool"
+                       for items in self._dbapi.plib_registry.getPreservedLibs().values():
+                               for x in items:
+                                       proc = subprocess.Popen([otool, "-DX", x.lstrip(".")],
+                                                       stdout=subprocess.PIPE)
+                                       install_name = proc.communicate()[0].split("\n")[0]
+                                       proc = subprocess.Popen([otool, "-LX", x.lstrip(".")],
+                                                       stdout=subprocess.PIPE)
+                                       output = [l.lstrip() for l in proc.communicate()[0].split("\n")]
+                                       n = ""
+                                       for l in output:
+                                               if l == '':
+                                                       continue
+                                               p = l.rfind(" (compatibility")
+                                               if p != -1:
+                                                       l = l[:p]
+                                               n += "," + l
+
+                                       lines += [x + ";" + install_name + ";" + n.lstrip(",") + "\n"]
 
                for l in lines:
                        if l.strip() == "":