Merge r3977 (osx-fix-libs) from 2.1.8 closes #964.
Originally committed to SVN as r3978.
This commit is contained in:
parent
6006fb5bba
commit
361f5228ba
1 changed files with 21 additions and 4 deletions
|
@ -10,6 +10,7 @@ is_bad_lib = re.compile(r'(/usr/local|/opt)').match
|
||||||
is_sys_lib = re.compile(r'(/usr|/System)').match
|
is_sys_lib = re.compile(r'(/usr|/System)').match
|
||||||
otool_libname_extract = re.compile(r'\s+(/.*?)[\(\s:]').search
|
otool_libname_extract = re.compile(r'\s+(/.*?)[\(\s:]').search
|
||||||
goodlist = []
|
goodlist = []
|
||||||
|
link_map = {}
|
||||||
|
|
||||||
def otool(cmdline):
|
def otool(cmdline):
|
||||||
pipe = os.popen("otool " + cmdline, 'r')
|
pipe = os.popen("otool " + cmdline, 'r')
|
||||||
|
@ -18,9 +19,10 @@ def otool(cmdline):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def collectlibs(lib, masterlist, targetdir):
|
def collectlibs(lib, masterlist, targetdir):
|
||||||
global goodlist
|
global goodlist, link_map
|
||||||
liblist = otool("-L '" + lib + "'")
|
liblist = otool("-L '" + lib + "'")
|
||||||
locallist = []
|
locallist = []
|
||||||
|
|
||||||
for l in liblist:
|
for l in liblist:
|
||||||
lr = otool_libname_extract(l)
|
lr = otool_libname_extract(l)
|
||||||
if not lr: continue
|
if not lr: continue
|
||||||
|
@ -32,20 +34,25 @@ def collectlibs(lib, masterlist, targetdir):
|
||||||
print "found %s:" % l
|
print "found %s:" % l
|
||||||
|
|
||||||
check = l
|
check = l
|
||||||
|
link_list = []
|
||||||
while check:
|
while check:
|
||||||
if os.path.isfile(check) and not os.path.islink(check):
|
if os.path.isfile(check) and not os.path.islink(check):
|
||||||
os.system("cp '%s' '%s'" % (check, targetdir))
|
os.system("cp '%s' '%s'" % (check, targetdir))
|
||||||
print " FILE %s ... copied to target" % check
|
print " FILE %s ... copied to target" % check
|
||||||
|
if link_list:
|
||||||
|
for link in link_list:
|
||||||
|
link_map[link] = os.path.basename(check)
|
||||||
break
|
break
|
||||||
|
|
||||||
if os.path.islink(check):
|
if os.path.islink(check):
|
||||||
os.system("cp -fR '%s' '%s'" % (check, targetdir))
|
print " LINK %s" % check
|
||||||
print " LINK %s ... copied to target" % check
|
link_list.append(os.path.basename(check))
|
||||||
check = os.path.dirname(check) + "/" + os.readlink(check)
|
check = os.path.dirname(check) + "/" + os.readlink(check)
|
||||||
|
|
||||||
elif not l in goodlist and not l in masterlist:
|
elif not l in goodlist and not l in masterlist:
|
||||||
goodlist.append(l)
|
goodlist.append(l)
|
||||||
masterlist.extend(locallist)
|
masterlist.extend(locallist)
|
||||||
|
|
||||||
for l in locallist:
|
for l in locallist:
|
||||||
collectlibs(l, masterlist, targetdir)
|
collectlibs(l, masterlist, targetdir)
|
||||||
|
|
||||||
|
@ -56,6 +63,7 @@ print "Searching for libraries in ", binname, "..."
|
||||||
libs = [binname]
|
libs = [binname]
|
||||||
collectlibs(sys.argv[1], libs, targetdir)
|
collectlibs(sys.argv[1], libs, targetdir)
|
||||||
|
|
||||||
|
|
||||||
print
|
print
|
||||||
print "System libraries used..."
|
print "System libraries used..."
|
||||||
goodlist.sort()
|
goodlist.sort()
|
||||||
|
@ -68,12 +76,21 @@ print "Fixing library install names..."
|
||||||
in_tool_cmdline = "install_name_tool "
|
in_tool_cmdline = "install_name_tool "
|
||||||
for lib in libs:
|
for lib in libs:
|
||||||
libbase = os.path.basename(lib)
|
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))
|
in_tool_cmdline = in_tool_cmdline + ("-change '%s' '@executable_path/%s' " % (lib, libbase))
|
||||||
for lib in libs:
|
for lib in libs:
|
||||||
libbase = os.path.basename(lib)
|
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))
|
os.system("%s -id '@executable_path/%s' '%s/%s'" % (in_tool_cmdline, libbase, targetdir, libbase))
|
||||||
print lib, "-> @executable_path/" + libbase
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
print
|
print
|
||||||
print "All done!"
|
print "All done!"
|
||||||
|
|
Loading…
Reference in a new issue