Skip to content

Commit 0979ee0

Browse files
committed
improve exception handling for zfs
Signed-off-by: Zen <[email protected]>
1 parent cfa071a commit 0979ee0

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/ugrd/kmod/kmod.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,19 @@ def process_ignored_module(self, module: str) -> None:
516516
for key in ["kmod_init", "kernel_modules", "_kmod_auto"]:
517517
if module in self[key]:
518518
if key == "kmod_init":
519-
modinfo = _get_kmod_info(self, module)
520-
if modinfo["filename"] == "(builtin)":
521-
self.logger.debug("Removing built-in module from kmod_init: %s" % module)
522-
elif module == "zfs":
523-
self.logger.critical("ZFS module is required but missing.")
524-
self.logger.critical("Please build/install the required kmods before running this script.")
525-
self.logger.critical("Detected kernel version: %s" % self["kernel_version"])
526-
# https://github.com/projg2/installkernel-gentoo/commit/1c70dda8cd2700e5306d2ed74886b66ad7ccfb42
527-
exit(77)
528-
else:
529-
raise MissingModuleError("Required module cannot be imported and is not builtin: %s" % module)
519+
try:
520+
modinfo = _get_kmod_info(self, module)
521+
if modinfo["filename"] == "(builtin)":
522+
self.logger.debug("Removing built-in module from kmod_init: %s" % module)
523+
except DependencyResolutionError:
524+
if module == "zfs":
525+
self.logger.critical("ZFS module is required but missing.")
526+
self.logger.critical("Please build/install the required kmods before running this script.")
527+
self.logger.critical("Detected kernel version: %s" % self["kernel_version"])
528+
# https://github.com/projg2/installkernel-gentoo/commit/1c70dda8cd2700e5306d2ed74886b66ad7ccfb42
529+
exit(77)
530+
else:
531+
raise MissingModuleError("Required module cannot be imported and is not builtin: %s" % module)
530532
else:
531533
self.logger.debug("Removing ignored kernel module from %s: %s" % (key, module))
532534
self[key].remove(module)

0 commit comments

Comments
 (0)