Blob Blame History Raw
RHBZ: #1729039
Upstream status: RHEL >= 8.0.0 only

Add modinfo -F vermagic KMOD to the ksc-report, namely the section
identifier.

Before: {kmod.ko}
Now:    {kmod.ko@4.18.0-48.el8.x86_64 SMP mod_unload modversions}

This will help to determine against which kernel were modules
compiled against. This is a non-intrusive change that does not
alter the existing structure of ksc report and requires only minor
changes to existing ksc parsers/lexers.

Signed-off-by: Čestmír Kalina <ckalina@redhat.com>
---
 ksc.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/ksc.py b/ksc.py
index 2664d26..57df894 100755
--- a/ksc.py
+++ b/ksc.py
@@ -63,6 +63,7 @@ class Ksc(object):
         self.releasedir = None
         self.symvers = None
         self.arch = None
+        self.vermagic = {}
         if mock:
             self.releasename = '7.0'
         else:
@@ -77,6 +78,7 @@ class Ksc(object):
         self.justifications = {}
         self.matchdata = None
         self.total = None
+        self.vermagic = {}

     def main(self, mock_options=None):
         """
@@ -401,7 +403,10 @@ class Ksc(object):

                 f.write(command)
                 for ko_file in self.all_symbols_used:
-                    f.write("\n{%s}\n\n" % os.path.basename(ko_file))
+                    f.write("\n{%s@%s}\n\n" % (
+                        os.path.basename(ko_file),
+                        self.vermagic[ko_file].strip()
+                    ))
                     self.write_result(f, ko_file)

             if not self.mock:
@@ -544,6 +549,12 @@ class Ksc(object):

         self.defined_symbols[path] = set()

+        try:
+            self.vermagic[path] = run("modinfo -F vermagic '%s'" % path)
+        except Exception as e:
+            print(e)
+            sys.exit(1)
+
         try:
             out = run("nm '%s'" % path)
         except Exception as e:
-- 
2.21.0