From 5a45ff1e4a613497324a9bf0bd1359f987bf2b27 Mon Sep 17 00:00:00 2001 From: xiaochn Date: Fri, 20 Dec 2024 15:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dethernet=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=AE=8C=E6=88=90=E5=90=8E=E5=8D=A1=E4=BD=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwcompatible/cert_info.py | 7 +++++++ hwcompatible/device.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/hwcompatible/cert_info.py b/hwcompatible/cert_info.py index f486777..410ef09 100644 --- a/hwcompatible/cert_info.py +++ b/hwcompatible/cert_info.py @@ -77,6 +77,13 @@ class CertInfo: oec_json["date"] = curday filename = self.command.run_cmd( "modinfo %s | grep filename | awk '{print $2}'" % device.driver, log_print=False) + if len(filename[0].strip("\n")) == 0: + kernel_modules = device.get_modules() + for module in kernel_modules: + filename = self.command.run_cmd( + "modinfo %s | grep filename | awk '{print $2}'" % module, log_print=False) + if len(filename[0].strip("\n")) == 0: + continue shanum = self.command.run_cmd( "sha256sum %s | awk '{print $1}'" % filename[0].strip("\n"), log_print=False) oec_json["sha256"] = shanum[0].strip("\n") diff --git a/hwcompatible/device.py b/hwcompatible/device.py index 6597af2..49961b0 100755 --- a/hwcompatible/device.py +++ b/hwcompatible/device.py @@ -85,6 +85,7 @@ class Device: self.path = properties["DEVPATH"] else: self.properties = dict() + self.modules = list() def get_property(self, prop): """ @@ -407,6 +408,23 @@ class Device: def set_driver(self, driver): self.driver = driver + def get_modules(self): + """ + get the kernel modules name of the board + :return: + """ + modules = list() + self.get_pci() + if not self.pci: + return modules + cmd_result = self.command.run_cmd( + "lspci -xs %s -v" % self.pci, log_print=False) + for info in cmd_result[0].split('\n'): + if re.search("Kernel modules", info) and len(info.split(":")[1].strip()) > 0: + self.modules = info.split(":")[1].strip().split(", ") + return self.modules + return modules + def get_pci(self): """ get the pci of card. -- Gitee