Beispiel #1
0
def copy_missing_libraries_of_file(root, path):
	'''
	Copy missing libraries of file 'path'.
	A library is missing if it is not in 'root' or if it is not a system lib.
	'''
	# Change install names
	linkedLib = binary_utilities.get_linked_libraries_of_file(path)
	for lib in linkedLib:
		newLibLink = binary_utilities.get_library_basename(lib)
		if not binary_utilities.is_system_library(lib) \
			and not os.path.exists(os.path.join(root, newLibLink)):
			print "Copying", lib, "in", root + "..."
			shutil.copy(lib, root)
			# Call recursively copy_missing_libraries_of_file because adding 
			# newLibLink may have added some new dependencies.
			copy_missing_libraries_of_file(root, os.path.join(root, newLibLink))
Beispiel #2
0
def update_links_of_file_with_libraries(binary, availableLibs, executable = None):
	'''
	Update all install_name of binary file path.
	Libraries are looked for in availableLibs.
	'''
	replacePath = None
	if (executable != None):
		replacePath = os.path.dirname(os.path.dirname(executable))

	libraries = binary_utilities.get_linked_libraries_of_file(binary)

	for lib in libraries:
                libName = binary_utilities.get_library_basename(lib)
                if availableLibs.has_key(libName):
                        newLib = availableLibs[libName]
                        if replacePath != None:
                                newLib = newLib.replace(replacePath, "@executable_path/..")
                        command = "install_name_tool -change %(lib)s %(newlib)s %(bin)s" \
                                % { "lib" : lib, "newlib" : newLib, "bin" : binary }
                        print command
                        os.popen(command)