2019-07-26 21:45:47 +00:00
|
|
|
--- a/src/mklibs
|
|
|
|
+++ b/src/mklibs
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -57,17 +57,17 @@ debuglevel = DEBUG_NORMAL
|
2019-07-26 21:45:47 +00:00
|
|
|
|
|
|
|
def debug(level, *msg):
|
|
|
|
if debuglevel >= level:
|
2022-02-25 04:27:34 +00:00
|
|
|
- print(string.join(msg))
|
2019-07-26 21:45:47 +00:00
|
|
|
+ print(' '.join(msg))
|
|
|
|
|
|
|
|
# return a list of lines of output of the command
|
|
|
|
def command(command, *args):
|
|
|
|
- debug(DEBUG_SPAM, "calling", command, string.join(args))
|
|
|
|
+ debug(DEBUG_SPAM, "calling", command, ' '.join(args))
|
|
|
|
pipe = os.popen(command + ' ' + ' '.join(args), 'r')
|
|
|
|
output = pipe.read().strip()
|
|
|
|
status = pipe.close()
|
|
|
|
if status is not None and os.WEXITSTATUS(status) != 0:
|
2022-02-25 04:27:34 +00:00
|
|
|
print("Command failed with status", os.WEXITSTATUS(status), ":", \
|
|
|
|
- command, string.join(args))
|
2019-07-26 21:45:47 +00:00
|
|
|
+ command, ' '.join(args))
|
2022-02-25 04:27:34 +00:00
|
|
|
print("With output:", output)
|
2019-07-26 21:45:47 +00:00
|
|
|
sys.exit(1)
|
|
|
|
return [i for i in output.split('\n') if i]
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -296,7 +296,7 @@ def usage(was_err):
|
|
|
|
print("Make a set of minimal libraries for FILE(s, file=outfd) in DEST.", file=outfd)
|
|
|
|
print("" , file=outfd)
|
|
|
|
print(" -d, --dest-dir DIRECTORY create libraries in DIRECTORY", file=outfd)
|
|
|
|
- print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path, file=outfd), ", file=outfd)", file=outfd)
|
2019-07-26 21:45:47 +00:00
|
|
|
+ print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path), ")", file=outfd)
|
2022-02-25 04:27:34 +00:00
|
|
|
print(" -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s, file=outfd) to the library search path", file=outfd)
|
|
|
|
print(" -l LIBRARY add LIBRARY always", file=outfd)
|
|
|
|
print(" --ldlib LDLIB use LDLIB for the dynamic linker", file=outfd)
|
|
|
|
@@ -372,7 +372,7 @@ for opt, arg in optlist:
|
2019-07-26 21:45:47 +00:00
|
|
|
if debuglevel < DEBUG_SPAM:
|
|
|
|
debuglevel = debuglevel + 1
|
|
|
|
elif opt == "-L":
|
|
|
|
- lib_path.extend(string.split(arg, ":"))
|
|
|
|
+ lib_path.extend(arg.split(":"))
|
|
|
|
elif opt in ("-d", "--dest-dir"):
|
|
|
|
dest_path = arg
|
|
|
|
elif opt in ("-D", "--no-default-lib"):
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -391,7 +391,7 @@ for opt, arg in optlist:
|
2019-07-26 21:45:47 +00:00
|
|
|
elif opt in ("-l",):
|
|
|
|
force_libs.append(arg)
|
|
|
|
elif opt == "--gcc-options":
|
|
|
|
- gcc_options.extend(string.split(arg, " "))
|
|
|
|
+ gcc_options.extend(arg.split(" "))
|
|
|
|
elif opt == "--libdir":
|
|
|
|
libdir = arg
|
|
|
|
elif opt in ("--help", "-h"):
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -419,17 +419,17 @@ if ldlib == "LDLIB":
|
2019-07-26 21:45:47 +00:00
|
|
|
objects = {} # map from inode to filename
|
|
|
|
for prog in proglist:
|
|
|
|
inode = os.stat(prog)[ST_INO]
|
|
|
|
- if objects.has_key(inode):
|
|
|
|
+ if inode in objects:
|
|
|
|
debug(DEBUG_SPAM, prog, "is a hardlink to", objects[inode])
|
|
|
|
elif so_pattern.match(prog):
|
|
|
|
debug(DEBUG_SPAM, prog, "is a library")
|
|
|
|
- elif script_pattern.match(open(prog).read(256)):
|
|
|
|
+ elif script_pattern.match(open(prog, 'r', encoding='iso-8859-1').read(256)):
|
|
|
|
debug(DEBUG_SPAM, prog, "is a script")
|
|
|
|
else:
|
|
|
|
objects[inode] = prog
|
|
|
|
|
|
|
|
if not ldlib:
|
|
|
|
- for obj in objects.values():
|
|
|
|
+ for obj in list(objects.values()):
|
|
|
|
output = command("mklibs-readelf", "--print-interp", obj)
|
|
|
|
if output:
|
|
|
|
ldlib = output.pop()
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -462,9 +462,9 @@ previous_pass_unresolved = set()
|
2019-07-26 21:45:47 +00:00
|
|
|
while 1:
|
2022-02-25 04:27:34 +00:00
|
|
|
debug(DEBUG_NORMAL, "I: library reduction pass", str(passnr))
|
2019-07-26 21:45:47 +00:00
|
|
|
if debuglevel >= DEBUG_VERBOSE:
|
2022-02-25 04:27:34 +00:00
|
|
|
- print("Objects:",)
|
2019-07-26 21:45:47 +00:00
|
|
|
- for obj in sorted([x[string.rfind(x, '/') + 1:] for x in objects.values()]):
|
2022-02-25 04:27:34 +00:00
|
|
|
- print(obj,)
|
2019-07-26 21:45:47 +00:00
|
|
|
+ print("Objects:", end=' ')
|
|
|
|
+ for obj in sorted([x[x.rfind('/') + 1:] for x in list(objects.values())]):
|
|
|
|
+ print(obj, end=' ')
|
2022-02-25 04:27:34 +00:00
|
|
|
print()
|
2019-07-26 21:45:47 +00:00
|
|
|
|
|
|
|
passnr = passnr + 1
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -474,7 +474,7 @@ while 1:
|
2019-07-26 21:45:47 +00:00
|
|
|
obj = dest_path + "/" + lib
|
|
|
|
small_libs.append(obj)
|
|
|
|
inode = os.stat(obj)[ST_INO]
|
|
|
|
- if objects.has_key(inode):
|
|
|
|
+ if inode in objects:
|
|
|
|
debug(DEBUG_SPAM, obj, "is hardlink to", objects[inode])
|
|
|
|
else:
|
|
|
|
objects[inode] = obj
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -504,7 +504,7 @@ while 1:
|
2019-07-26 21:45:47 +00:00
|
|
|
present_symbols = {}
|
|
|
|
checked_libs = small_libs
|
|
|
|
checked_libs.extend(available_libs)
|
|
|
|
- checked_libs.append(ldlib)
|
|
|
|
+ checked_libs.append(sysroot + "/" + ldlib)
|
|
|
|
for lib in checked_libs:
|
|
|
|
for symbol in provided_symbols(lib):
|
|
|
|
debug(DEBUG_SPAM, "present_symbols adding %s" % symbol)
|
|
|
|
--- a/src/mklibs-copy
|
|
|
|
+++ b/src/mklibs-copy
|
|
|
|
@@ -159,7 +159,7 @@ if include_default_lib_path:
|
|
|
|
objects = {} # map from inode to filename
|
|
|
|
for prog in proglist:
|
|
|
|
inode = os.stat(prog)[ST_INO]
|
|
|
|
- if objects.has_key(inode):
|
|
|
|
+ if inode in objects:
|
|
|
|
logger.debug("%s is a hardlink to %s", prog, objects[inode])
|
|
|
|
elif so_pattern.match(prog):
|
|
|
|
logger.debug("%s is a library", prog)
|
2022-02-25 04:27:34 +00:00
|
|
|
@@ -169,7 +169,7 @@ for prog in proglist:
|
2019-07-26 21:45:47 +00:00
|
|
|
logger.debug("%s is no ELF", prog)
|
|
|
|
|
|
|
|
if not ldlib:
|
|
|
|
- for obj in objects.values():
|
|
|
|
+ for obj in list(objects.values()):
|
|
|
|
output = command("mklibs-readelf", "-i", obj)
|
2022-02-25 04:27:34 +00:00
|
|
|
for x in output:
|
|
|
|
ldlib = x
|
2019-07-26 21:45:47 +00:00
|
|
|
@@ -182,7 +182,7 @@ if not ldlib:
|
|
|
|
logger.info('Using %s as dynamic linker', ldlib)
|
|
|
|
|
|
|
|
# Check for rpaths
|
|
|
|
-for obj in objects.values():
|
|
|
|
+for obj in list(objects.values()):
|
|
|
|
rpath_val = rpath(obj)
|
|
|
|
if rpath_val:
|
|
|
|
if root:
|
|
|
|
@@ -208,18 +208,18 @@ while 1:
|
|
|
|
obj = dest_path + "/" + lib
|
|
|
|
small_libs.append(obj)
|
|
|
|
inode = os.stat(obj)[ST_INO]
|
|
|
|
- if objects.has_key(inode):
|
|
|
|
+ if inode in objects:
|
|
|
|
logger.debug("%s is hardlink to %s", obj, objects[inode])
|
|
|
|
else:
|
|
|
|
objects[inode] = obj
|
|
|
|
|
|
|
|
- for obj in objects.values():
|
|
|
|
+ for obj in list(objects.values()):
|
|
|
|
small_libs.append(obj)
|
|
|
|
|
|
|
|
- logger.verbose('Objects: %r', ' '.join([i[i.rfind('/') + 1:] for i in objects.itervalues()]))
|
|
|
|
+ logger.verbose('Objects: %r', ' '.join([i[i.rfind('/') + 1:] for i in objects.values()]))
|
|
|
|
|
|
|
|
libraries = set()
|
|
|
|
- for obj in objects.values():
|
|
|
|
+ for obj in list(objects.values()):
|
|
|
|
libraries.update(library_depends(obj))
|
|
|
|
|
|
|
|
if libraries == previous_pass_libraries:
|