100-apply-2to3.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. --- a/src/mklibs
  2. +++ b/src/mklibs
  3. @@ -57,17 +57,17 @@ debuglevel = DEBUG_NORMAL
  4. def debug(level, *msg):
  5. if debuglevel >= level:
  6. - print(string.join(msg))
  7. + print(' '.join(msg))
  8. # return a list of lines of output of the command
  9. def command(command, *args):
  10. - debug(DEBUG_SPAM, "calling", command, string.join(args))
  11. + debug(DEBUG_SPAM, "calling", command, ' '.join(args))
  12. pipe = os.popen(command + ' ' + ' '.join(args), 'r')
  13. output = pipe.read().strip()
  14. status = pipe.close()
  15. if status is not None and os.WEXITSTATUS(status) != 0:
  16. print("Command failed with status", os.WEXITSTATUS(status), ":", \
  17. - command, string.join(args))
  18. + command, ' '.join(args))
  19. print("With output:", output)
  20. sys.exit(1)
  21. return [i for i in output.split('\n') if i]
  22. @@ -296,7 +296,7 @@ def usage(was_err):
  23. print("Make a set of minimal libraries for FILE(s, file=outfd) in DEST.", file=outfd)
  24. print("" , file=outfd)
  25. print(" -d, --dest-dir DIRECTORY create libraries in DIRECTORY", file=outfd)
  26. - print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path, file=outfd), ", file=outfd)", file=outfd)
  27. + print(" -D, --no-default-lib omit default libpath (", ':'.join(default_lib_path), ")", file=outfd)
  28. print(" -L DIRECTORY[:DIRECTORY]... add DIRECTORY(s, file=outfd) to the library search path", file=outfd)
  29. print(" -l LIBRARY add LIBRARY always", file=outfd)
  30. print(" --ldlib LDLIB use LDLIB for the dynamic linker", file=outfd)
  31. @@ -372,7 +372,7 @@ for opt, arg in optlist:
  32. if debuglevel < DEBUG_SPAM:
  33. debuglevel = debuglevel + 1
  34. elif opt == "-L":
  35. - lib_path.extend(string.split(arg, ":"))
  36. + lib_path.extend(arg.split(":"))
  37. elif opt in ("-d", "--dest-dir"):
  38. dest_path = arg
  39. elif opt in ("-D", "--no-default-lib"):
  40. @@ -391,7 +391,7 @@ for opt, arg in optlist:
  41. elif opt in ("-l",):
  42. force_libs.append(arg)
  43. elif opt == "--gcc-options":
  44. - gcc_options.extend(string.split(arg, " "))
  45. + gcc_options.extend(arg.split(" "))
  46. elif opt == "--libdir":
  47. libdir = arg
  48. elif opt in ("--help", "-h"):
  49. @@ -419,17 +419,17 @@ if ldlib == "LDLIB":
  50. objects = {} # map from inode to filename
  51. for prog in proglist:
  52. inode = os.stat(prog)[ST_INO]
  53. - if objects.has_key(inode):
  54. + if inode in objects:
  55. debug(DEBUG_SPAM, prog, "is a hardlink to", objects[inode])
  56. elif so_pattern.match(prog):
  57. debug(DEBUG_SPAM, prog, "is a library")
  58. - elif script_pattern.match(open(prog).read(256)):
  59. + elif script_pattern.match(open(prog, 'r', encoding='iso-8859-1').read(256)):
  60. debug(DEBUG_SPAM, prog, "is a script")
  61. else:
  62. objects[inode] = prog
  63. if not ldlib:
  64. - for obj in objects.values():
  65. + for obj in list(objects.values()):
  66. output = command("mklibs-readelf", "--print-interp", obj)
  67. if output:
  68. ldlib = output.pop()
  69. @@ -462,9 +462,9 @@ previous_pass_unresolved = set()
  70. while 1:
  71. debug(DEBUG_NORMAL, "I: library reduction pass", str(passnr))
  72. if debuglevel >= DEBUG_VERBOSE:
  73. - print("Objects:",)
  74. - for obj in sorted([x[string.rfind(x, '/') + 1:] for x in objects.values()]):
  75. - print(obj,)
  76. + print("Objects:", end=' ')
  77. + for obj in sorted([x[x.rfind('/') + 1:] for x in list(objects.values())]):
  78. + print(obj, end=' ')
  79. print()
  80. passnr = passnr + 1
  81. @@ -474,7 +474,7 @@ while 1:
  82. obj = dest_path + "/" + lib
  83. small_libs.append(obj)
  84. inode = os.stat(obj)[ST_INO]
  85. - if objects.has_key(inode):
  86. + if inode in objects:
  87. debug(DEBUG_SPAM, obj, "is hardlink to", objects[inode])
  88. else:
  89. objects[inode] = obj
  90. @@ -504,7 +504,7 @@ while 1:
  91. present_symbols = {}
  92. checked_libs = small_libs
  93. checked_libs.extend(available_libs)
  94. - checked_libs.append(ldlib)
  95. + checked_libs.append(sysroot + "/" + ldlib)
  96. for lib in checked_libs:
  97. for symbol in provided_symbols(lib):
  98. debug(DEBUG_SPAM, "present_symbols adding %s" % symbol)
  99. --- a/src/mklibs-copy
  100. +++ b/src/mklibs-copy
  101. @@ -159,7 +159,7 @@ if include_default_lib_path:
  102. objects = {} # map from inode to filename
  103. for prog in proglist:
  104. inode = os.stat(prog)[ST_INO]
  105. - if objects.has_key(inode):
  106. + if inode in objects:
  107. logger.debug("%s is a hardlink to %s", prog, objects[inode])
  108. elif so_pattern.match(prog):
  109. logger.debug("%s is a library", prog)
  110. @@ -169,7 +169,7 @@ for prog in proglist:
  111. logger.debug("%s is no ELF", prog)
  112. if not ldlib:
  113. - for obj in objects.values():
  114. + for obj in list(objects.values()):
  115. output = command("mklibs-readelf", "-i", obj)
  116. for x in output:
  117. ldlib = x
  118. @@ -182,7 +182,7 @@ if not ldlib:
  119. logger.info('Using %s as dynamic linker', ldlib)
  120. # Check for rpaths
  121. -for obj in objects.values():
  122. +for obj in list(objects.values()):
  123. rpath_val = rpath(obj)
  124. if rpath_val:
  125. if root:
  126. @@ -208,18 +208,18 @@ while 1:
  127. obj = dest_path + "/" + lib
  128. small_libs.append(obj)
  129. inode = os.stat(obj)[ST_INO]
  130. - if objects.has_key(inode):
  131. + if inode in objects:
  132. logger.debug("%s is hardlink to %s", obj, objects[inode])
  133. else:
  134. objects[inode] = obj
  135. - for obj in objects.values():
  136. + for obj in list(objects.values()):
  137. small_libs.append(obj)
  138. - logger.verbose('Objects: %r', ' '.join([i[i.rfind('/') + 1:] for i in objects.itervalues()]))
  139. + logger.verbose('Objects: %r', ' '.join([i[i.rfind('/') + 1:] for i in objects.values()]))
  140. libraries = set()
  141. - for obj in objects.values():
  142. + for obj in list(objects.values()):
  143. libraries.update(library_depends(obj))
  144. if libraries == previous_pass_libraries: