Fix pkg support module

This commit is contained in:
Shane Lee 2024-03-21 14:44:46 -06:00 committed by Pedro Algarvio
parent 7342246514
commit 97e9395b7f

View file

@ -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,