From d8200c669ebfbc76e1ed8afc243be15c93988f0d Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Fri, 31 Jul 2009 23:47:22 +0000 Subject: [PATCH] Add some logic to copy files as links if they're links, and resolve all links to the final destination file then copy that. This is just part of the solution. The final solution will be to remove all symbolic links and change all library references (to symbolic links) to their actual versioned filename. Updates #964 Originally committed to SVN as r3342. --- aegisub/tools/osx-fix-libs.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/aegisub/tools/osx-fix-libs.py b/aegisub/tools/osx-fix-libs.py index d553a13ec..606a5c4d5 100755 --- a/aegisub/tools/osx-fix-libs.py +++ b/aegisub/tools/osx-fix-libs.py @@ -4,6 +4,7 @@ import re import sys import os import shutil +import stat is_bad_lib = re.compile(r'(/usr/local|/opt)').match is_sys_lib = re.compile(r'(/usr|/System)').match @@ -28,15 +29,27 @@ def collectlibs(lib, masterlist, targetdir): sys.exit("Linking with library in blacklisted location: " + l) if not is_sys_lib(l) and not l in masterlist: locallist.append(l) - print "found ", l, - shutil.copy(l, targetdir) - print " ...copied to target" + print "found %s:" % l + + check = l + 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 + break + + if os.path.islink(check): + os.system("cp -fR '%s' '%s'" % (check, targetdir)) + print " LINK %s ... copied to target" % 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) +exit; binname = sys.argv[1] targetdir = os.path.dirname(binname) print "Searching for libraries in ", binname, "..."