Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent conversion with multiple kernel devel #60

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pleskdistup/actions/common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pleskdistup/common/src/dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion pleskdistup/common/src/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
Loading