fix rpath on kiwix binaries

This commit is contained in:
reg_ 2012-12-03 08:52:11 +00:00
parent 8feb6d7a98
commit 11283444a7

View File

@ -19,14 +19,20 @@ if not os.path.exists(component):
print(u"Unable to access component at: %s" % component) print(u"Unable to access component at: %s" % component)
exit(1) exit(1)
if not component.endswith('.dylib'): # we'll also allow binaries to be fixed.
print(u"%s is not a dylib component" % component) #
exit(1) # if not component.endswith('.dylib'):
# print(u"%s is not a dylib component" % component)
# exit(1)
print("Fixing %s..." % component) print("Fixing %s..." % component)
basename = os.path.basename(component) basename = os.path.basename(component)
try:
name, ext = basename.rsplit('.', 1) name, ext = basename.rsplit('.', 1)
except ValueError:
name = basename
ext = ''
libname = u'lib%s%s.0.dylib' % (name[0].upper(), name[1:]) libname = u'lib%s%s.0.dylib' % (name[0].upper(), name[1:])
# run otool to get a list of deps. # run otool to get a list of deps.
@ -38,7 +44,8 @@ for line in otool_out.split('\n'):
or 'libSystem' in line or 'libSystem' in line
or 'libstdc++' in line or 'libstdc++' in line
or ':' in line or ':' in line
or not len(line)): or not len(line)
or 'aria2c' in basename):
continue continue
path, junk = line.strip().split(' (', 1) path, junk = line.strip().split(' (', 1)
# erroneous_links.append(path) # erroneous_links.append(path)
@ -54,7 +61,9 @@ for line in otool_out.split('\n'):
# is it a library link? # is it a library link?
match = re.match(r'lib([a-z\_\-\d]+)([\.?\d]*)\.dylib', _basename) match = re.match(r'lib([a-z\_\-\d]+)([\.?\d]*)\.dylib', _basename)
if match: if match:
print("match: %s" % match.groups()[0])
newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0] newpath = u'@executable_path/../Frameworks/lib%s.dylib' % match.groups()[0]
print('install_name_tool -change %s %s %s' % (path, newpath, component))
os.system('install_name_tool -change %s %s %s' % (path, newpath, component)) os.system('install_name_tool -change %s %s %s' % (path, newpath, component))
continue continue