15 os.chdir(os.path.join(os.environ[
'LIB3_DIR'],
"lib"))
16 for fileName
in os.listdir(
'.'):
17 if os.path.isfile(fileName):
18 if ".dylib" in fileName:
20 p = subprocess.Popen([
"otool",
"-D", fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
21 out, err = p.communicate()
23 parts = out.decode(
"utf-8").split()
24 parts = parts[1].split(
"/")
26 if not "@rpath" in parts[0]:
30 subprocess.call([
"install_name_tool",
"-id", id, fileName])
32 p = subprocess.Popen([
"otool",
"-L", fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
33 out, err = p.communicate()
35 lines = out.decode(
"utf-8").split(
'\n')
37 if '/opt/homebrew/' in line
or '/usr/local/' in line
or '/opt/X11/lib/' in line
or os.environ[
'LIB3_DIR']
in line
or (
'/' not in line
and 'compatibility' in line):
39 libPath = line.split()[0]
40 parts = libPath.split(
'/')
42 newName =
'@rpath/' + libName
44 subprocess.call([
"install_name_tool",
"-change", libPath, newName, fileName])
45 if os.environ[
'LIB3_DIR']
not in libPath:
46 if not os.path.isfile(os.environ[
'LIB3_DIR'] +
"/lib/" + libName):
48 print(
"copying", libPath, os.environ[
'LIB3_DIR'] +
"/lib" )
49 shutil.copy(libPath, os.environ[
'LIB3_DIR'] +
"/lib")
53 os.chdir(os.path.join(os.environ[
'LIB3_DIR'],
"bin"))
54 for fileName
in os.listdir(
'.'):
55 if os.path.isfile(fileName):
56 line = subprocess.check_output([
'file', fileName]).decode(
"utf-8")
57 if "Mach-O 64-bit executable" in line:
59 p = subprocess.Popen([
"otool",
"-L", fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
60 out, err = p.communicate()
62 lines = out.decode(
"utf-8").split(
'\n')
64 if '/opt/homebrew/' in line
or '/usr/local/' in line
or '/opt/X11/lib/' in line
or os.environ[
'LIB3_DIR']
in line:
66 libPath = line.split()[0]
67 parts = libPath.split(
'/')
69 newName =
'@rpath/' + libName
71 subprocess.call([
"install_name_tool",
"-change", libPath, newName, fileName])
72 if os.environ[
'LIB3_DIR']
not in libPath:
73 if not os.path.isfile(os.environ[
'LIB3_DIR'] +
"/lib/" + libName):
75 print(
"copying", libPath, os.environ[
'LIB3_DIR'] +
"/lib" )
76 shutil.copy(libPath, os.environ[
'LIB3_DIR'] +
"/lib")
80 os.chdir(os.path.join(os.environ[
'OCSSWROOT'],
"lib"))
81 for fileName
in os.listdir(
'.'):
82 if os.path.isfile(fileName):
83 if ".dylib" in fileName:
85 p = subprocess.Popen([
"otool",
"-D", fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
86 out, err = p.communicate()
88 parts = out.decode(
"utf-8").split()
89 parts = parts[1].split(
"/")
91 if not "@rpath" in parts[0]:
95 subprocess.call([
"install_name_tool",
"-id", id, fileName])
97 p = subprocess.Popen([
"otool",
"-L", fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
98 out, err = p.communicate()
100 lines = out.decode(
"utf-8").split(
'\n')
102 if '/opt/homebrew/' in line
or '/usr/local/' in line
or '/opt/X11/lib/' in line
or os.environ[
'LIB3_DIR']
in line:
104 libPath = line.split()[0]
105 parts = libPath.split(
'/')
107 newName =
'@rpath/' + libName
109 subprocess.call([
"install_name_tool",
"-change", libPath, newName, fileName])
110 if os.environ[
'LIB3_DIR']
not in libPath:
111 if not os.path.isfile(os.environ[
'LIB3_DIR'] +
"/lib/" + libName):
113 print(
"copying", libPath, os.environ[
'LIB3_DIR'] +
"/lib" )
114 shutil.copy(libPath, os.environ[
'LIB3_DIR'] +
"/lib")
118 os.chdir(os.path.join(os.environ[
'OCSSWROOT'],
"bin"))
119 for fileName
in os.listdir(
'.'):
120 if os.path.isfile(fileName):
121 line = subprocess.check_output([
'file', fileName]).decode(
"utf-8")
122 if "Mach-O 64-bit executable" in line:
124 p = subprocess.Popen([
"otool",
"-L", fileName], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
125 out, err = p.communicate()
127 lines = out.decode(
"utf-8").split(
'\n')
129 if '/opt/homebrew/' in line
or '/usr/local/' in line
or '/opt/X11/lib/' in line
or os.environ[
'LIB3_DIR']
in line
or '%s/lib' % (os.environ[
'OCSSWROOT'])
in line:
131 libPath = line.split()[0]
132 parts = libPath.split(
'/')
134 newName =
'@rpath/' + libName
136 subprocess.call([
"install_name_tool",
"-change", libPath, newName, fileName])
137 if os.environ[
'LIB3_DIR']
not in libPath:
138 if not os.path.isfile(os.environ[
'LIB3_DIR'] +
"/lib/" + libName):
140 print(
"copying", libPath, os.environ[
'LIB3_DIR'] +
"/lib" )
141 shutil.copy(libPath, os.environ[
'LIB3_DIR'] +
"/lib")