From d4a5b72814e6d2abcc7766fddde5c3430e01d4ab Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 18 Oct 2024 19:48:55 +0300 Subject: [PATCH] Updated for class method Signed-off-by: Dimitris Zlatanidis --- slpkg/main.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index deeb13b0..0cc27b6e 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -456,7 +456,7 @@ class Menu(Configs): # pylint: disable=[R0902] removed: list = [] added: list = [] ordered: bool = True - kernel_generic_current: str = self.utils.is_package_installed('kernel-generic') + kernel_generic_current_package: str = self.utils.is_package_installed('kernel-generic') if len(self.args) == 1: @@ -506,14 +506,24 @@ class Menu(Configs): # pylint: disable=[R0902] else: self.usage.help_minimal(f"{self.prog_name}: invalid repository '{self.repository}'") - kernel_generic_new: str = self.utils.is_package_installed('kernel-generic') - if kernel_generic_current != kernel_generic_new: - self._kernel_image_message() + self._is_kernel_upgrade(kernel_generic_current_package) raise SystemExit(0) self.usage.help_short(1) + def _is_kernel_upgrade(self, kernel_generic_current_package: str) -> None: + """Compare current and installed kernel package. + + Args: + kernel_generic_current_package (str): Kernel-generic package + """ + kernel_generic_new_package: str = self.utils.is_package_installed('kernel-generic') + if kernel_generic_current_package != kernel_generic_new_package: + self._kernel_image_message() + def _kernel_image_message(self) -> None: + """Print a warning kernel upgrade message. + """ print(f"\n{self.bred}Warning!{self.endc} Your kernel image looks like to have been upgraded!\n" "Please update the bootloader with the new parameters of the upgraded kernel.\n" "See: lilo, eliloconfig or grub-mkconfig -o /boot/grub/grub.cfg,\n" @@ -567,7 +577,7 @@ class Menu(Configs): # pylint: disable=[R0902] SystemExit: Exit code 0. """ command: str = Menu.install.__name__ - kernel_generic_current: str = self.utils.is_package_installed('kernel-generic') + kernel_generic_current_package: str = self.utils.is_package_installed('kernel-generic') if len(self.args) >= 2: self.data: dict = self.load_data.load(self.repository) @@ -586,9 +596,7 @@ class Menu(Configs): # pylint: disable=[R0902] install_sbo = Slackbuilds(self.repository, self.data, packages, self.flags, mode=command) install_sbo.execute() - kernel_generic_new: str = self.utils.is_package_installed('kernel-generic') - if kernel_generic_current != kernel_generic_new: - self._kernel_image_message() + self._is_kernel_upgrade(kernel_generic_current_package) raise SystemExit(0) self.usage.help_short(1)