Skip to content

Commit 97e9395

Browse files
twangboys0undt3ch
authored andcommitted
Fix pkg support module
1 parent 7342246 commit 97e9395

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

tests/support/pkg.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -445,18 +445,12 @@ def _install_pkgs(self, upgrade=False, downgrade=False):
445445
if pkg.endswith("exe"):
446446
# Install the package
447447
log.debug("Installing: %s", str(pkg))
448-
ps_cmd = (
449-
f'$p = Start-Process -FilePath "{str(pkg)}" -ArgumentList '
450-
f'"/start-minion=0","/S" -Wait -NoNewWindow -Passthru; '
451-
f"exit $p.ExitCode"
452-
)
453-
ret = self.proc.run(
454-
"powershell.exe",
455-
"-ExecutionPolicy",
456-
"Bypass",
457-
"-Command",
458-
f"'{ps_cmd}'",
459-
)
448+
batch_file = pathlib.Path(pkg).parent / "install_nsis.cmd"
449+
batch_content = f'start "" /wait {str(pkg)} /start-minion=0 /S'
450+
with salt.utils.files.fopen(batch_file, "w") as fp:
451+
fp.write(batch_content)
452+
# Now run the batch file
453+
ret = self.proc.run("cmd.exe", "/c", str(batch_file))
460454
self._check_retcode(ret)
461455
elif pkg.endswith("msi"):
462456
# Install the package
@@ -819,18 +813,12 @@ def install_previous(self, downgrade=False):
819813
ret = self.proc.run("cmd.exe", "/c", str(batch_file))
820814
self._check_retcode(ret)
821815
else:
822-
ps_cmd = (
823-
f'$p = Start-Process -FilePath "{str(pkg_path)}" '
824-
f'-ArgumentList "/start-minion=0","/S" -Wait -NoNewWindow '
825-
f"-Passthru; exit $p.ExitCode"
826-
)
827-
ret = self.proc.run(
828-
"powershell.exe",
829-
"-ExecutionPolicy",
830-
"Bypass",
831-
"-Command",
832-
f"'{ps_cmd}'",
833-
)
816+
batch_file = pkg_path.parent / "install_nsis.cmd"
817+
batch_content = f'start "" /wait {str(pkg_path)} /start-minion=0 /S'
818+
with salt.utils.files.fopen(batch_file, "w") as fp:
819+
fp.write(batch_content)
820+
# Now run the batch file
821+
ret = self.proc.run("cmd.exe", "/c", str(batch_file))
834822
self._check_retcode(ret)
835823

836824
log.debug("Removing installed salt-minion service")
@@ -1169,8 +1157,8 @@ def _terminate(self):
11691157

11701158
# Dereference the internal _process attribute
11711159
self._process = None
1172-
# Lets log and kill any child processes left behind, including the main subprocess
1173-
# if it failed to properly stop
1160+
# Let's log and kill any child processes left behind, including the main
1161+
# subprocess if it failed to properly stop
11741162
terminate_process(
11751163
pid=pid,
11761164
kill_children=True,

0 commit comments

Comments
 (0)