diff --git a/pleskdistup/actions/common_checks.py b/pleskdistup/actions/common_checks.py index 6ed5a79..fa45dd5 100644 --- a/pleskdistup/actions/common_checks.py +++ b/pleskdistup/actions/common_checks.py @@ -636,3 +636,21 @@ def __init__(self): def _do_check(self) -> bool: return os.path.exists("/etc/default/grub") and packages.is_package_installed("grub2-common") + + +class AssertNoMoreThenOneKernelDevelInstalled(action.CheckAction): + def __init__(self): + self.name = "checking if more than one kernel-devel package is installed" + self.description = """More than one kernel-devel package is installed. +\tTo proceed with the conversion, please remove all kernel-devel packages except the one that corresponds to the running kernel. +\tKernel packages list: +\t- {} +""" + + def _do_check(self) -> bool: + kernel_devel_packages = packages.get_installed_packages_list("kernel-devel") + if len(kernel_devel_packages) <= 1: + return True + + self.description = self.description.format("\n\t- ".join([pkg.replace(" ", "-") for pkg in kernel_devel_packages])) + return False diff --git a/pleskdistup/common/src/dpkg.py b/pleskdistup/common/src/dpkg.py index 7dae729..9e05cb3 100644 --- a/pleskdistup/common/src/dpkg.py +++ b/pleskdistup/common/src/dpkg.py @@ -194,6 +194,6 @@ def do_distupgrade() -> None: def get_installed_packages_list(regex: str) -> typing.List[str]: - res = subprocess.check_output(["/usr/bin/dpkg-query", "-W", "-f", "${binary:Package}\n", regex], + res = subprocess.check_output(["/usr/bin/dpkg-query", "-W", "-f", "${binary:Package} ${Version}\n", regex], universal_newlines=True) return res.splitlines() diff --git a/pleskdistup/common/src/rpm.py b/pleskdistup/common/src/rpm.py index a66fd54..955d20d 100644 --- a/pleskdistup/common/src/rpm.py +++ b/pleskdistup/common/src/rpm.py @@ -161,7 +161,7 @@ def install_packages(pkgs: typing.List[str], repository: typing.Optional[str] = def get_installed_packages_list(regex: str) -> typing.List[str]: - res = subprocess.check_output(["/usr/bin/rpm", "-qa", "--queryformat", "%{NAME}\n", regex], universal_newlines=True) + res = subprocess.check_output(["/usr/bin/rpm", "-qa", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", regex], universal_newlines=True) return res.splitlines()