Skip to content

Commit

Permalink
Fix pkg support module
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy authored and s0undt3ch committed Apr 5, 2024
1 parent 7342246 commit 97e9395
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions tests/support/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,12 @@ def _install_pkgs(self, upgrade=False, downgrade=False):
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
Expand Down Expand Up @@ -819,18 +813,12 @@ def install_previous(self, downgrade=False):
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")
Expand Down Expand Up @@ -1169,8 +1157,8 @@ def _terminate(self):

# 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,
Expand Down

0 comments on commit 97e9395

Please sign in to comment.