Skip to content

Commit

Permalink
Merge pull request saltstack#3735 from UtahDave/add_msiiexec_check
Browse files Browse the repository at this point in the history
Add msiexec flag for Windows Installer Packages. Fixes saltstack#3667
  • Loading branch information
thatch45 committed Feb 15, 2013
2 parents d7cfcf8 + 656432b commit 9c573fe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
15 changes: 15 additions & 0 deletions doc/ref/windows-package-manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,22 @@ The package definition file should look similar to this example for Firefox:
uninstaller: '%ProgramFiles(x86)%/Mozilla Firefox/uninstall/helper.exe'
uninstall_flags: ' /S'
Add ``msiexec: True`` if using an msi installer requiring the use of ``msiexec
/i`` to install and ``msiexec /x`` to uninstall.
``/srv/salt/win/repo/7zip/init.sls``

.. code-block:: yaml
7zip:
9.20:
installer: salt://win/repo/7zip/7z920-x64.msi
full_name: 7zip 9.22
reboot: False
install_flags: ' /q '
msiexec: True
uninstaller: salt://win/repo/7zip/7z920-x64.msi
uninstall_flags: ' /qn'
Generate Repo Cache File
========================
Expand Down
8 changes: 6 additions & 2 deletions salt/modules/win_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ def install(name=None, refresh=False, **kwargs):
cached_pkg = pkginfo[version]['installer']
cached_pkg = cached_pkg.replace('/', '\\')
cmd = '"' + str(cached_pkg) + '"' + str(pkginfo[version]['install_flags'])
if pkginfo[version]['msiexec']:
cmd = 'msiexec /i ' + cmd
stderr = __salt__['cmd.run_all'](cmd).get('stderr', '')
if stderr:
log.error(stderr)
Expand Down Expand Up @@ -402,14 +404,16 @@ def remove(name, version=None, **kwargs):
cached_pkg = cached_pkg.replace('(x86)', '')
cmd = '"' + str(os.path.expandvars(
cached_pkg)) + '"' + str(pkginfo[version]['uninstall_flags'])
if pkginfo[version]['msiexec']:
cmd = 'msiexec /x ' + cmd
stderr = __salt__['cmd.run_all'](cmd).get('stderr', '')
if stderr:
log.error(stderr)
new = list_pkgs()
return __salt__['pkg_resource.find_changes'](old, new)


def purge(name, **kwargs):
def purge(name, version=None, **kwargs):
'''
Recursively remove a package and all dependencies which were installed
with it
Expand All @@ -420,7 +424,7 @@ def purge(name, **kwargs):
salt '*' pkg.purge <package name>
'''
return remove(name)
return remove(name, version, **kwargs)


def _get_package_info(name):
Expand Down
2 changes: 2 additions & 0 deletions salt/runners/winrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def genrepo():
'''
ret = {}
repo = __opts__['win_repo']
if not os.path.exists(repo):
os.makedirs(repo)
winrepo = __opts__['win_repo_mastercachefile']
for root, dirs, files in os.walk(repo):
for name in files:
Expand Down

0 comments on commit 9c573fe

Please sign in to comment.