From 28318a55fa8c28f651ec6bf2213ce5e7dff52116 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 20 Jun 2008 11:26:08 +0000 Subject: [PATCH] Implemented the missing part in preserve-libs for Mach-O systems. 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 | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 70348ded6..3cbc8dee7 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -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() == "": -- 2.26.2