|
@@ -1,4 +1,4 @@
|
|
|
-#!/usr/bin/env python2
|
|
|
+#!/usr/bin/env python3
|
|
|
# coding: utf-8
|
|
|
"""
|
|
|
Extract dependencies from kernel modules.
|
|
@@ -10,7 +10,8 @@ import subprocess
|
|
|
|
|
|
def processModule(path):
|
|
|
p = subprocess.Popen(["i686-pc-toaru-nm",path,"-p"], stdout=subprocess.PIPE)
|
|
|
- symbols, errors = p.communicate()
|
|
|
+ symbols, _ = p.communicate()
|
|
|
+ symbols = symbols.decode('utf-8')
|
|
|
name = [ x[2].replace("module_info_","") for x in [x.strip().split(" ") for x in symbols.split("\n") if len(x.strip().split(" ")) > 2] if x[1] == "D" and x[2].startswith("module_info_") ][0]
|
|
|
dependencies = [ x[2].replace("_mod_dependency_","") for x in [x.strip().split(" ") for x in symbols.split("\n") if len(x.strip().split(" ")) > 2] if x[1] == "d" and x[2].startswith("_mod_dependency_") ]
|
|
|
return path, name, dependencies
|
|
@@ -27,7 +28,7 @@ for module in os.listdir("hdd/mod"):
|
|
|
|
|
|
# Okay, now let's spit out the dependencies for our module.
|
|
|
if len(sys.argv) < 2:
|
|
|
- print >>sys.stderr, "Expected a path to a module (from the root of the build tree), eg. hdd/mod/test.ko"
|
|
|
+ print("Expected a path to a module (from the root of the build tree), eg. hdd/mod/test.ko", file=sys.stderr)
|
|
|
sys.exit(1)
|
|
|
|
|
|
me = sys.argv[-1]
|
|
@@ -59,11 +60,11 @@ while set(satisfied) != set(depends):
|
|
|
if len(sys.argv) > 2:
|
|
|
for i in sys.argv[1:-1]:
|
|
|
if i == '--print-deps':
|
|
|
- print name, "→", " ".join(["\033[31m{mod}\033[m".format(mod=x) if not x in deps else x for x in satisfied])
|
|
|
+ print(name, "→", " ".join(["\033[31m{mod}\033[m".format(mod=x) if not x in deps else x for x in satisfied]))
|
|
|
|
|
|
if i == '--print-files':
|
|
|
for i in satisfied:
|
|
|
- print modules[i][0], "(dep-of-dep)" if i not in deps else ""
|
|
|
+ print(modules[i][0], "(dep-of-dep)" if i not in deps else "")
|
|
|
|
|
|
|
|
|
p = subprocess.Popen(["i686-pc-toaru-ld","-T","kernel/link.ld","-o","/dev/null","toaruos-kernel",]+[modules[x][0] for x in satisfied]+[me])
|