Skip to content

Instantly share code, notes, and snippets.

@UtahDave
Created March 18, 2016 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UtahDave/977b60ee7b515b79ea38 to your computer and use it in GitHub Desktop.
Save UtahDave/977b60ee7b515b79ea38 to your computer and use it in GitHub Desktop.
How to build Windows Installer (MSI) packages for SaltStack

Build environment (in order):

  • Microsoft Windows Server 2008 R2 Standard w/ SP1
  • Microsoft Visual Studio 2008 (all features)
  • Microsoft Windows SDK for Windows 7 and .NET Framework 4 (all features)
  • Python 2.7.11 (all features, skip byte compilation of .py files)
  • Run WindowsSdkVer.exe -version:v7.1 as an administrator in order to register the SDK properly with Visual Studio 2008.
  • Run pip install -U setuptools as an administrator in order to update the bundled version of setuptools.
  • Patch distutils per http://bugs.python.org/issue15797.

Obtaining sources:

  • pip install --no-binary :all: -d . salt
  • download some manually (e.g., pypiwin32, pycrypto, salt)
  • grab the salt source release from GitHub in ZIP format (the tarball includes symlinks that 7-Zip can't handle)
  • m2crypto isn't needed as of the salt 2015.8 branch

Patching sources:

  • some libraries with dotted-quad version numbers need to be changed to dotted-triple version numbers, otherwise bdist_msi fails (e.g., backports.ssl_match_hostname, certifi, pypiwin32, singledispatch)
  • pypiwin32-219 is missing several demo and test files, references to which must be removed from setup.py

Building Windows installers:

  • build everything from the Windows SDK 7.1 Command Prompt
  • make sure to run setenv /release in the Windows SDK 7.1 Command Prompt to disable debugging flags
  • python setup.py bdist_msi && copy dist\*.msi ..\..\packages\
  • distutils should find the C++ compiler via the registry

Gotchas:

  • the compiler included in Microsoft Visual C++ Compiler for Python 2.7 is not compatible with distutils
  • the compiler included in version 7.0 of the Microsoft Windows SDK is not compatible with distutils
  • the compiler included in version 7.1 of the Microsoft Windows SDK is not compatible with Python, nor is it compatible with distutils
  • SaltStack's build scripts refer to packages not downloaded by pip
  • salt's setup.py wants all requisites installed before running its build process, while the other packages seem to be able to be built in any order
  • pip install -U setuptools
  • http://sourceforge.net/p/pywin32/bugs/648/
  • salt gets the wrong version number (2015.8.0 instead of 2015.8.3)
  • salt's setup.py does not create ".exe" files in the Python scripts folder
  • The root directory is hard-coded in salt\syspaths.py.

Directory Structure that must be created by hand:

	 c:\salt\
		 conf\
			 minion
			 pki\
		 var\
			 cache\
				 salt\
			 log\
				 salt\
			 run\
				 salt\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment