From 07df929fd058ea599e2351ccf624a1bd1c0d0ef2 Mon Sep 17 00:00:00 2001 From: Nikolay Vizovitin <73231049+vizovitin@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:23:47 +0300 Subject: [PATCH] Implement simulate for rpm.install_packages(). --- pleskdistup/common/src/rpm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pleskdistup/common/src/rpm.py b/pleskdistup/common/src/rpm.py index bbf6457..eb295ab 100644 --- a/pleskdistup/common/src/rpm.py +++ b/pleskdistup/common/src/rpm.py @@ -147,7 +147,12 @@ def is_package_installed(pkg: str) -> bool: return res.returncode == 0 -def install_packages(pkgs: typing.List[str], repository: typing.Optional[str] = None, force_package_config: bool = False) -> None: +def install_packages( + pkgs: typing.List[str], + repository: typing.Optional[str] = None, + force_package_config: bool = False, + simulate: bool = False, +) -> None: # force_package_config is not supported yet if len(pkgs) == 0: return @@ -155,6 +160,8 @@ def install_packages(pkgs: typing.List[str], repository: typing.Optional[str] = command = ["/usr/bin/yum", "install"] if repository is not None: command += ["--repo", repository] + if simulate: + command += ["--setopt", "tsflags=test"] command += ["-y"] + pkgs util.logged_check_call(command)