From 97e9395b7f1ad53c449bf166be33cea01b9f91be Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Thu, 21 Mar 2024 14:44:46 -0600 Subject: [PATCH] Fix pkg support module --- tests/support/pkg.py | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/tests/support/pkg.py b/tests/support/pkg.py index 8663fd9a283..ae81c9c86f3 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -445,18 +445,12 @@ class SaltPkgInstall: if pkg.endswith("exe"): # Install the package log.debug("Installing: %s", str(pkg)) - ps_cmd = ( - f'$p = Start-Process -FilePath "{str(pkg)}" -ArgumentList ' - f'"/start-minion=0","/S" -Wait -NoNewWindow -Passthru; ' - f"exit $p.ExitCode" - ) - ret = self.proc.run( - "powershell.exe", - "-ExecutionPolicy", - "Bypass", - "-Command", - f"'{ps_cmd}'", - ) + batch_file = pathlib.Path(pkg).parent / "install_nsis.cmd" + batch_content = f'start "" /wait {str(pkg)} /start-minion=0 /S' + with salt.utils.files.fopen(batch_file, "w") as fp: + fp.write(batch_content) + # Now run the batch file + ret = self.proc.run("cmd.exe", "/c", str(batch_file)) self._check_retcode(ret) elif pkg.endswith("msi"): # Install the package @@ -819,18 +813,12 @@ class SaltPkgInstall: ret = self.proc.run("cmd.exe", "/c", str(batch_file)) self._check_retcode(ret) else: - ps_cmd = ( - f'$p = Start-Process -FilePath "{str(pkg_path)}" ' - f'-ArgumentList "/start-minion=0","/S" -Wait -NoNewWindow ' - f"-Passthru; exit $p.ExitCode" - ) - ret = self.proc.run( - "powershell.exe", - "-ExecutionPolicy", - "Bypass", - "-Command", - f"'{ps_cmd}'", - ) + batch_file = pkg_path.parent / "install_nsis.cmd" + batch_content = f'start "" /wait {str(pkg_path)} /start-minion=0 /S' + with salt.utils.files.fopen(batch_file, "w") as fp: + fp.write(batch_content) + # Now run the batch file + ret = self.proc.run("cmd.exe", "/c", str(batch_file)) self._check_retcode(ret) log.debug("Removing installed salt-minion service") @@ -1169,8 +1157,8 @@ class PkgLaunchdSaltDaemonImpl(PkgSystemdSaltDaemonImpl): # Dereference the internal _process attribute self._process = None - # Lets log and kill any child processes left behind, including the main subprocess - # if it failed to properly stop + # Let's log and kill any child processes left behind, including the main + # subprocess if it failed to properly stop terminate_process( pid=pid, kill_children=True,