neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

Blame SOURCES/0009-Do-not-use-BlockDev-utils_have_kernel_module-to-check-for-modules.patch

f01d01
From 7303f4a3f2fe3280339f6303dcff31b6ade12176 Mon Sep 17 00:00:00 2001
f01d01
From: Vojtech Trefny <vtrefny@redhat.com>
f01d01
Date: Thu, 9 Jul 2020 16:30:55 +0200
f01d01
Subject: [PATCH] Do not use BlockDev.utils_have_kernel_module to check for
f01d01
 modules
f01d01
f01d01
The function unfortunately uses only the name when searching for
f01d01
the module and we need to use aliases for modules like ext2 and
f01d01
ext3. So we need to use "modprobe --dry-run" instead.
f01d01
---
f01d01
 blivet/formats/fs.py | 12 +++---------
f01d01
 1 file changed, 3 insertions(+), 9 deletions(-)
f01d01
f01d01
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
f01d01
index eee15aaa..bcfbc08e 100644
f01d01
--- a/blivet/formats/fs.py
f01d01
+++ b/blivet/formats/fs.py
f01d01
@@ -60,12 +60,6 @@
f01d01
 import logging
f01d01
 log = logging.getLogger("blivet")
f01d01
 
f01d01
-import gi
f01d01
-gi.require_version("GLib", "2.0")
f01d01
-gi.require_version("BlockDev", "2.0")
f01d01
-
f01d01
-from gi.repository import GLib
f01d01
-from gi.repository import BlockDev
f01d01
 
f01d01
 AVAILABLE_FILESYSTEMS = kernel_filesystems
f01d01
 
f01d01
@@ -462,13 +456,13 @@ def check_module(self):
f01d01
 
f01d01
         for module in self._modules:
f01d01
             try:
f01d01
-                succ = BlockDev.utils_have_kernel_module(module)
f01d01
-            except GLib.GError as e:
f01d01
+                rc = util.run_program(["modprobe", "--dry-run", module])
f01d01
+            except OSError as e:
f01d01
                 log.error("Could not check kernel module availability %s: %s", module, e)
f01d01
                 self._supported = False
f01d01
                 return
f01d01
 
f01d01
-            if not succ:
f01d01
+            if rc:
f01d01
                 log.debug("Kernel module %s not available", module)
f01d01
                 self._supported = False
f01d01
                 return