From 361f5228ba2cd56afc6cbf4c1b2882e90ff23386 Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Tue, 12 Jan 2010 13:00:24 +0000 Subject: [PATCH] Merge r3977 (osx-fix-libs) from 2.1.8 closes #964. Originally committed to SVN as r3978. --- aegisub/tools/osx-fix-libs.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/aegisub/tools/osx-fix-libs.py b/aegisub/tools/osx-fix-libs.py index 606a5c4d5..1426ffffa 100755 --- a/aegisub/tools/osx-fix-libs.py +++ b/aegisub/tools/osx-fix-libs.py @@ -10,6 +10,7 @@ is_bad_lib = re.compile(r'(/usr/local|/opt)').match is_sys_lib = re.compile(r'(/usr|/System)').match otool_libname_extract = re.compile(r'\s+(/.*?)[\(\s:]').search goodlist = [] +link_map = {} def otool(cmdline): pipe = os.popen("otool " + cmdline, 'r') @@ -18,9 +19,10 @@ def otool(cmdline): return output def collectlibs(lib, masterlist, targetdir): - global goodlist + global goodlist, link_map liblist = otool("-L '" + lib + "'") locallist = [] + for l in liblist: lr = otool_libname_extract(l) if not lr: continue @@ -32,20 +34,25 @@ def collectlibs(lib, masterlist, targetdir): print "found %s:" % l check = l + link_list = [] while check: if os.path.isfile(check) and not os.path.islink(check): os.system("cp '%s' '%s'" % (check, targetdir)) print " FILE %s ... copied to target" % check + if link_list: + for link in link_list: + link_map[link] = os.path.basename(check) break if os.path.islink(check): - os.system("cp -fR '%s' '%s'" % (check, targetdir)) - print " LINK %s ... copied to target" % check + print " LINK %s" % check + link_list.append(os.path.basename(check)) check = os.path.dirname(check) + "/" + os.readlink(check) elif not l in goodlist and not l in masterlist: goodlist.append(l) masterlist.extend(locallist) + for l in locallist: collectlibs(l, masterlist, targetdir) @@ -56,6 +63,7 @@ print "Searching for libraries in ", binname, "..." libs = [binname] collectlibs(sys.argv[1], libs, targetdir) + print print "System libraries used..." goodlist.sort() @@ -68,12 +76,21 @@ print "Fixing library install names..." in_tool_cmdline = "install_name_tool " for lib in libs: libbase = os.path.basename(lib) + if libbase in link_map: + libbase = link_map[libbase] in_tool_cmdline = in_tool_cmdline + ("-change '%s' '@executable_path/%s' " % (lib, libbase)) for lib in libs: libbase = os.path.basename(lib) + + if libbase in link_map: + libbase = link_map[libbase] + print "%s -> @executable_path/%s (REMAPPED)" % (lib, libbase) + else: + print "%s -> @executable_path/%s" % (lib, libbase) + os.system("%s -id '@executable_path/%s' '%s/%s'" % (in_tool_cmdline, libbase, targetdir, libbase)) - print lib, "-> @executable_path/" + libbase sys.stdout.flush() + print print "All done!"