Initial copy of scripts from salt-windows-nsis repo

This commit is contained in:
Twangboy 2022-10-18 16:57:41 -06:00
parent 361868c21d
commit 15cd5edf65
No known key found for this signature in database
GPG key ID: ED267D5C0DE6F8A6
29 changed files with 2945 additions and 2136 deletions

View file

@ -1,180 +0,0 @@
@echo off
@echo Salt Windows Build Script, which calls the other *.ps1 scripts.
@echo ---------------------------------------------------------------------
@echo.
:: This script builds salt on any machine. It uses the following scripts:
:: - build_env.ps1: Sets up a Python environment will all dependencies salt will
:: will require
:: - build_pkg.bat: Bundles the contents of the Python directory into a
:: nullsoft installer binary
:: The script first calls the `build_env.ps1` script to set up a python
:: environment. Then it installs Salt into that python environment using Salt's
:: `setup.py install` command. Finally, it runs the `build_pkg.bat` to create
:: a NullSoft installer in the `installer` directory (pkg\windows\installer)
:: This script accepts two parameters.
:: Version: The version of Salt being built. If not passed, the version will
:: determined using `git describe`. The leading `v` will be removed
:: Python: The version of Python to build Salt on (Default is 3)
:: These parameters can be passed positionally or as named parameters. Named
:: parameters must be wrapped in quotes.
:: Examples:
:: # To build Salt 3000.3 on Python 3
:: build.bat 3000.3
:: build.bat 3000.3 3
:: # Using named parameters
:: build.bat "Version=3000.3"
:: build.bat "Version=3000.3" "Python=3"
:: # Using a mix
:: build.bat 3000.3 "Python=3"
:: To activate caching, set environment variables
:: SALTREPO_LOCAL_CACHE for resources from saltstack.com/...
:: SALT_REQ_LOCAL_CACHE for pip resources specified in req.txt
:: SALT_PIP_LOCAL_CACHE for pip resources specified in req_pip.txt
:: Make sure the script is run as Admin
@echo Administrative permissions required. Detecting permissions...
@echo ---------------------------------------------------------------------
net session >nul 2>&1
if %errorLevel%==0 (
echo ...Success: Administrative permissions confirmed.
) else (
echo ...Failure: This script must be run as Administrator
goto eof
)
@echo =====================================================================
@echo.
@echo Git required. Detecting git...
@echo ---------------------------------------------------------------------
where git >nul 2>&1
if %errorLevel%==0 (
echo ...Success: Git found.
) else (
echo ...Failure: This script needs to call git
goto eof
)
@echo =====================================================================
@echo.
:: Get Passed Parameters
@echo %0 :: Get Passed Parameters...
@echo ---------------------------------------------------------------------
set "Version="
set "Python="
:: First Parameter
if not "%~1"=="" (
echo.%1 | FIND /I "=" > nul && (
:: Named Parameter
echo Named Parameter
set "%~1"
) || (
:: Positional Parameter
echo Positional Parameter
set "Version=%~1"
)
)
:: Second Parameter
if not "%~2"=="" (
echo.%2 | FIND /I "=" > nul && (
:: Named Parameter
set "%~2"
) || (
:: Positional Parameter
set "Python=%~2"
)
)
:: If Version not defined, Get the version from Git
set git=0
if "%Version%"=="" (
echo Getting version from git
for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
set git=1
)
:: Strip off the leading `v` when getting version from git describe
if %git%==1 set Version=%Version:~1%
:: If Python not defined, Assume Python 3
if "%Python%"=="" (
set Python=3
)
:: Verify valid Python value (3)
:: We may need to add Python 4 in the future (delims=34)
set "x="
for /f "delims=3" %%i in ("%Python%") do set x=%%i
if Defined x (
echo Invalid Python Version specified. Must be 3. Passed %Python%
goto eof
)
@echo =====================================================================
@echo.
:: Define Variables
@echo %0 :: Defining Variables...
@echo ---------------------------------------------------------------------
if "%PyDir%"=="" (Set "PyDir=C:\Python38")
if "%PyVerMajor%"=="" (Set "PyVerMajor=3")
if "%PyDirMinor%"=="" (Set "PyVerMinor=8")
Set "PATH=%PATH%;%PyDir%;%PyDir%\Scripts"
Set "CurDir=%~dp0"
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"
@echo =====================================================================
@echo.
:: Create Build Environment
@echo %0 :: Create the Build Environment...
@echo ---------------------------------------------------------------------
PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env.ps1" -Silent
if not %errorLevel%==0 (
echo "%CurDir%build_env.ps1" returned errorlevel %errorLevel%. Aborting %0
goto eof
)
@echo.
:: Remove build and dist directories
@echo %0 :: Remove build and dist directories...
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" clean --all
if not %errorLevel%==0 (
goto eof
)
If Exist "%SrcDir%\dist" (
@echo removing %SrcDir%\dist
rd /S /Q "%SrcDir%\dist"
)
@echo.
:: Install Current Version of salt
@echo %0 :: Install Current Version of salt...
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" --quiet install --force
if not %errorLevel%==0 (
goto eof
)
@echo.
:: Build the Salt Package
@echo %0 :: Build the Salt Package...
@echo ---------------------------------------------------------------------
call "%CurDir%build_pkg.bat" "%Version%" "%Python%"
@echo.
:eof
@echo.
@echo =====================================================================
@echo End of %0
@echo =====================================================================

3
pkg/windows/build.cmd Normal file
View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\build.ps1" %*

203
pkg/windows/build.ps1 Normal file
View file

@ -0,0 +1,203 @@
<#
.SYNOPSIS
Parent script that runs all other scripts required to build Salt
.DESCRIPTION
This script Cleans, Installs Dependencies, Builds Python, Installs Salt,
and builds the NullSoft Installer. It depends on the following Scripts
and are called in this order:
- clean_env.ps1
- install_nsis.ps1
- build_python.ps1
- install_salt.ps1
- build_pkg.ps1
.EXAMPLE
build.ps1
.EXAMPLE
build.ps1 -Version 3005 -PythonVersion 3.8.13
#>
param(
[Parameter(Mandatory=$false)]
[Alias("v")]
# The version of Salt to be built. If this is not passed, the script will
# attempt to get it from the git describe command on the Salt source
# repo
[String] $Version,
[Parameter(Mandatory=$false)]
[ValidateSet("x86", "x64")]
[Alias("a")]
# The System Architecture to build. "x86" will build a 32-bit installer.
# "x64" will build a 64-bit installer. Default is: x64
$Architecture = "x64",
[Parameter(Mandatory=$false)]
[ValidatePattern("^\d{1,2}.\d{1,2}.\d{1,2}$")]
[ValidateSet(
# Until Pythonnet supports newer versions
#"3.10.5",
#"3.10.4",
#"3.10.3",
#"3.9.13",
#"3.9.12",
#"3.9.11",
"3.8.14",
"3.8.13",
"3.8.12",
"3.8.11",
"3.8.10"
)]
[Alias("p")]
# The version of Python to be built. Pythonnet only supports up to Python
# 3.8 for now. Pycurl stopped building wheel files after 7.43.0.5 which
# supported up to 3.8. So we're pinned to the latest version of Python 3.8.
# We may have to drop support for pycurl.
# Default is: 3.8.14
[String] $PythonVersion = "3.8.14"
)
# Script Preferences
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Import Modules
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
Import-Module $SCRIPT_DIR\Modules\uac-module.psm1
#-------------------------------------------------------------------------------
# Check for Elevated Privileges
#-------------------------------------------------------------------------------
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$SCRIPT_DIR"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
#-------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------
$PROJECT_DIR = $(git rev-parse --show-toplevel)
$SALT_REPO_URL = "https://github.com/saltstack/salt"
$SALT_SRC_DIR = "$( (Get-Item $PROJECT_DIR).Parent.FullName )\salt"
#-------------------------------------------------------------------------------
# Verify Salt and Version
#-------------------------------------------------------------------------------
if ( [String]::IsNullOrEmpty($Version) ) {
if ( ! (Test-Path -Path $SALT_SRC_DIR) ) {
Write-Host "Missing Salt Source Directory: $SALT_SRC_DIR"
exit 1
}
Push-Location $SALT_SRC_DIR
$Version = $( git describe )
$Version = $Version.Trim("v")
Pop-Location
if ( [String]::IsNullOrEmpty($Version) ) {
Write-Host "Failed to get version from $SALT_SRC_DIR"
exit 1
}
}
#-------------------------------------------------------------------------------
# Start the Script
#-------------------------------------------------------------------------------
Write-Host $("#" * 80)
Write-Host "Build Salt Installer Packages" -ForegroundColor Cyan
Write-Host "- Salt Version: $Version"
Write-Host "- Python Version: $PythonVersion"
Write-Host "- Architecture: $Architecture"
Write-Host $("#" * 80)
#-------------------------------------------------------------------------------
# Clean the Environment
#-------------------------------------------------------------------------------
PowerShell.exe -file "$SCRIPT_DIR\clean_env.ps1"
if ( ! $? ) {
Write-Host "Failed to clean the environment"
exit 1
}
#-------------------------------------------------------------------------------
# Install NSIS
#-------------------------------------------------------------------------------
powershell -file "$SCRIPT_DIR\install_nsis.ps1"
if ( ! $? ) {
Write-Host "Failed to install NSIS"
exit 1
}
#-------------------------------------------------------------------------------
# Install Visual Studio Build Tools
#-------------------------------------------------------------------------------
powershell -file "$SCRIPT_DIR\install_vs_buildtools.ps1"
if ( ! $? ) {
Write-Host "Failed to install Visual Studio Build Tools"
exit 1
}
#-------------------------------------------------------------------------------
# Build Python
#-------------------------------------------------------------------------------
powershell -file "$SCRIPT_DIR\build_python.ps1" `
-Version $PythonVersion `
-Architecture $Architecture
if ( ! $? ) {
Write-Host "Failed to build Python"
exit 1
}
#-------------------------------------------------------------------------------
# Install Salt
#-------------------------------------------------------------------------------
powershell -file "$SCRIPT_DIR\install_salt.ps1" -Architecture $Architecture
if ( ! $? ) {
Write-Host "Failed to install Salt"
exit 1
}
#-------------------------------------------------------------------------------
# Build Package
#-------------------------------------------------------------------------------
$KeywordArguments = @{Architecture = $Architecture}
if ( ! [String]::IsNullOrEmpty($Version) ) {
$KeywordArguments.Add("Version", $Version)
}
powershell -file "$SCRIPT_DIR\build_pkg.ps1" @KeywordArguments
if ( ! $? ) {
Write-Host "Failed to build package"
exit 1
}
Write-Host $("#" * 80)
Write-Host "Build Salt $Architecture Completed" -ForegroundColor Cyan
Write-Host $("#" * 80)

View file

@ -1,438 +0,0 @@
#==============================================================================
# You may need to change the execution policy in order to run this script
# Run the following in powershell:
#
# Set-ExecutionPolicy RemoteSigned
#
#==============================================================================
#
# FILE: dev_env.ps1
#
# DESCRIPTION: Development Environment Installation for Windows
#
# BUGS: https://github.com/saltstack/salt-windows-bootstrap/issues
#
# COPYRIGHT: (c) 2012-2017 by the SaltStack Team, see AUTHORS.rst for more
# details.
#
# LICENSE: Apache 2.0
# ORGANIZATION: SaltStack (saltstack.org)
# CREATED: 03/10/2017
#==============================================================================
# Load parameters
param(
[switch]$Silent,
[switch]$NoPipDependencies
)
#==============================================================================
# Get the Directory of actual script
#==============================================================================
$script_path = dir "$($myInvocation.MyCommand.Definition)"
$script_path = $script_path.DirectoryName
#==============================================================================
# Get the name of actual script
#==============================================================================
$script_name = $MyInvocation.MyCommand.Name
Write-Output "================================================================="
Write-Output ""
Write-Output " Development Environment Installation"
Write-Output ""
Write-Output " - Installs All Salt Dependencies"
Write-Output " - Detects 32/64 bit Architectures"
Write-Output ""
Write-Output " To run silently add -Silent"
Write-Output " eg: ${script_name} -Silent"
Write-Output ""
Write-Output " To run skip installing pip dependencies add -NoPipDependencies"
Write-Output " eg: ${script_name} -NoPipDependencies"
Write-Output ""
Write-Output "================================================================="
Write-Output ""
#==============================================================================
# Import Modules
#==============================================================================
Import-Module $script_path\Modules\download-module.psm1
Import-Module $script_path\Modules\get-settings.psm1
Import-Module $script_path\Modules\uac-module.psm1
Import-Module $script_path\Modules\zip-module.psm1
Import-Module $script_path\Modules\start-process-and-test-exitcode.psm1
#==============================================================================
# Check for Elevated Privileges
#==============================================================================
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$script_path"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
#------------------------------------------------------------------------------
# Load Settings
#------------------------------------------------------------------------------
$ini = Get-Settings
#------------------------------------------------------------------------------
# Create Directories
#------------------------------------------------------------------------------
$p = New-Item $ini['Settings']['DownloadDir'] -ItemType Directory -Force
$p = New-Item "$($ini['Settings']['DownloadDir'])\64" -ItemType Directory -Force
$p = New-Item "$($ini['Settings']['DownloadDir'])\32" -ItemType Directory -Force
$p = New-Item $ini['Settings']['SaltDir'] -ItemType Directory -Force
#------------------------------------------------------------------------------
# Determine Architecture (32 or 64 bit) and assign variables
#------------------------------------------------------------------------------
If ([System.IntPtr]::Size -ne 4) {
Write-Output "Detected 64bit Architecture..."
$bitDLLs = "64bitDLLs"
$bitPaths = "64bitPaths"
$bitPrograms = "64bitPrograms"
$bitFolder = "64"
} Else {
Write-Output "Detected 32bit Architecture"
$bitDLLs = "32bitDLLs"
$bitPaths = "32bitPaths"
$bitPrograms = "32bitPrograms"
$bitFolder = "32"
}
#------------------------------------------------------------------------------
# Check for installation of NSIS
#------------------------------------------------------------------------------
Write-Output " - Checking for NSIS installation . . ."
If (Test-Path "$($ini[$bitPaths]['NSISDir'])\NSIS.exe") {
# Found NSIS, do nothing
Write-Output " - NSIS Found . . ."
} Else {
# NSIS not found, install
Write-Output " - NSIS Not Found . . ."
Write-Output " - Downloading $($ini['Prerequisites']['NSIS']) . . ."
$file = "$($ini['Prerequisites']['NSIS'])"
$url = "$($ini['Settings']['SaltRepo'])/$file"
$file = "$($ini['Settings']['DownloadDir'])\$file"
DownloadFileWithProgress $url $file
# Install NSIS
Write-Output " - Installing $($ini['Prerequisites']['NSIS']) . . ."
$file = "$($ini['Settings']['DownloadDir'])\$($ini['Prerequisites']['NSIS'])"
$p = Start-Process $file -ArgumentList '/S' -Wait -NoNewWindow -PassThru
}
#------------------------------------------------------------------------------
# Check for installation of NSIS NxS Unzip Plug-in
#------------------------------------------------------------------------------
Write-Output " - Checking for NSIS NxS Unzip (ansi) Plug-in installation . . ."
If (Test-Path "$( $ini[$bitPaths]['NSISPluginsDirA'] )\nsisunz.dll") {
# Found NSIS NxS Unzip Plug-in, do nothing
Write-Output " - NSIS NxS Unzip Plugin (ansi) Found . . ."
} Else
{
# NSIS NxS Unzip Plug-in (ansi) not found, install
Write-Output " - NSIS NxS Unzip Plugin (ansi) Not Found . . ."
# Ansi Plugin
Write-Output " - Downloading $( $ini['Prerequisites']['NSISPluginUnzipA'] ) . . ."
$file = "$( $ini['Prerequisites']['NSISPluginUnzipA'] )"
$url = "$( $ini['Settings']['SaltRepo'] )/$file"
$file = "$( $ini['Settings']['DownloadDir'] )\$file"
DownloadFileWithProgress $url $file
# Extract Ansi Zip file
Write-Output " - Extracting . . ."
Expand-ZipFile $file $ini['Settings']['DownloadDir']
# Copy dll to plugins directory
Write-Output " - Copying dll to plugins directory . . ."
Move-Item "$( $ini['Settings']['DownloadDir'] )\nsisunz\Release\nsisunz.dll" "$( $ini[$bitPaths]['NSISPluginsDirA'] )\nsisunz.dll" -Force
# Remove temp files
Remove-Item "$( $ini['Settings']['DownloadDir'] )\nsisunz" -Force -Recurse
Remove-Item "$file" -Force
}
Write-Output " - Checking for NSIS NxS Unzip (unicode) Plug-in installation . . ."
If (Test-Path "$( $ini[$bitPaths]['NSISPluginsDirU'] )\nsisunz.dll") {
# Found NSIS NxS Unzip Plug-in (unicode), do nothing
Write-Output " - NSIS NxS Unzip Plugin (unicode) Found . . ."
} Else {
# Unicode Plugin
Write-Output " - Downloading $( $ini['Prerequisites']['NSISPluginUnzipU'] ) . . ."
$file = "$( $ini['Prerequisites']['NSISPluginUnzipU'] )"
$url = "$( $ini['Settings']['SaltRepo'] )/$file"
$file = "$( $ini['Settings']['DownloadDir'] )\$file"
DownloadFileWithProgress $url $file
# Extract Unicode Zip file
Write-Output " - Extracting . . ."
Expand-ZipFile $file $ini['Settings']['DownloadDir']
# Copy dll to plugins directory
Write-Output " - Copying dll to plugins directory . . ."
Move-Item "$( $ini['Settings']['DownloadDir'] )\NSISunzU\Plugin unicode\nsisunz.dll" "$( $ini[$bitPaths]['NSISPluginsDirU'] )\nsisunz.dll" -Force
# Remove temp files
Remove-Item "$( $ini['Settings']['DownloadDir'] )\NSISunzU" -Force -Recurse
Remove-Item "$file" -Force
}
#------------------------------------------------------------------------------
# Check for installation of EnVar Plugin for NSIS
#------------------------------------------------------------------------------
Write-Output " - Checking for EnVar Plugin of NSIS installation . . ."
If ( (Test-Path "$($ini[$bitPaths]['NSISPluginsDirA'])\EnVar.dll") -and (Test-Path "$($ini[$bitPaths]['NSISPluginsDirU'])\EnVar.dll") ) {
# Found EnVar Plugin for NSIS, do nothing
Write-Output " - EnVar Plugin for NSIS Found . . ."
} Else {
# EnVar Plugin for NSIS not found, install
Write-Output " - EnVar Plugin for NSIS Not Found . . ."
Write-Output " - Downloading $($ini['Prerequisites']['NSISPluginEnVar']) . . ."
$file = "$($ini['Prerequisites']['NSISPluginEnVar'])"
$url = "$($ini['Settings']['SaltRepo'])/$file"
$file = "$($ini['Settings']['DownloadDir'])\$file"
DownloadFileWithProgress $url $file
# Extract Zip File
Write-Output " - Extracting . . ."
Expand-ZipFile $file "$($ini['Settings']['DownloadDir'])\nsisenvar"
# Copy dlls to plugins directory (both ANSI and Unicode)
Write-Output " - Copying dlls to plugins directory . . ."
Move-Item "$( $ini['Settings']['DownloadDir'] )\nsisenvar\Plugins\x86-ansi\EnVar.dll" "$( $ini[$bitPaths]['NSISPluginsDirA'] )\EnVar.dll" -Force
Move-Item "$( $ini['Settings']['DownloadDir'] )\nsisenvar\Plugins\x86-unicode\EnVar.dll" "$( $ini[$bitPaths]['NSISPluginsDirU'] )\EnVar.dll" -Force
# Remove temp files
Remove-Item "$( $ini['Settings']['DownloadDir'] )\nsisenvar" -Force -Recurse
Remove-Item "$file" -Force
}
#------------------------------------------------------------------------------
# Check for installation of AccessControl Plugin for NSIS
#------------------------------------------------------------------------------
Write-Output " - Checking for AccessControl Plugin installation . . ."
If ( (Test-Path "$($ini[$bitPaths]['NSISPluginsDirA'])\AccessControl.dll") -and (Test-Path "$($ini[$bitPaths]['NSISPluginsDirU'])\AccessControl.dll") ) {
# Found AccessControl Plugin, do nothing
Write-Output " - AccessControl Plugin Found . . ."
} Else {
# AccessControl Plugin not found, install
Write-Output " - AccessControl Plugin Not Found . . ."
Write-Output " - Downloading $($ini['Prerequisites']['NSISPluginAccessControl']) . . ."
$file = "$($ini['Prerequisites']['NSISPluginAccessControl'])"
$url = "$($ini['Settings']['SaltRepo'])/$file"
$file = "$($ini['Settings']['DownloadDir'])\$file"
DownloadFileWithProgress $url $file
# Extract Zip File
Write-Output " - Extracting . . ."
Expand-ZipFile $file "$($ini['Settings']['DownloadDir'])\nsisaccesscontrol"
# Copy dlls to plugins directory (both ANSI and Unicode)
Write-Output " - Copying dlls to plugins directory . . ."
Move-Item "$( $ini['Settings']['DownloadDir'] )\nsisaccesscontrol\Plugins\i386-ansi\AccessControl.dll" "$( $ini[$bitPaths]['NSISPluginsDirA'] )\AccessControl.dll" -Force
Move-Item "$( $ini['Settings']['DownloadDir'] )\nsisaccesscontrol\Plugins\i386-unicode\AccessControl.dll" "$( $ini[$bitPaths]['NSISPluginsDirU'] )\AccessControl.dll" -Force
# Remove temp files
Remove-Item "$( $ini['Settings']['DownloadDir'] )\nsisaccesscontrol" -Force -Recurse
Remove-Item "$file" -Force
}
#------------------------------------------------------------------------------
# Check for installation of the MoveFileFolder Library for NSIS
#------------------------------------------------------------------------------
Write-Output " - Checking for MoveFileFolder Library installation . . ."
If ( Test-Path "$($ini[$bitPaths]['NSISDir'])\Include\MoveFileFolder.nsh" ) {
# Found MoveFileFolder Library for NSIS, do nothing
Write-Output " - MoveFileFolder Library for NSIS Found . . ."
} Else {
# MoveFileFolder Library for NSIS not found, install
Write-Output " - MoveFileFolder Library for NSIS Not Found . . ."
Write-Output " - Downloading $($ini['Prerequisites']['NSISLibMoveFileFolder']) . . ."
$file = "$($ini['Prerequisites']['NSISLibMoveFileFolder'])"
$url = "$($ini['Settings']['SaltRepo'])/$file"
$file = "$($ini['Settings']['DownloadDir'])\$file"
DownloadFileWithProgress $url $file
# Move library to the include directory
Write-Output " - Copying library to include directory . . ."
Move-Item "$file" "$( $ini[$bitPaths]['NSISDir'] )\Include\MoveFileFolder.nsh" -Force
}
#------------------------------------------------------------------------------
# Check for installation of Microsoft Visual Studio 2015 Build Tools
#------------------------------------------------------------------------------
Write-Output " - Checking for Microsoft Visual Studio 2015 Build Tools installation . . ."
If (Test-Path "$($ini[$bitPaths]['VS2015BuildToolsDir'])\cl.exe") {
# Found Microsoft Visual Studio 2015 Build Tools, do nothing
Write-Output " - Microsoft Visual Studio 2015 Build Tools Found . . ."
} Else {
# Microsoft Visual Studio 2015 Build Tools not found, install
Write-Output " - Microsoft Visual Studio 2015 Build Tools Not Found . . ."
Write-Output " - Downloading $($ini['Prerequisites']['VS2015BuildTools']) . . ."
$file = "$($ini['Prerequisites']['VS2015BuildTools'])"
$url = "$($ini['Settings']['SaltRepo'])/$file"
$file = "$($ini['Settings']['DownloadDir'])\$file"
DownloadFileWithProgress $url $file
# Extract Zip File
Write-Output " - Extracting . . ."
Expand-ZipFile $file "$($ini['Settings']['DownloadDir'])\vs2015buildtools"
# Install Microsoft Visual C++ Build Tools
Write-Output " - Installing $($ini['Prerequisites']['VS2015BuildTools']) . . ."
$file = "$($ini['Settings']['DownloadDir'])\vs2015buildtools\install.bat"
$p = Start-Process $file -Wait -NoNewWindow -PassThru
}
#------------------------------------------------------------------------------
# Install Python
#------------------------------------------------------------------------------
Write-Output " - Checking for Python 3 installation . . ."
If (Test-Path "$($ini['Settings']['Python3Dir'])\python.exe") {
# Found Python 3, do nothing
Write-Output " - Python 3 Found . . ."
} Else {
Write-Output " - Downloading $($ini[$bitPrograms]['Python3']) . . ."
$file = "$($ini[$bitPrograms]['Python3'])"
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
DownloadFileWithProgress $url $file
Write-Output " - $script_name :: Installing $($ini[$bitPrograms]['Python3']) . . ."
$p = Start-Process $file -ArgumentList "/Quiet InstallAllUsers=1 TargetDir=`"$($ini['Settings']['Python3Dir'])`" Include_doc=0 Include_tcltk=0 Include_test=0 Include_launcher=1 PrependPath=1 Shortcuts=0" -Wait -NoNewWindow -PassThru
}
#------------------------------------------------------------------------------
# Install VCRedist
#------------------------------------------------------------------------------
If (Test-Path "$($ini[$bitPrograms]['VCRedistReg'])") {
# Found VCRedist 2013, do nothing
Write-Output " - VCRedist 2013 Found . . ."
} Else {
Write-Output " - Downloading $($ini[$bitPrograms]['VCRedist']) . . ."
$file = "$($ini[$bitPrograms]['VCRedist'])"
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
DownloadFileWithProgress $url $file
Write-Output " - $script_name :: Installing $($ini[$bitPrograms]['VCRedist']) . . ."
$p = Start-Process $file -ArgumentList "/install /quiet /norestart" -Wait -NoNewWindow -PassThru
}
#------------------------------------------------------------------------------
# Update Environment Variables
#------------------------------------------------------------------------------
Write-Output " - Updating Environment Variables . . ."
$Path = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
If (!($Path.ToLower().Contains("$($ini['Settings']['Scripts3Dir'])".ToLower()))) {
$newPath = "$($ini['Settings']['Scripts3Dir']);$Path"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
$env:Path = $newPath
}
#==============================================================================
# Update PIP and SetupTools
#==============================================================================
Write-Output " ----------------------------------------------------------------"
Write-Output " - $script_name :: Updating PIP, SetupTools, and Wheel . . ."
Write-Output " ----------------------------------------------------------------"
Start_Process_and_test_exitcode "cmd" "/c $($ini['Settings']['Python3Dir'])\python.exe -m pip --disable-pip-version-check --no-cache-dir install -U pip setuptools wheel" "update pip"
#==============================================================================
# Install pypi resources using pip
#==============================================================================
If ($NoPipDependencies -eq $false) {
Write-Output " ----------------------------------------------------------------"
Write-Output " - $script_name :: Installing pypi resources using pip . . ."
Write-Output " ----------------------------------------------------------------"
Start_Process_and_test_exitcode "cmd" "/c $($ini['Settings']['Python3Dir'])\python.exe -m pip --disable-pip-version-check --no-cache-dir install -r $($ini['Settings']['SrcDir'])\requirements\static\pkg\py$($ini['Settings']['PyVerMajor']).$($ini['Settings']['PyVerMinor'])\windows.txt" "pip install"
}
If (Test-Path "$($ini['Settings']['SitePkgs3Dir'])\pywin32_system32" -PathType Container )
{
#==============================================================================
# Cleaning Up PyWin32
#==============================================================================
Write-Output " ----------------------------------------------------------------"
Write-Output " - $script_name :: Cleaning Up PyWin32 . . ."
Write-Output " ----------------------------------------------------------------"
# Move DLL's to Python Root
# The dlls have to be in Python directory and the site-packages\win32 directory
Write-Output " - $script_name :: Moving PyWin32 DLLs . . ."
Copy-Item "$( $ini['Settings']['SitePkgs3Dir'] )\pywin32_system32\*.dll" "$( $ini['Settings']['Python3Dir'] )" -Force
Move-Item "$( $ini['Settings']['SitePkgs3Dir'] )\pywin32_system32\*.dll" "$( $ini['Settings']['SitePkgs3Dir'] )\win32" -Force
# Create gen_py directory
Write-Output " - $script_name :: Creating gen_py Directory . . ."
New-Item -Path "$( $ini['Settings']['SitePkgs3Dir'] )\win32com\gen_py" -ItemType Directory -Force | Out-Null
# Remove pywin32_system32 directory
Write-Output " - $script_name :: Removing pywin32_system32 Directory . . ."
Remove-Item "$( $ini['Settings']['SitePkgs3Dir'] )\pywin32_system32"
# Remove PyWin32 PostInstall and testall Scripts
Write-Output " - $script_name :: Removing PyWin32 scripts . . ."
Remove-Item "$( $ini['Settings']['Scripts3Dir'] )\pywin32_*" -Force -Recurse
}
#==============================================================================
# Copy DLLs to Python Directory
#==============================================================================
Write-Output " ----------------------------------------------------------------"
Write-Output " - $script_name :: Copying DLLs . . ."
Write-Output " ----------------------------------------------------------------"
# Architecture Specific DLL's
ForEach($key in $ini[$bitDLLs].Keys) {
Write-Output " - $key . . ."
$file = "$($ini[$bitDLLs][$key])"
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$($file.Split("/")[-1])"
DownloadFileWithProgress $url $file
Copy-Item $file -destination $($ini['Settings']['Python3Dir'])
}
#------------------------------------------------------------------------------
# Script complete
#------------------------------------------------------------------------------
Write-Output "================================================================="
Write-Output " $script_name :: Salt Stack Dev Environment Script Complete"
Write-Output "================================================================="
Write-Output ""
If (-Not $Silent) {
Write-Output "Press any key to continue ..."
$p = $HOST.UI.RawUI.Flushinputbuffer()
$p = $HOST.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
#------------------------------------------------------------------------------
# Remove the temporary download directory
#------------------------------------------------------------------------------
Write-Output " ----------------------------------------------------------------"
Write-Output " - $script_name :: Cleaning up downloaded files"
Write-Output " ----------------------------------------------------------------"
Write-Output ""
Remove-Item $($ini['Settings']['DownloadDir']) -Force -Recurse

View file

@ -1,635 +0,0 @@
@echo off
@echo Salt Windows Build Package Script
@echo =====================================================================
@echo.
:: Get Passed Parameters
@echo Get Passed Parameters...
@echo ---------------------------------------------------------------------
Set "Version="
Set "Python="
:: First Parameter
if not "%~1"=="" (
echo.%1 | FIND /I "=" > nul && (
:: Named Parameter
set "%~1"
) || (
:: Positional Parameter
set "Version=%~1"
)
)
:: Second Parameter
if not "%~2"=="" (
echo.%2 | FIND /I "=" > nul && (
:: Named Parameter
set "%~2"
) || (
:: Positional Parameter
set "Python=%~2"
)
)
:: If Version not defined, Get the version from Git
if "%Version%"=="" (
for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
)
:: If Python not defined, Assume Python 3
if "%Python%"=="" (
set Python=3
)
:: Verify valid Python value (3)
:: We may need to add Python 4 in the future (delims=34)
set "x="
for /f "delims=3" %%i in ("%Python%") do set x=%%i
if Defined x (
echo Invalid Python Version specified. Must be 3. Passed %Python%
goto eof
)
@echo.
:: Define Variables
@echo Defining Variables...
@echo ----------------------------------------------------------------------
if %PyDir%=="" (Set "PyDir=C:\Python38")
if %PyVerMajor%=="" (Set "PyVerMajor=3")
if %PyVerMinor%=="" (Set "PyVerMinor=8")
:: Verify the Python Installation
If not Exist "%PyDir%\python.exe" (
@echo Expected version of Python not found: Python %PyVerMajor%.%PyVerMinor%"
exit /b 1
)
Set "CurDir=%~dp0"
Set "BldDir=%CurDir%buildenv"
Set "BinDir=%CurDir%buildenv\bin"
Set "CnfDir=%CurDir%buildenv\conf"
Set "InsDir=%CurDir%installer"
Set "PreDir=%CurDir%prereqs"
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"
:: Find the NSIS Installer
If Exist "C:\Program Files\NSIS\" (
Set "NSIS=C:\Program Files\NSIS\"
) Else (
Set "NSIS=C:\Program Files (x86)\NSIS\"
)
If not Exist "%NSIS%NSIS.exe" (
@echo "NSIS not found in %NSIS%"
exit /b 1
)
:: Add NSIS to the Path
Set "PATH=%NSIS%;%PATH%"
@echo.
:: Check for existing bin directory and remove
If Exist "%BinDir%\" (
@echo Removing %BinDir%
@echo ----------------------------------------------------------------------
rd /S /Q "%BinDir%"
)
:: Copy the contents of the Python Dir to bin
@echo Copying "%PyDir%" to bin...
@echo ----------------------------------------------------------------------
@echo xcopy /E /Q "%PyDir%" "%BinDir%\"
xcopy /E /Q "%PyDir%" "%BinDir%\"
@echo.
:: Copy the default master and minion configs to buildenv\conf
@echo Copying configs to buildenv\conf...
@echo ----------------------------------------------------------------------
@echo xcopy /E /Q "%SrcDir%\conf\master" "%CnfDir%\"
xcopy /Q /Y "%SrcDir%\conf\master" "%CnfDir%\"
@echo xcopy /E /Q "%SrcDir%\conf\minion" "%CnfDir%\"
xcopy /Q /Y "%SrcDir%\conf\minion" "%CnfDir%\"
@echo.
@echo Copying SSM to buildenv
@echo ----------------------------------------------------------------------
:: Set the location of the ssm to download
Set Url64="https://repo.saltproject.io/windows/dependencies/64/ssm-2.24-103-gdee49fc.exe"
Set Url32="https://repo.saltproject.io/windows/dependencies/32/ssm-2.24-103-gdee49fc.exe"
:: Check for 64 bit by finding the Program Files (x86) directory
If Defined ProgramFiles(x86) (
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url "%Url64%" -file "%BinDir%\ssm.exe"
) Else (
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url "%Url32%" -file "%BinDir%\ssm.exe"
)
@echo.
:: Make sure the "prereq" directory exists and is empty
If Exist "%PreDir%" rd /s /q "%PreDir%"
mkdir "%PreDir%"
:: 32 bit binaries only needed for x86 installer
:: ProgramFiles(x86) is defined on AMD64 systems
:: If it's defined, skip the x86 binaries
If Defined ProgramFiles(x86) goto dependencies_x64
:dependencies_x86
@echo.
@echo Copying VCRedist 2013 X86 to Prerequisites
@echo ----------------------------------------------------------------------
set Url=https://repo.saltproject.io/windows/dependencies/32/vcredist_x86_2013.exe
set Name=vcredist_x86_2013.exe
@echo - Downloading %Name%
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url %Url% -file "%PreDir%\%Name%"
@echo.
@echo Copying Universal C Runtimes X86 to Prerequisites
@echo ----------------------------------------------------------------------
set Url=https://repo.saltproject.io/windows/dependencies/32/ucrt_x86.zip
set Name=ucrt_x86.zip
@echo - Downloading %Name%
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url %Url% -file "%PreDir%\%Name%"
goto prereq_end
:: These are only needed on 64bit installer
:dependencies_x64
@echo.
@echo Copying VCRedist 2013 X64 to Prerequisites
@echo ----------------------------------------------------------------------
set Url=https://repo.saltproject.io/windows/dependencies/64/vcredist_x64_2013.exe
set Name=vcredist_x64_2013.exe
@echo - Downloading %Name%
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url %Url% -file "%PreDir%\%Name%"
@echo.
@echo Copying Universal C Runtimes X64 to Prerequisites
@echo ----------------------------------------------------------------------
set Url=https://repo.saltproject.io/windows/dependencies/64/ucrt_x64.zip
set Name=ucrt_x64.zip
@echo - Downloading %Name%
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url %Url% -file "%PreDir%\%Name%"
:prereq_end
:: Remove the fixed path in .exe files
@echo Removing fixed path from .exe files
@echo ----------------------------------------------------------------------
:: As of setuptools 53.0 easy_install has been removed
:: https://github.com/pypa/setuptools/pull/2544
:: "%PyDir%\python" "%CurDir%\portable.py" -f "%BinDir%\Scripts\easy_install.exe"
:: "%PyDir%\python" "%CurDir%\portable.py" -f "%BinDir%\Scripts\easy_install-%PyVerMajor%.%PyVerMinor%.exe"
"%PyDir%\python" "%CurDir%\portable.py" -f "%BinDir%\Scripts\pip.exe"
"%PyDir%\python" "%CurDir%\portable.py" -f "%BinDir%\Scripts\pip%PyVerMajor%.%PyVerMinor%.exe"
"%PyDir%\python" "%CurDir%\portable.py" -f "%BinDir%\Scripts\pip%PyVerMajor%.exe"
"%PyDir%\python" "%CurDir%\portable.py" -f "%BinDir%\Scripts\wheel.exe"
@echo.
@echo Cleaning up unused files and directories...
@echo ----------------------------------------------------------------------
:: Remove all Compiled Python files (.pyc)
del /S /Q "%BinDir%\*.pyc" 1>nul
:: Remove all Compiled HTML Help (.chm)
del /S /Q "%BinDir%\*.chm" 1>nul
:: Remove all empty text files (they are placeholders for git)
del /S /Q "%BinDir%\..\empty.*" 1>nul
:: Delete Unused Docs and Modules
If Exist "%BinDir%\Doc" rd /S /Q "%BinDir%\Doc"
If Exist "%BinDir%\share" rd /S /Q "%BinDir%\share"
If Exist "%BinDir%\tcl" rd /S /Q "%BinDir%\tcl"
If Exist "%BinDir%\Lib\idlelib" rd /S /Q "%BinDir%\Lib\idlelib"
If Exist "%BinDir%\Lib\lib-tk" rd /S /Q "%BinDir%\Lib\lib-tk"
If Exist "%BinDir%\Lib\test" rd /S /Q "%BinDir%\Lib\test"
If Exist "%BinDir%\Lib\unit-test" rd /S /Q "%BinDir%\Lib\unit-test"
:: Delete Unused .dll files
If Exist "%BinDir%\DLLs\tcl85.dll" del /Q "%BinDir%\DLLs\tcl85.dll" 1>nul
If Exist "%BinDir%\DLLs\tclpip85.dll" del /Q "%BinDir%\DLLs\tclpip85.dll" 1>nul
If Exist "%BinDir%\DLLs\tk85.dll" del /Q "%BinDir%\DLLs\tk85.dll" 1>nul
:: Delete Unused .lib files
If Exist "%BinDir%\libs\_tkinter.lib" del /Q "%BinDir%\libs\_tkinter.lib" 1>nul
:: Delete .txt files
If Exist "%BinDir%\NEWS.txt" del /Q "%BinDir%\NEWS.txt" 1>nul
If Exist "%BinDir%\README.txt" del /Q "%BinDir%\README.txt" 1>nul
:: Delete Unneeded Python Libraries
If Exist "%BinDir%\Lib\site-packages\pythonwin" rd /S /Q "%BinDir%\Lib\site-packages\pythonwin"
:: Delete Non-Windows Modules
If Exist "%BinDir%\Lib\site-packages\salt\modules\acme.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\acme.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\alternatives.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\alternatives.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\apf.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\apf.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\aptpkg.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\aptpkg.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\at.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\at.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\bcache.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\bcache.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\blockdev.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\blockdev.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\bluez.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\bluez.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\bridge.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\bridge.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\bsd_shadow.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\bsd_shadow.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\btrfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\btrfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\ceph.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\ceph.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\container_resource.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\container_resource.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\cron.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\cron.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\csf.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\csf.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\daemontools.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\daemontools.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\deb*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\deb*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\devmap.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\devmap.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\dpkg.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\dpkg.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\ebuild.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\ebuild.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\eix.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\eix.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\eselect.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\eselect.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\ethtool.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\ethtool.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\extfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\extfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\firewalld.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\firewalld.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\freebsd*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\freebsd*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\genesis.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\genesis.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\gentoo*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\gentoo*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\glusterfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\glusterfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\gnomedesktop.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\gnomedesktop.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\groupadd.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\groupadd.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\grub_legacy.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\grub_legacy.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\guestfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\guestfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\htpasswd.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\htpasswd.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\ilo.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\ilo.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\img.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\img.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\incron.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\incron.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\inspector.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\inspector.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\ipset.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\ipset.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\iptables.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\iptables.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\iwtools.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\iwtools.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\k8s.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\k8s.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\kapacitor.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\kapacitor.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\keyboard.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\keyboard.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\keystone.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\keystone.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\kmod.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\kmod.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\layman.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\layman.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\linux*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\linux*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\localemod.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\localemod.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\locate.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\locate.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\logadm.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\logadm.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\logrotate.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\logrotate.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\lvs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\lvs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\lxc.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\lxc.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\mac*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\mac*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\makeconf.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\makeconf.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\mdadm.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\mdadm.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\mdata.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\mdata.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\monit.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\monit.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\moosefs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\moosefs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\mount.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\mount.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\napalm*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\napalm*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\netbsd*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\netbsd*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\netscaler.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\netscaler.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\neutron.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\neutron.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\nfs3.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\nfs3.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\nftables.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\nftables.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\nova.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\nova.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\nspawn.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\nspawn.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\openbsd*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\openbsd*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\openstack_mng.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\openstack_mng.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\openvswitch.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\openvswitch.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\opkg.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\opkg.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\pacman.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\pacman.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\parallels.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\parallels.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\parted.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\parted.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\pcs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\pcs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\pkgin.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\pkgin.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\pkgng.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\pkgng.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\pkgutil.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\pkgutil.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\portage_config.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\portage_config.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\postfix.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\postfix.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\poudriere.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\poudriere.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\powerpath.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\powerpath.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\pw_*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\pw_*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\qemu_ndb.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\qemu_ndb.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\quota.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\quota.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\redismod.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\redismod.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\restartcheck.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\restartcheck.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\rh_*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\rh_*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\riak.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\riak.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\rpm*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\rpm*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\runit.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\runit.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\s6.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\s6.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\scsi.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\scsi.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\seed.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\seed.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\sensors.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\sensors.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\service.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\service.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\shadow.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\shadow.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\smartos*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\smartos*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\smf.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\smf.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\snapper.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\snapper.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\solaris*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\solaris*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\solr.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\solr.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\ssh_*"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\ssh_*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\supervisord.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\supervisord.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\sysbench.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\sysbench.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\sysfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\sysfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\sysrc.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\sysrc.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\system.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\system.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\test_virtual.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\test_virtual.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\timezone.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\timezone.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\trafficserver.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\trafficserver.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\tuned.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\tuned.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\udev.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\udev.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\upstart.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\upstart.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\useradd.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\useradd.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\uswgi.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\uswgi.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\varnish.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\varnish.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\vbox_guest.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\vbox_guest.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\vboxmanage.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\vboxmanage.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\virt.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\virt.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\xapi.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\xapi.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\xbpspkg.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\xbpspkg.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\xfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\xfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\yumpkg.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\yum.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\zfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\zfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\znc.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\znc.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\zpool.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\zpool.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\modules\zypper.py"^
del /Q "%BinDir%\Lib\site-packages\salt\modules\zypper.*" 1>nul
:: Delete Non-Windows States
If Exist "%BinDir%\Lib\site-packages\salt\states\acme.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\acme.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\alternatives.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\alternatives.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\aptpkg.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\aptpkg.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\at.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\at.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\blockdev.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\blockdev.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\ceph.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\ceph.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\cron.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\cron.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\csf.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\csf.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\debconfmod.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\debconfmod.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\eselect.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\eselect.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\ethtool.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\ethtool.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\firewalld.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\firewalld.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\glusterfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\glusterfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\gnomedesktop.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\gnomedesktop.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\htpasswd.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\htpasswd.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\incron.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\incron.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\ipset.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\ipset.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\iptables.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\iptables.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\k8s.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\k8s.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\kapacitor.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\kapacitor.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\keyboard.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\keyboard.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\keystone.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\keystone.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\kmod.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\kmod.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\layman.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\layman.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\linux*"^
del /Q "%BinDir%\Lib\site-packages\salt\states\linux*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\lxc.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\lxc.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\mac_*"^
del /Q "%BinDir%\Lib\site-packages\salt\states\mac_*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\makeconf.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\makeconf.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\mdadm.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\mdadm.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\monit.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\monit.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\mount.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\mount.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\nftables.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\nftables.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\pcs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\pcs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\pkgng.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\pkgng.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\portage_config.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\portage_config.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\powerpath.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\powerpath.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\quota.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\quota.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\redismod.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\redismod.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\smartos.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\smartos.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\snapper.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\snapper.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\ssh_*"^
del /Q "%BinDir%\Lib\site-packages\salt\states\ssh_*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\supervisord.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\supervisord.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\sysrc.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\sysrc.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\trafficserver.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\trafficserver.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\tuned.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\tuned.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\vbox_guest.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\vbox_guest.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\virt.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\virt.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\zfs.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\zfs.*" 1>nul
If Exist "%BinDir%\Lib\site-packages\salt\states\zpool.py"^
del /Q "%BinDir%\Lib\site-packages\salt\states\zpool.*" 1>nul
:: Remove Unneeded Components
If Exist "%BinDir%\Lib\site-packages\salt\cloud"^
rd /S /Q "%BinDir%\Lib\site-packages\salt\cloud" 1>nul
@echo.
@echo Building the installer...
@echo ----------------------------------------------------------------------
:: Make the Master installer if the nullsoft script exists
If Exist "%InsDir%\Salt-Setup.nsi"^
makensis.exe /DSaltVersion=%Version% /DPythonVersion=%Python% "%InsDir%\Salt-Setup.nsi"
:: Remove files not needed for Salt Minion
:: salt
:: salt has to be removed individually (can't wildcard it)
If Exist "%BinDir%\Scripts\salt"^
del /Q "%BinDir%\Scripts\salt" 1>nul
If Exist "%BinDir%\Scripts\salt.exe"^
del /Q "%BinDir%\Scripts\salt.exe" 1>nul
If Exist "%BldDir%\salt.bat"^
del /Q "%BldDir%\salt.bat" 1>nul
:: salt-key
If Exist "%BinDir%\Scripts\salt-key*"^
del /Q "%BinDir%\Scripts\salt-key*" 1>nul
If Exist "%BldDir%\salt-key.bat"^
del /Q "%BldDir%\salt-key.bat" 1>nul
:: salt-master
If Exist "%BinDir%\Scripts\salt-master*"^
del /Q "%BinDir%\Scripts\salt-master*" 1>nul
If Exist "%BldDir%\salt-master.bat"^
del /Q "%BldDir%\salt-master.bat" 1>nul
:: salt-run
If Exist "%BinDir%\Scripts\salt-run*"^
del /Q "%BinDir%\Scripts\salt-run*" 1>nul
If Exist "%BldDir%\salt-run.bat"^
del /Q "%BldDir%\salt-run.bat" 1>nul
:: Remove the master config file
if Exist "%CnfDir%\master"^
del /Q "%CnfDir%\master" 1>nul
:: Make the Salt Minion Installer
makensis.exe /DSaltVersion=%Version% /DPythonVersion=%Python% "%InsDir%\Salt-Minion-Setup.nsi"
@echo.
@echo.
@echo ======================================================================
@echo Script completed...
@echo ======================================================================
@echo Installation file can be found in the following directory:
@echo %InsDir%
:done
if [%Version%] == [] pause

View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\build_pkg.ps1" %*

559
pkg/windows/build_pkg.ps1 Normal file
View file

@ -0,0 +1,559 @@
<#
.SYNOPSIS
Script that builds a NullSoft Installer package for Salt
.DESCRIPTION
This script takes the contents of the Python Directory that has Salt installed
and creates a NullSoft Installer based on that directory.
.EXAMPLE
build_pkg.ps1 -Version 3005
#>
param(
[Parameter(Mandatory=$false)]
[Alias("v")]
# The version of Salt to be built. If this is not passed, the script will
# attempt to get it from the git describe command on the Salt source
# repo
[String] $Version,
[Parameter(Mandatory=$false)]
[ValidateSet("x86", "x64")]
[Alias("a")]
# The System Architecture to build. "x86" will build a 32-bit installer.
# "x64" will build a 64-bit installer. Default is: x64
$Architecture = "x64"
)
# Script Preferences
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------
# Script Variables
$NSIS_DIR = "$( ${env:ProgramFiles(x86)} )\NSIS"
if ( $Architecture -eq "x64" ) {
$ARCH = "AMD64"
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
} else {
$ARCH = "x86"
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/32"
}
# Python Variables
# TODO: These need to be moved to a Script option
$PY_VERSION = "3.8"
$PY_DOT_VERSION = "3.8.14"
$PYTHON_DIR = "C:\Python$($PY_VERSION -replace "\.")"
$PYTHON_BIN = "$PYTHON_DIR\python.exe"
$SCRIPTS_DIR = "$PYTHON_DIR\Scripts"
# Build Variables
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
$PROJECT_DIR = $(git rev-parse --show-toplevel)
$SALT_REPO_URL = "https://github.com/saltstack/salt"
$SALT_SRC_DIR = "$( (Get-Item $PROJECT_DIR).Parent.FullName )\salt"
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
$BUILD_DIR_BIN = "$BUILD_DIR\bin"
$BUILD_DIR_SALT = "$BUILD_DIR_BIN\Lib\site-packages\salt"
$BUILD_DIR_CONF = "$BUILD_DIR\configs"
$INSTALLER_DIR = "$SCRIPT_DIR\installer"
$PREREQ_DIR = "$SCRIPT_DIR\prereqs"
#-------------------------------------------------------------------------------
# Verify Salt and Version
#-------------------------------------------------------------------------------
if ( [String]::IsNullOrEmpty($Version) ) {
if ( ! (Test-Path -Path $SALT_SRC_DIR) ) {
Write-Host "Missing Salt Source Directory: $SALT_SRC_DIR"
exit 1
}
Push-Location $SALT_SRC_DIR
$Version = $( git describe )
$Version = $Version.Trim("v")
Pop-Location
if ( [String]::IsNullOrEmpty($Version) ) {
Write-Host "Failed to get version from $SALT_SRC_DIR"
exit 1
}
}
#-------------------------------------------------------------------------------
# Start the Script
#-------------------------------------------------------------------------------
Write-Host $("=" * 80)
Write-Host "Build NullSoft Installer for Salt" -ForegroundColor Cyan
Write-Host "- Architecture: $Architecture"
Write-Host "- Salt Version: $Version"
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# Verify Environment
#-------------------------------------------------------------------------------
Write-Host "Verifying Salt Source Present: " -NoNewline
if ( Test-Path -Path $SALT_SRC_DIR ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit
}
Write-Host "Verifying Python Installation: " -NoNewline
if ( Test-Path -Path "$PYTHON_DIR\python.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Verifying Salt Installation: " -NoNewline
if ( Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Verifying NSIS Installation: " -NoNewline
if ( Test-Path -Path "$NSIS_DIR\makensis.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Cleaning Build Environment
#-------------------------------------------------------------------------------
if ( Test-Path -Path $BUILD_DIR_BIN ) {
Write-Host "Removing Bin Directory: " -NoNewline
Remove-Item -Path $BUILD_DIR_BIN -Recurse -Force
if ( ! (Test-Path -Path $BUILD_DIR_BIN) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
if ( Test-Path -Path $BUILD_DIR_CONF ) {
Write-Host "Removing Configs Directory: " -NoNewline
Remove-Item -Path $BUILD_DIR_CONF -Recurse -Force
if ( ! (Test-Path -Path $BUILD_DIR_CONF) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
if ( Test-Path -Path $PREREQ_DIR ) {
Write-Host "Removing PreReq Directory: " -NoNewline
Remove-Item -Path $PREREQ_DIR -Recurse -Force
if ( ! (Test-Path -Path $PREREQ_DIR) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Staging the Build Environment
#-------------------------------------------------------------------------------
Write-Host "Copying $PYTHON_DIR to Bin: " -NoNewline
Copy-Item -Path "$PYTHON_DIR" -Destination "$BUILD_DIR_BIN" -Recurse
if ( Test-Path -Path "$BUILD_DIR_BIN\python.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying config files from Salt: " -NoNewline
New-Item -Path $BUILD_DIR_CONF -ItemType Directory | Out-Null
Copy-Item -Path "$SALT_SRC_DIR\conf\minion" -Destination "$BUILD_DIR_CONF"
if ( Test-Path -Path "$BUILD_DIR_CONF\minion" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying SSM to Bin: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/ssm-2.24-103-gdee49fc.exe" -OutFile "$BUILD_DIR_BIN\ssm.exe"
if ( Test-Path -Path "$BUILD_DIR_BIN\ssm.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
New-Item -Path $PREREQ_DIR -ItemType Directory | Out-Null
if ( $Architecture -eq "x64" ) {
# 64-bit Prereqs
Write-Host "Copying VCRedist 2013 x64 to prereqs: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/vcredist_x64_2013.exe" -OutFile "$PREREQ_DIR\vcredist_x64_2013.exe"
if ( Test-Path -Path "$PREREQ_DIR\vcredist_x64_2013.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying Universal C Runtimes x64 to prereqs: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/ucrt_x64.zip" -OutFile "$PREREQ_DIR\ucrt_x64.zip"
if ( Test-Path -Path "$PREREQ_DIR\ucrt_x64.zip" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
} else {
# 32-bit Prereqs
Write-Host "Copying VCRedist 2013 x86 to prereqs: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/vcredist_x86_2013.exe" -OutFile "$PREREQ_DIR\vcredist_x86_2013.exe"
if ( Test-Path -Path "$PREREQ_DIR\vcredist_x86_2013.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying Universal C Runtimes x86 to prereqs: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/ucrt_x86.zip" -OutFile "$PREREQ_DIR\ucrt_x86.zip"
if ( Test-Path -Path "$PREREQ_DIR\ucrt_x86.zip" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Remove binaries not needed by Salt
#-------------------------------------------------------------------------------
# These binaries may conflict with an existing Python installation. These
# binaries are needed for Tiamat builds, but not for standard Salt packages
# which we are building here
$binaries = @(
"py.exe",
"pyw.exe",
"pythonw.exe",
"venvlauncher.exe",
"venvwlauncher.exe"
)
Write-Host "Removing Python binaries: " -NoNewline
$binaries | ForEach-Object {
Remove-Item -Path "$BUILD_DIR_BIN\$_"
if ( ! ( Test-Path -Path "$PYTHON_DIR\$_") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
#-------------------------------------------------------------------------------
# Make the Binaries in the Scripts directory portable
#-------------------------------------------------------------------------------
$binaries = Get-ChildItem -Path "$BUILD_DIR_BIN\Scripts" -Filter "*.exe"
$binaries | ForEach-Object {
Write-Host "Making $_ Portable: " -NoNewline
$before = $_.LastWriteTime
Start-Process -FilePath "$PYTHON_BIN" `
-ArgumentList "$SCRIPT_DIR\portable.py", "-f", "$($_.FullName)" `
-Wait -WindowStyle Hidden
$after = (Get-Item -Path $_.FullName).LastWriteTime
if ( $after -gt $before) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
}
}
#-------------------------------------------------------------------------------
# Remove Non-Windows Execution Modules
#-------------------------------------------------------------------------------
Write-Host "Removing Non-Windows Execution Modules: " -NoNewline
$modules = "acme",
"aix",
"alternatives",
"apcups",
"apf",
"apt",
"arista",
"at",
"bcache",
"blockdev",
"bluez",
"bridge",
"bsd",
"btrfs",
"ceph",
"container_resource",
"cron",
"csf",
"daemontools",
"deb*",
"devmap",
"dpkg",
"ebuild",
"eix",
"eselect",
"ethtool",
"extfs",
"firewalld",
"freebsd",
"genesis",
"gentoo",
"glusterfs",
"gnomedesktop",
"groupadd",
"grub_legacy",
"guestfs",
"htpasswd",
"ilo",
"img",
"incron",
"inspector",
"ipset",
"iptables",
"iwtools",
"k8s",
"kapacitor",
"keyboard",
"keystone",
"kmod",
"layman",
"linux",
"localemod",
"locate",
"logadm",
"logrotate",
"lvs",
"lxc",
"mac",
"makeconf",
"mdadm",
"mdata",
"monit",
"moosefs",
"mount",
"napalm",
"netbsd",
"netscaler",
"neutron",
"nfs3",
"nftables",
"nova",
"nspawn",
"openbsd",
"openstack",
"openvswitch",
"opkg",
"pacman",
"parallels",
"parted",
"pcs",
"pkgin",
"pkgng",
"pkgutil",
"portage_config",
"postfix",
"poudriere",
"powerpath",
"pw_",
"qemu_",
"quota",
"redismod",
"restartcheck",
"rh_",
"riak",
"rpm",
"runit",
"s6",
"scsi",
"seed",
"sensors",
"service",
"shadow",
"smartos",
"smf",
"snapper",
"solaris",
"solr",
"ssh_",
"supervisord",
"sysbench",
"sysfs",
"sysrc",
"system",
"test_virtual",
"timezone",
"trafficserver",
"tuned",
"udev",
"upstart",
"useradd",
"uswgi",
"varnish",
"vbox",
"virt",
"xapi",
"xbpspkg",
"xfs",
"yum*",
"zfs",
"znc",
"zpool",
"zypper"
$modules | ForEach-Object {
Remove-Item -Path "$BUILD_DIR_SALT\modules\$_*" -Recurse
if ( Test-Path -Path "$BUILD_DIR_SALT\modules\$_*" ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $BUILD_DIR_SALT\modules\$_"
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
#-------------------------------------------------------------------------------
# Remove Non-Windows State Modules
#-------------------------------------------------------------------------------
Write-Host "Removing Non-Windows State Modules: " -NoNewline
$states = "acme",
"alternatives",
"apt",
"at",
"blockdev",
"ceph",
"cron",
"csf",
"deb",
"eselect",
"ethtool",
"firewalld",
"glusterfs",
"gnome",
"htpasswd",
"incron",
"ipset",
"iptables",
"k8s",
"kapacitor",
"keyboard",
"keystone",
"kmod",
"layman",
"linux",
"lxc",
"mac",
"makeconf",
"mdadm",
"monit",
"mount",
"nftables",
"pcs",
"pkgng",
"portage",
"powerpath",
"quota",
"redismod",
"smartos",
"snapper",
"ssh",
"supervisord",
"sysrc",
"trafficserver",
"tuned",
"vbox",
"virt.py",
"zfs",
"zpool"
$states | ForEach-Object {
Remove-Item -Path "$BUILD_DIR_SALT\states\$_*" -Recurse
if ( Test-Path -Path "$BUILD_DIR_SALT\states\$_*" ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $BUILD_DIR_SALT\states\$_"
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
Write-Host "Removing unneeded files (.pyc, .chm): " -NoNewline
$remove = "*.pyc",
"__pycache__",
"*.chm"
$remove | ForEach-Object {
$found = Get-ChildItem -Path "$BUILD_DIR_BIN\$_" -Recurse
$found | ForEach-Object {
Remove-Item -Path "$_" -Recurse -Force
if ( Test-Path -Path $_ ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $_"
exit 1
}
}
}
Write-Host "Success" -ForegroundColor Green
#-------------------------------------------------------------------------------
# Build the Installer
#-------------------------------------------------------------------------------
Write-Host "Building the Installer: " -NoNewline
$installer_name = "Salt-Minion-$Version-Py$($PY_VERSION.Split(".")[0])-$ARCH-Setup.exe"
Start-Process -FilePath $NSIS_DIR\makensis.exe `
-ArgumentList "/DSaltVersion=$Version", `
"/DPythonArchitecture=$Architecture", `
"$INSTALLER_DIR\Salt-Minion-Setup.nsi" `
-Wait -WindowStyle Hidden
if ( Test-Path -Path "$INSTALLER_DIR\$installer_name" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( ! (Test-Path -Path "$PROJECT_DIR\build") ) {
New-Item -Path "$PROJECT_DIR\build" -ItemType Directory | Out-Null
}
if ( Test-Path -Path "$PROJECT_DIR\build\$installer_name" ) {
Write-Host "Backing up existing installer: " -NoNewline
$new_name = "$installer_name.$( Get-Date -UFormat %s ).bak"
Move-Item -Path "$PROJECT_DIR\build\$installer_name" `
-Destination "$PROJECT_DIR\build\$new_name"
if ( Test-Path -Path "$PROJECT_DIR\build\$new_name" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
Write-Host "Moving the Installer: " -NoNewline
Move-Item -Path "$INSTALLER_DIR\$installer_name" -Destination "$PROJECT_DIR\build"
if ( Test-Path -Path "$PROJECT_DIR\build\$installer_name" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Finished
#-------------------------------------------------------------------------------
Write-Host $("-" * 80)
Write-Host "Build NullSoft Installer for Salt Completed" `
-ForegroundColor Cyan
Write-Host $("=" * 80)
Write-Host "Installer can be found at the following location:"
Write-Host "$PROJECT_DIR\build\$installer_name"

View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\build_python.ps1" %*

View file

@ -0,0 +1,458 @@
<#
.SYNOPSIS
Script that builds Python from source
.DESCRIPTION
This script builds python from Source. It then creates the directory
structure as created by the Python installer in C:\Python##. This includes
all header files, scripts, dlls, library files, and pip.
.EXAMPLE
build_python.ps1 -Version 3.8.13
#>
param(
[Parameter(Mandatory=$false)]
[ValidatePattern("^\d{1,2}.\d{1,2}.\d{1,2}$")]
[ValidateSet(
#"3.10.5",
#"3.10.4",
#"3.10.3",
#"3.9.13",
#"3.9.12",
#"3.9.11",
"3.8.14",
"3.8.13",
"3.8.12",
"3.8.11",
"3.8.10"
)]
[Alias("v")]
# The version of Python to be built. Pythonnet only supports up to Python
# 3.8 for now. Pycurl stopped building wheel files after 7.43.0.5 which
# supported up to 3.8. So we're pinned to the latest version of Python 3.8.
# We may have to drop support for pycurl.
# Default is: 3.8.14
[String] $Version = "3.8.14",
[Parameter(Mandatory=$false)]
[ValidateSet("x86", "x64")]
[Alias("a")]
# The System Architecture to build. "x86" will build a 32-bit installer.
# "x64" will build a 64-bit installer. Default is: x64
$Architecture = "x64"
)
# Script Preferences
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Import Modules
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
Import-Module $SCRIPT_DIR\Modules\uac-module.psm1
#-------------------------------------------------------------------------------
# Check for Elevated Privileges
#-------------------------------------------------------------------------------
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$SCRIPT_DIR"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
#-------------------------------------------------------------------------------
# Start the Script
#-------------------------------------------------------------------------------
Write-Host $("=" * 80)
Write-Host "Build Python from Source" -ForegroundColor Cyan
Write-Host "- Python Version: $Version"
Write-Host "- Architecture: $Architecture"
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# Global Script Preferences
#-------------------------------------------------------------------------------
# The Python Build script doesn't disable the progress bar. This is a problem
# when trying to add this to CICD so we need to disable it system wide. This
# Adds $ProgressPreference=$false to the Default PowerShell profile so when the
# cpython build script is launched it will not display the progress bar. This
# file will be backed up if it already exists and will be restored at the end
# this script.
if ( Test-Path -Path "$profile" ) {
if ( ! (Test-Path -Path "$profile.salt_bak") ) {
Write-Host "Backing up PowerShell Profile: " -NoNewline
Move-Item -Path "$profile" -Destination "$profile.salt_bak"
if ( Test-Path -Path "$profile.salt_bak" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
}
$CREATED_POWERSHELL_PROFILE_DIRECTORY = $false
if ( ! (Test-Path -Path "$(Split-Path "$profile" -Parent)") ) {
Write-Host "Creating WindowsPowerShell Directory: " -NoNewline
New-Item -Path "$(Split-Path "$profile" -Parent)" -ItemType Directory | Out-Null
if ( Test-Path -Path "$(Split-Path "$profile" -Parent)" ) {
$CREATED_POWERSHELL_PROFILE_DIRECTORY = $true
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
Write-Host "Creating Temporary PowerShell Profile: " -NoNewline
'$ProgressPreference = "SilentlyContinue"' | Out-File -FilePath $profile
'$ErrorActionPreference = "Stop"' | Out-File -FilePath $profile
Write-Host "Success" -ForegroundColor Green
#-------------------------------------------------------------------------------
# Script Variables
#-------------------------------------------------------------------------------
# Script Variables
$PROJ_DIR = $(git rev-parse --show-toplevel)
# Python Variables
$PY_DOT_VERSION = $Version
$PY_VERSION = [String]::Join(".", $Version.Split(".")[0..1])
$PY_SRC_DIR = "$( (Get-Item $PROJ_DIR).Parent.FullName )\cpython"
$PY_REPO_URL = "https://github.com/python/cpython"
$PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
$PYTHON_DIR = "C:\Python$($PY_VERSION -replace "\.")"
$SCRIPTS_DIR = "$PYTHON_DIR\Scripts"
if ( $Architecture -eq "x64" ) {
$PY_BLD_DIR = "$PY_SRC_DIR\PCbuild\amd64"
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
} else {
$PY_BLD_DIR = "$PY_SRC_DIR\PCbuild\win32"
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/32"
}
#-------------------------------------------------------------------------------
# Prepping Environment
#-------------------------------------------------------------------------------
if ( Test-Path -Path "$PY_SRC_DIR" ) {
Write-Host "Removing existing cpython directory: " -NoNewline
Remove-Item -Path "$PY_SRC_DIR" -Recurse -Force
if ( Test-Path -Path "$PY_SRC_DIR" ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
} else {
Write-Host "Success" -ForegroundColor Green
}
}
if ( Test-Path -Path "$PYTHON_DIR" ) {
Write-Host "Removing Existing Build Directory ($PYTHON_DIR): " -NoNewline
Remove-Item -Path "$PYTHON_DIR" -Recurse -Force | Out-Null
if ( Test-Path -Path "$PYTHON_DIR" ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
} else {
Write-Host "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Building Python
#-------------------------------------------------------------------------------
Write-Host "Cloning Python ($PY_DOT_VERSION): " -NoNewline
$args = "clone", "--depth", "1", "--branch", "v$PY_DOT_VERSION", "$PY_REPO_URL", "$PY_SRC_DIR"
Start-Process -FilePath git `
-ArgumentList $args `
-Wait -WindowStyle Hidden
if ( Test-Path -Path "$PY_SRC_DIR\Python") {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Building Python (long-running): " -NoNewLine
# Visual Studio Leaves and MSbuild.exe process hanging around to optimize future
# builds. This causes the build to hang waiting for all processes to end. So, we
# need to disable Node Reuse so it closes the running MSBuild.exe process.
[System.Environment]::SetEnvironmentVariable("MSBUILDDISABLENODEREUSE", "1")
Start-Process -FilePath "$PY_SRC_DIR\PCbuild\build.bat" `
-ArgumentList "-p", "$Architecture", "--no-tkinter" `
-WindowStyle Hidden
# Sometimes the process doesn't return properly so the script can continue
# So, we'll run it asynchronously and check for the last file it builds
while ( ! (Test-Path -Path "$PY_BLD_DIR\pythonw.exe") ) {
Start-Sleep -Seconds 5
}
# Remove the environment variable after build
[System.Environment]::SetEnvironmentVariable("MSBUILDDISABLENODEREUSE", $null)
if ( Test-Path -Path "$PY_BLD_DIR\python.exe") {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Creating Python Directory Structure
#-------------------------------------------------------------------------------
Write-Host "Creating Build Directory ($PYTHON_DIR): " -NoNewline
New-Item -Path "$PYTHON_DIR" -ItemType Directory | Out-Null
if ( Test-Path -Path "$PYTHON_DIR" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Moving Python binaries: " -NoNewline
$binaries = @(
"py.exe",
"pyw.exe",
"python.exe",
"pythonw.exe",
"python3.dll",
"python38.dll",
"vcruntime140.dll",
"venvlauncher.exe",
"venvwlauncher.exe"
)
$binaries | ForEach-Object {
Move-Item -Path "$PY_BLD_DIR\$_" -Destination "$PYTHON_DIR" | Out-Null
if ( ! ( Test-Path -Path "$PYTHON_DIR\$_") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
Write-Host "Creating DLLs directory: " -NoNewline
New-Item -Path "$PYTHON_DIR\DLLs" -ItemType Directory | Out-Null
if ( Test-Path -Path "$PYTHON_DIR\DLLs" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Moving Python DLLS: " -NoNewline
Move-Item -Path "$PY_BLD_DIR\*.pyd" -Destination "$PYTHON_DIR\DLLs"
Move-Item -Path "$PY_BLD_DIR\*.dll" -Destination "$PYTHON_DIR\DLLs"
if ( ! (Test-Path -Path "$PYTHON_DIR\DLLs\select.pyd") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path "$PYTHON_DIR\DLLs\sqlite3.dll" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying Header Files: " -NoNewline
Copy-Item -Path "$PY_SRC_DIR\include" -Destination "$PYTHON_DIR\include" -Recurse | Out-Null
Copy-Item -Path "$PY_SRC_DIR\PC\pyconfig.h" -Destination "$PYTHON_DIR\include" -Recurse | Out-Null
if ( ! (Test-Path -Path "$PYTHON_DIR\include\abstract.h") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path "$PYTHON_DIR\include\pyconfig.h" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying Library Files: " -NoNewline
Copy-Item -Path "$PY_SRC_DIR\Lib" -Destination "$PYTHON_DIR\Lib" -Recurse | Out-Null
if ( Test-Path -Path "$PYTHON_DIR\Lib\abc.py" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Creating libs directory: " -NoNewline
New-Item -Path "$PYTHON_DIR\libs" -ItemType Directory | Out-Null
if ( Test-Path -Path "$PYTHON_DIR\libs" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying lib Files: " -NoNewline
Copy-Item -Path "$PY_BLD_DIR\python3.lib" -Destination "$PYTHON_DIR\libs" | Out-Null
Copy-Item -Path "$PY_BLD_DIR\python38.lib" -Destination "$PYTHON_DIR\libs" | Out-Null
if ( ! (Test-Path -Path "$PYTHON_DIR\libs\python3.lib") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path "$PYTHON_DIR\libs\python38.lib" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Retrieving SSL libaries: " -NoNewline
$libeay_url = "$SALT_DEP_URL/openssl/1.1.1k/libeay32.dll"
$ssleay_url = "$SALT_DEP_URL/openssl/1.1.1k/ssleay32.dll"
Invoke-WebRequest -Uri "$libeay_url" -OutFile "$PYTHON_DIR\libeay32.dll" | Out-Null
Invoke-WebRequest -Uri "$ssleay_url" -OutFile "$PYTHON_DIR\ssleay32.dll" | Out-Null
if ( ! (Test-Path -Path "$PYTHON_DIR\libeay32.dll") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path "$PYTHON_DIR\ssleay32.dll" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Installing PIP
#-------------------------------------------------------------------------------
Write-Host "Downloading pip: " -NoNewline
Invoke-WebRequest -Uri $PIP_URL -OutFile "$env:TEMP\get-pip.py" | Out-Null
if ( Test-Path -Path "$env:TEMP\get-pip.py" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Installing pip: " -NoNewline
Start-Process -FilePath "$PYTHON_DIR\python.exe" `
-ArgumentList "$env:TEMP\get-pip.py" `
-Wait -WindowStyle Hidden
if ( Test-Path -Path "$PYTHON_DIR\Scripts\pip.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Removing Unneeded files from Python
#-------------------------------------------------------------------------------
Write-Host "Removing Unneeded Files from Python: " -NoNewline
$remove = "idlelib",
"test",
"tkinter",
"turtledemo"
$remove | ForEach-Object {
Remove-Item -Path "$PYTHON_DIR\Lib\$_" -Recurse -Force
if ( Test-Path -Path "$PYTHON_DIR\Lib\$_" ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $PYTHON_DIR\Lib\$_"
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
#-------------------------------------------------------------------------------
# Updating PATH Environment Variable
#-------------------------------------------------------------------------------
Write-Host "Updating Path: " -NoNewLine
$Path = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ( ! ($Path.ToLower().Contains("$SCRIPTS_DIR".ToLower())) ) {
$env:Path = "$PYTHON_DIR;$SCRIPTS_DIR;$Path"
[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine")
}
$Path = [Environment]::GetEnvironmentVariable("Path", "Machine")
if ( ! ($Path.ToLower().Contains("$PYTHON_DIR".ToLower())) ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to add $PYTHON_DIR to path"
exit 1
}
if ( $Path.ToLower().Contains("$SCRIPTS_DIR".ToLower()) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to add $SCRIPTS_DIR to path"
exit 1
}
if ( $CREATED_POWERSHELL_PROFILE_DIRECTORY ) {
Write-Host "Removing PowerShell Profile Directory"
Remove-Item -Path "$(Split-Path "$profile" -Parent)" -Recurse -Force
if ( ! (Test-Path -Path "$(Split-Path "$profile" -Parent)") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failure" -ForegroundColor Red
exit 1
}
}
if ( Test-Path -Path "$profile" ) {
Write-Host "Removing Temporary PowerShell Profile: " -NoNewline
Remove-Item -Path "$profile" -Force
if ( ! (Test-Path -Path "$profile") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
if ( Test-Path -Path "$profile.salt_bak" ) {
Write-Host "Restoring Original PowerShell Profile: " -NoNewline
Move-Item -Path "$profile.salt_bak" -Destination "$profile"
if ( Test-Path -Path "$profile" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Adding Registry Key for Python Launcher
#-------------------------------------------------------------------------------
Write-Host "Writing Python Launcher Registry Entries: " -NoNewline
$PL_REG = "HKLM:\SOFTWARE\Python\PythonCore\$PY_VERSION\InstallPath"
New-Item -Path $PL_REG -Value $PYTHON_DIR -Force | Out-Null
if ( Test-Path -Path $PL_REG ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Finished
#-------------------------------------------------------------------------------
Write-Host $("-" * 80)
Write-Host "Build Python $Architecture from Source Completed" `
-ForegroundColor Cyan
Write-Host "Environment Location: $PYTHON_DIR"
Write-Host $("=" * 80)

View file

@ -1,171 +0,0 @@
echo off
echo =====================================================================
echo Salt Windows Clean Script
echo =====================================================================
echo.
rem Make sure the script is run as Admin
echo Administrative permissions required. Detecting permissions ...
echo ---------------------------------------------------------------------
net session >nul 2>&1
if %errorLevel%==0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: This script must be run as Administrator
goto eof
)
echo.
:CheckPython27
if exist "\Python27" goto RemovePython27
goto CheckPython35
:RemovePython27
rem Uninstall Python 2.7
echo %0 :: Uninstalling Python 2 ...
echo ---------------------------------------------------------------------
echo %0 :: - 2.7.12 (32 bit)
MsiExec.exe /X {9DA28CE5-0AA5-429E-86D8-686ED898C665} /QN
echo %0 :: - 2.7.12 (64 bit)
MsiExec.exe /X {9DA28CE5-0AA5-429E-86D8-686ED898C666} /QN
echo %0 :: - 2.7.13 (32 bit)
MsiExec.exe /X {4A656C6C-D24A-473F-9747-3A8D00907A03} /QN
echo %0 :: - 2.7.13 (64 bit)
MsiExec.exe /X {4A656C6C-D24A-473F-9747-3A8D00907A04} /QN
echo %0 :: - 2.7.14 (32 bit)
MsiExec.exe /X {0398A685-FD8D-46B3-9816-C47319B0CF5E} /QN
echo %0 :: - 2.7.14 (64 bit)
MsiExec.exe /X {0398A685-FD8D-46B3-9816-C47319B0CF5F} /QN
echo %0 :: - 2.7.15 (32 bit)
MsiExec.exe /X {16CD92A4-0152-4CB7-8FD6-9788D3363616} /QN
echo %0 :: - 2.7.15 (64 bit)
MsiExec.exe /X {16CD92A4-0152-4CB7-8FD6-9788D3363617} /QN
echo.
rem Wipe the Python directory
echo %0 :: Removing the C:\Python27 Directory ...
echo ---------------------------------------------------------------------
rd /s /q C:\Python27
if %errorLevel%==0 (
echo Successful
) else (
echo Failed, please remove manually
)
:CheckPython35
if exist "\Python35" goto RemovePython35
goto CheckPython37
:RemovePython35
echo %0 :: Uninstalling Python 3 ...
echo ---------------------------------------------------------------------
:: 64 bit
if exist "%LOCALAPPDATA%\Package Cache\{b94f45d6-8461-440c-aa4d-bf197b2c2499}" (
echo %0 :: - 3.5.3 64bit
"%LOCALAPPDATA%\Package Cache\{b94f45d6-8461-440c-aa4d-bf197b2c2499}\python-3.5.3-amd64.exe" /uninstall /quiet
)
if exist "%LOCALAPPDATA%\Package Cache\{5d57524f-af24-49a7-b90b-92138880481e}" (
echo %0 :: - 3.5.4 64bit
"%LOCALAPPDATA%\Package Cache\{5d57524f-af24-49a7-b90b-92138880481e}\python-3.5.4-amd64.exe" /uninstall /quiet
)
:: 32 bit
if exist "%LOCALAPPDATA%\Package Cache\{a10037e1-4247-47c9-935b-c5ca049d0299}" (
echo %0 :: - 3.5.3 32bit
"%LOCALAPPDATA%\Package Cache\{a10037e1-4247-47c9-935b-c5ca049d0299}\python-3.5.3" /uninstall /quiet
)
if exist "%LOCALAPPDATA%\Package Cache\{06e841fa-ca3b-4886-a820-cd32c614b0c1}" (
echo %0 :: - 3.5.4 32bit
"%LOCALAPPDATA%\Package Cache\{06e841fa-ca3b-4886-a820-cd32c614b0c1}\python-3.5.4" /uninstall /quiet
)
rem wipe the Python directory
echo %0 :: Removing the C:\Python35 Directory ...
echo ---------------------------------------------------------------------
rd /s /q "C:\Python35"
if %errorLevel%==0 (
echo Successful
) else (
echo Failed, please remove manually
)
goto eof
:CheckPython37
if exist "\Python37" goto RemovePython37
goto CheckPython38
:RemovePython37
echo %0 :: Uninstalling Python 3.7 ...
echo ---------------------------------------------------------------------
:: 64 bit
if exist "%LOCALAPPDATA%\Package Cache\{8ae589dd-de2e-42cd-af56-102374115fee}" (
echo %0 :: - 3.7.4 64bit
"%LOCALAPPDATA%\Package Cache\{8ae589dd-de2e-42cd-af56-102374115fee}\python-3.7.4-amd64.exe" /uninstall /quiet
)
:: 32 bit
if exist "%LOCALAPPDATA%\Package Cache\{b66087e3-469e-4725-8b9b-f0981244afea}" (
echo %0 :: - 3.7.4 32bit
"%LOCALAPPDATA%\Package Cache\{b66087e3-469e-4725-8b9b-f0981244afea}\python-3.7.4" /uninstall /quiet
)
:: Python Launcher, seems to be the same for 32 and 64 bit
echo %0 :: - Python Launcher
msiexec.exe /x {D722DA3A-92F5-454A-BD5D-A48C94D82300} /quiet /qn
rem wipe the Python directory
echo %0 :: Removing the C:\Python37 Directory ...
echo ---------------------------------------------------------------------
rd /s /q "C:\Python37"
if %errorLevel%==0 (
echo Successful
) else (
echo Failed, please remove manually
)
goto eof
:CheckPython38
if exist "\Python38" goto RemovePython38
goto eof
:RemovePython38
echo %0 :: Uninstalling Python 3.8 ...
echo ---------------------------------------------------------------------
:: 64 bit
if exist "%LOCALAPPDATA%\Package Cache\{ef6306ce-2a12-4d59-887e-ebf00b9e4ab5}" (
echo %0 :: - 3.8.8 64bit
"%LOCALAPPDATA%\Package Cache\{ef6306ce-2a12-4d59-887e-ebf00b9e4ab5}\python-3.8.8-amd64.exe" /uninstall /quiet
)
:: 32 bit
if exist "%LOCALAPPDATA%\Package Cache\{ac93da86-1536-4b03-aea1-dc354b5e9282}" (
echo %0 :: - 3.8.8 32bit
"%LOCALAPPDATA%\Package Cache\{ac93da86-1536-4b03-aea1-dc354b5e9282}\python-3.8.8" /uninstall /quiet
)
:: Python Launcher, seems to be the same for 32 and 64 bit
echo %0 :: - Python Launcher
msiexec.exe /x {3B53E5B7-CFC4-401C-80E9-FF7591C58741} /quiet /qn
rem wipe the Python directory
echo %0 :: Removing the C:\Python38 Directory ...
echo ---------------------------------------------------------------------
rd /s /q "C:\Python38"
if %errorLevel%==0 (
echo Successful
) else (
echo Failed, please remove manually
)
goto eof
:eof
echo.
echo =====================================================================
echo End of %0
echo =====================================================================

View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\clean_env.ps1" %*

201
pkg/windows/clean_env.ps1 Normal file
View file

@ -0,0 +1,201 @@
<#
.SYNOPSIS
Script that cleans the build environment
.DESCRIPTION
This script uninstalls all versions of Python on the System. It also removes
Python from the system path. Additional, it removes the Python Launcher.
.EXAMPLE
clean_env.ps1
#>
# Script Preferences
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Import Modules
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
Import-Module $SCRIPT_DIR\Modules\uac-module.psm1
#-------------------------------------------------------------------------------
# Check for Elevated Privileges
#-------------------------------------------------------------------------------
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$SCRIPT_DIR"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
Write-Host $("=" * 80)
Write-Host "Cleaning Build Environment" -ForegroundColor Cyan
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# Remove all Python 2 Installations
#-------------------------------------------------------------------------------
$packages = Get-Package | where { $_.Name -match "^Python 2.*$" }
$packages | ForEach-Object {
$pkg_name = $_.Name
Write-Host "Uninstalling $($pkg_name): " -NoNewline
Start-Process -FilePath MsiExec.exe `
-ArgumentList "/X", "$( $_.FastPackageReference )", "/QN" `
-Wait -WindowStyle Hidden
$test = Get-Package | where { $_.Name -eq $pkg_name }
if ( $test.Count -eq 0 ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Remove all Python 3 Installations
#-------------------------------------------------------------------------------
$packages = Get-Package | where {($_.Name -match "^Python 3.*$") -and ($_.ProviderName -eq "Programs") }
$packages | ForEach-Object {
$pkg_name = $_.Name
Write-Host "Uninstalling $($pkg_name): " -NoNewline
$null, $uninstaller, $arguments = $_.Metadata["QuietUninstallString"] -Split('"')
$arguments = $arguments.Trim().Split()
Start-Process -FilePath $uninstaller `
-ArgumentList $arguments `
-Wait
$test = Get-Package | where { $_.Name -eq $pkg_name }
if ( $test.Count -eq 0 ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Remove Python Launcher
#-------------------------------------------------------------------------------
$packages = Get-Package | where { $_.Name -match "^Python Launcher$" }
$packages | ForEach-Object {
$pkg_name = $_.Name
Write-Host "Uninstalling $($pkg_name): " -NoNewline
Start-Process -FilePath MsiExec.exe `
-ArgumentList "/X", "$( $_.FastPackageReference )", "/QN" `
-Wait -WindowStyle Hidden
$test = Get-Package | where { $_.Name -eq $pkg_name }
if ( $test.Count -eq 0 ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Remove all Python Directories
#-------------------------------------------------------------------------------
$paths = "$env:SystemDrive\Python27",
"$env:SystemDrive\Python36",
"$env:SystemDrive\Python37",
"$env:SystemDrive\Python38",
"$env:SystemDrive\Python39",
"$env:SystemDrive\Python310"
$paths | ForEach-Object {
if ( Test-Path -Path $_ ) {
Write-Host "Removing $($_): " -NoNewline
Remove-Item -Path $_ -Recurse -Force
if ( ! (Test-Path -Path "$_") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
}
#-------------------------------------------------------------------------------
# Clean Path Environment Variable
#-------------------------------------------------------------------------------
$system_paths = [Environment]::GetEnvironmentVariable("PATH", "Machine").Split(";")
$new_path = [System.Collections.ArrayList]::New()
$found_in_path = $false
$paths | ForEach-Object {
if ( $_ -in $system_paths ) {
$found_in_path = $true
}
}
if ( $found_in_path ) {
Write-Host "Removing Python from PATH: " -NoNewline
$system_paths | ForEach-Object {
$found = $false
if ($_ -match "^[A-Z]:\\Python\d{2,3}.*") {
$found = $true
}
if (!$found) {
$new_path.Add($_) | Out-Null
}
}
if ( ! [String]::IsNullOrEmpty($new_path) ) {
[Environment]::SetEnvironmentVariable("PATH", $new_path -join ";", [EnvironmentVariableTarget]::Machine)
$env:PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine")
}
$found_in_path = $false
$paths | ForEach-Object {
if ( $_ -in $env:PATH ) {
$found_in_path = $true
}
}
if ( ! $found_in_path ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Remove Python Launcher Registry Keys
#-------------------------------------------------------------------------------
if ( Test-Path -Path HKLM:\SOFTWARE\Python ) {
Write-Host "Removing Python Launcher Registry Keys: " -NoNewline
Remove-Item -Path HKLM:\SOFTWARE\Python -Recurse -Force
if ( ! (Test-Path -Path HKLM:\SOFTWARE\Python) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Done
#-------------------------------------------------------------------------------
Write-Host $("-" * 80)
Write-Host "Cleaning Build Environment Complete" -ForegroundColor Cyan
Write-Host $("=" * 80)

View file

@ -1,13 +0,0 @@
#
# ps1 wrapper for psm1
#
#
Param(
[Parameter(Mandatory=$true)][string]$url,
[Parameter(Mandatory=$true)][string]$file
)
Import-Module ./Modules/download-module.psm1
DownloadFileWithProgress $url $file

View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\install_nsis.ps1" %*

View file

@ -0,0 +1,369 @@
<#
.SYNOPSIS
Script that installs NullSoft Installer
.DESCRIPTION
This script installs the NullSoft installer and all Plugins and Libraries
required to build the Salt installer
.EXAMPLE
install_nsis.ps1
#>
# Script Preferences
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Import Modules
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
Import-Module $SCRIPT_DIR\Modules\uac-module.psm1
Import-Module $SCRIPT_DIR\Modules\zip-module.psm1
#-------------------------------------------------------------------------------
# Check for Elevated Privileges
#-------------------------------------------------------------------------------
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$SCRIPT_DIR"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
#-------------------------------------------------------------------------------
# Script Variables
#-------------------------------------------------------------------------------
$NSIS_DIR = "${env:ProgramFiles(x86)}\NSIS"
$NSIS_PLUG_A = "$NSIS_DIR\Plugins\x86-ansi"
$NSIS_PLUG_U = "$NSIS_DIR\Plugins\x86-unicode"
$NSIS_LIB_DIR = "$NSIS_DIR\Include"
$DEPS_URL = "https://repo.saltproject.io/windows/dependencies"
#-------------------------------------------------------------------------------
# Start the Script
#-------------------------------------------------------------------------------
Write-Host $("=" * 80)
Write-Host "Install NullSoft Installer Software and Plugins" -ForegroundColor Cyan
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# NSIS
#-------------------------------------------------------------------------------
Write-Host "Looking for NSIS: " -NoNewline
$check_file = "$NSIS_DIR\NSIS.exe"
if ( Test-Path -Path "$check_file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Downloading NSIS: " -NoNewline
$url = "$DEPS_URL/nsis-3.03-setup.exe"
$file = "$env:TEMP\install_nsis.exe"
Invoke-WebRequest -Uri $url -OutFile "$file"
if ( Test-Path -Path "$file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Installing NSIS: " -NoNewline
Start-Process $file -ArgumentList "/S" -Wait -NoNewWindow
if ( Test-Path -Path "$check_file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Cleaning up: " -NoNewline
Remove-Item -Path $file -Force
if ( ! (Test-Path -Path "$file") ) {
Write-Host "Success" -ForegroundColor Green
} else {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
}
}
#-------------------------------------------------------------------------------
# NSIS NxS Unzip Plugin
#-------------------------------------------------------------------------------
Write-Host "Looking for NSIS NxS Unzip (ansi) Plugin: " -NoNewline
$check_file = "$NSIS_PLUG_A\nsisunz.dll"
if ( Test-Path -Path $check_file ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Downloading NSIS NxS Unzip (ansi) Plugin: " -NoNewline
$url = "$DEPS_URL/nsis-plugin-nsisunz.zip"
$file = "$env:TEMP\nsizunz.zip"
Invoke-WebRequest -Uri $url -OutFile "$file"
if ( Test-Path -Path "$file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Extracting NSIS NxS Unzip (ansi) Plugin: " -NoNewline
Expand-Archive -Path "$file" -DestinationPath "$env:TEMP"
if ( Test-Path -Path "$env:TEMP\nsisunz\Release\nsisunz.dll") {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Moving DLL to plugins directory: " -NoNewline
Move-Item -Path "$env:TEMP\nsisunz\Release\nsisunz.dll" -Destination "$check_file" -Force
if ( Test-Path -Path $check_file ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Cleaning up: " -NoNewline
Remove-Item -Path $file -Force
Remove-Item -Path "$env:TEMP\nsisunz" -Force -Recurse | Out-Null
if ( Test-Path -Path "$file" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
}
if ( Test-Path -Path "$env:TEMP\nsisunz" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
} else {
Write-Host "Success" -ForegroundColor Green
}
}
Write-Host "Looking for NSIS NxS Unzip (unicode) Plugin: " -NoNewline
$check_file = "$NSIS_PLUG_U\nsisunz.dll"
if ( Test-Path -Path $check_file ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Downloading NSIS NxS Unzip (unicode) Plugin: " -NoNewline
$url = "$DEPS_URL/nsis-plugin-nsisunzu.zip"
$file = "$env:TEMP\nsisunzu.zip"
Invoke-WebRequest -Uri $url -OutFile "$file"
if ( Test-Path -Path "$file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Extracting NSIS NxS Unzip (unicode) Plugin: " -NoNewline
Expand-Archive -Path "$file" -DestinationPath "$env:TEMP"
if ( Test-Path -Path "$env:TEMP\NSISunzU\Plugin unicode\nsisunz.dll") {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Moving DLL to plugins directory: " -NoNewline
Move-Item -Path "$env:TEMP\NSISunzU\Plugin unicode\nsisunz.dll" -Destination "$check_file" -Force
if ( Test-Path -Path $check_file ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Cleaning up: " -NoNewline
Remove-Item -Path $file -Force
Remove-Item -Path "$env:TEMP\NSISunzU" -Force -Recurse | Out-Null
if ( Test-Path -Path "$file" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
}
if ( Test-Path -Path "$env:TEMP\NSISunzU" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
} else {
Write-Host "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# NSIS EnVar Plugin
#-------------------------------------------------------------------------------
Write-Host "Looking for NSIS EnVar Plugin: " -NoNewline
$check_file_a = "$NSIS_PLUG_A\EnVar.dll"
$check_file_u = "$NSIS_PLUG_U\EnVar.dll"
if ( (Test-Path -Path $check_file_a) -and (Test-Path -Path $check_file_u) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Downloading NSIS EnVar Plugin: " -NoNewline
$url = "$DEPS_URL/nsis-plugin-envar.zip"
$file = "$env:TEMP\nsisenvar.zip"
Invoke-WebRequest -Uri $url -OutFile "$file"
if ( Test-Path -Path "$file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Extracting NSIS EnVar Plugin: " -NoNewline
Expand-Archive -Path "$file" -DestinationPath "$env:TEMP\nsisenvar\"
if ( ! (Test-Path -Path "$env:TEMP\nsisenvar\Plugins\x86-ansi\EnVar.dll") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path "$env:TEMP\nsisenvar\Plugins\x86-unicode\EnVar.dll" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Moving DLLs to plugins directory: " -NoNewline
Move-Item -Path "$env:TEMP\nsisenvar\Plugins\x86-ansi\EnVar.dll" -Destination "$check_file_a" -Force
Move-Item -Path "$env:TEMP\nsisenvar\Plugins\x86-unicode\EnVar.dll" -Destination "$check_file_u" -Force
if ( ! (Test-Path -Path $check_file_a) ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path $check_file_u ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Cleaning up: " -NoNewline
Remove-Item -Path $file -Force
Remove-Item -Path "$env:TEMP\nsisenvar" -Force -Recurse | Out-Null
if ( Test-Path -Path "$file" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
}
if ( Test-Path -Path "$env:TEMP\NSISunzU" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
} else {
Write-Host "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# NSIS AccessControl Plugin
#-------------------------------------------------------------------------------
Write-Host "Looking for NSIS AccessControl Plugin: " -NoNewline
$check_file_a = "$NSIS_PLUG_A\AccessControl.dll"
$check_file_u = "$NSIS_PLUG_U\AccessControl.dll"
if ( (Test-Path -Path $check_file_a) -and (Test-Path -Path $check_file_u) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Downloading NSIS AccessControl Plugin: " -NoNewline
$url = "$DEPS_URL/nsis-plugin-accesscontrol.zip"
$file = "$env:TEMP\nsisaccesscontrol.zip"
Invoke-WebRequest -Uri $url -OutFile "$file"
if ( Test-Path -Path "$file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Extracting NSIS EnVar Plugin: " -NoNewline
Expand-Archive -Path "$file" -DestinationPath "$env:TEMP\nsisaccesscontrol\"
if ( ! (Test-Path -Path "$env:TEMP\nsisaccesscontrol\Plugins\i386-ansi\AccessControl.dll") ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path "$env:TEMP\nsisaccesscontrol\Plugins\i386-unicode\AccessControl.dll" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Moving DLLs to plugins directory: " -NoNewline
Move-Item -Path "$env:TEMP\nsisaccesscontrol\Plugins\i386-ansi\AccessControl.dll" -Destination "$check_file_a" -Force
Move-Item -Path "$env:TEMP\nsisaccesscontrol\Plugins\i386-unicode\AccessControl.dll" -Destination "$check_file_u" -Force
if ( ! (Test-Path -Path $check_file_a) ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( Test-Path -Path $check_file_u ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Cleaning up: " -NoNewline
Remove-Item -Path $file -Force
Remove-Item -Path "$env:TEMP\nsisaccesscontrol" -Force -Recurse | Out-Null
if ( Test-Path -Path "$file" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
}
if ( Test-Path -Path "$env:TEMP\nsisaccesscontrol" ) {
# Not a hard fail
Write-Host "Failed" -ForegroundColor Yellow
} else {
Write-Host "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# NSIS MoveFileFolder Library
#-------------------------------------------------------------------------------
Write-Host "Looking for NSIS MoveFileFolder Library: " -NoNewline
$check_file = "$NSIS_LIB_DIR\MoveFileFolder.nsh"
if ( Test-Path -Path $check_file ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Installing NSIS MoveFileFolder Library: " -NoNewline
$url = "$DEPS_URL/nsis-MoveFileFolder.nsh"
$file = "$check_file"
Invoke-WebRequest -Uri $url -OutFile "$file"
if ( Test-Path -Path "$file" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
Write-Host $("-" * 80)
Write-Host "Install NullSoft Installer Software and Plugins Completed" `
-ForegroundColor Cyan
Write-Host $("=" * 80)

View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\install_salt.ps1" %*

View file

@ -0,0 +1,272 @@
<#
.SYNOPSIS
Script that installs Salt in the Python environment
.DESCRIPTION
This script installs Salt into the Python environment built by the
build_python.ps1 script. It puts required dlls in the Python directory
and removes items not needed by a Salt installation on Windows such as Python
docs and test files. Once this script completes, the Python directory is
ready to be packaged.
.EXAMPLE
install_salt.ps1
#>
param(
[Parameter(Mandatory=$false)]
[ValidateSet("x86", "x64")]
[Alias("a")]
# The System Architecture to build. "x86" will build a 32-bit installer.
# "x64" will build a 64-bit installer. Default is: x64
$Architecture = "x64"
)
# Script Preferences
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Import Modules
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
Import-Module $SCRIPT_DIR\Modules\uac-module.psm1
#-------------------------------------------------------------------------------
# Check for Elevated Privileges
#-------------------------------------------------------------------------------
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$SCRIPT_DIR"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
#-------------------------------------------------------------------------------
# Define Variables
#-------------------------------------------------------------------------------
# Python Variables
$PY_VERSION = "3.8"
$PYTHON_DIR = "C:\Python$($PY_VERSION -replace "\.")"
$PYTHON_BIN = "$PYTHON_DIR\python.exe"
$SCRIPTS_DIR = "$PYTHON_DIR\Scripts"
$SITE_PKGS_DIR = "$PYTHON_DIR\Lib\site-packages"
# Script Variables
$PROJECT_DIR = $(git rev-parse --show-toplevel)
$SALT_REPO_URL = "https://github.com/saltstack/salt"
$SALT_SRC_DIR = "$( (Get-Item $PROJECT_DIR).Parent.FullName )\salt"
$SALT_DEPS = "$SALT_SRC_DIR\requirements\static\pkg\py$PY_VERSION\windows.txt"
if ( $Architecture -eq "x64" ) {
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
} else {
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/32"
}
#-------------------------------------------------------------------------------
# Start the Script
#-------------------------------------------------------------------------------
Write-Host $("=" * 80)
Write-Host "Install Salt into Python Environment" -ForegroundColor Cyan
Write-Host "- Architecture: $Architecture"
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# Installing Salt
#-------------------------------------------------------------------------------
# We don't want to use an existing salt installation because we don't know what
# it is
Write-Host "Checking for existing Salt installation: " -NoNewline
if ( ! (Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Cleaning Salt Build Environment: " -NoNewline
$remove = "build", "dist"
$remove | ForEach-Object {
if ( Test-Path -Path "$SALT_SRC_DIR\$_" ) {
Remove-Item -Path "$SALT_SRC_DIR\$_" -Recurse -Force
if ( Test-Path -Path "$SALT_SRC_DIR\$_" ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to remove $_"
exit 1
}
}
}
Write-Host "Success" -ForegroundColor Green
Write-Host "Installing Salt: " -NoNewline
Start-Process -FilePath $SCRIPTS_DIR\pip.exe `
-ArgumentList "install", "." `
-WorkingDirectory "$SALT_SRC_DIR" `
-Wait -WindowStyle Hidden
if ( Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Copying Scripts: " -NoNewline
$salt_binaries = Get-ChildItem -Path $SCRIPTS_DIR -Filter "salt*.exe"
$salt_binaries | ForEach-Object {
Copy-Item -Path "$SALT_SRC_DIR\scripts\$($_.BaseName)" `
-Destination "$SCRIPTS_DIR" -Force
}
$salt_files = Get-ChildItem -Path $SCRIPTS_DIR -Filter "salt*"
if ( $salt_files.Count -eq ($salt_binaries.Count * 2) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
}
#-------------------------------------------------------------------------------
# Installing Libsodium DLL
#-------------------------------------------------------------------------------
Write-Host "Installing Libsodium DLL: " -NoNewline
$libsodium_url = "$SALT_DEP_URL/libsodium/1.0.18/libsodium.dll"
Invoke-WebRequest -Uri $libsodium_url -OutFile "$PYTHON_DIR\libsodium.dll"
if ( Test-Path -Path "$PYTHON_DIR\libsodium.dll" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Cleaning Up Installation
#-------------------------------------------------------------------------------
# Remove doc
if ( Test-Path -Path "$PYTHON_DIR\doc" ) {
Write-Host "Removing doc directory: " -NoNewline
Remove-Item "$PYTHON_DIR\doc" -Recurse -Force
if ( ! (Test-Path -Path "$PYTHON_DIR\doc") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
# Remove share
if ( Test-Path -Path "$PYTHON_DIR\share" ) {
Write-Host "Removing share directory: " -NoNewline
Remove-Item "$PYTHON_DIR\share" -Recurse -Force
if ( ! (Test-Path -Path "$PYTHON_DIR\share") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
# Remove WMI Test Scripts
Write-Host "Removing wmitest scripts: " -NoNewline
Remove-Item -Path "$SCRIPTS_DIR\wmitest*" -Force | Out-Null
if ( ! (Test-Path -Path "$SCRIPTS_DIR\wmitest*") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
# Remove Non-Minion Components
# TODO: These should probably be removed from Setup.py so they
# TODO: are not created in the first place
Write-Host "Removing Non-Minion Components: " -NoNewline
$remove = "salt-key",
"salt-run",
"salt-syndic",
"salt-unity"
$remove | ForEach-Object {
Remove-Item -Path "$SCRIPTS_DIR\$_*" -Recurse
if ( Test-Path -Path "$SCRIPTS_DIR\$_*" ) {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Failed to remove: $SCRIPTS_DIR\$_"
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
#-------------------------------------------------------------------------------
# Cleaning PyWin32 Installation
#-------------------------------------------------------------------------------
# Move DLL's to Python Root
# The dlls have to be in Python directory and the site-packages\win32 directory
Write-Host "Placing PyWin32 DLLs: " -NoNewline
Copy-Item "$SITE_PKGS_DIR\pywin32_system32\*.dll" "$PYTHON_DIR" -Force | Out-Null
Move-Item "$SITE_PKGS_DIR\pywin32_system32\*.dll" "$SITE_PKGS_DIR\win32" -Force | Out-Null
if ( ! ((Test-Path -Path "$PYTHON_DIR\pythoncom38.dll") -and (Test-Path -Path "$PYTHON_DIR\pythoncom38.dll")) ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
if ( (Test-Path -Path "$SITE_PKGS_DIR\win32\pythoncom38.dll") -and (Test-Path -Path "$SITE_PKGS_DIR\win32\pythoncom38.dll") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
# Create gen_py directory
Write-Host "Creating gen_py directory: " -NoNewline
New-Item -Path "$SITE_PKGS_DIR\win32com\gen_py" -ItemType Directory -Force | Out-Null
if ( Test-Path -Path "$SITE_PKGS_DIR\win32com\gen_py" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
# Remove pywin32_system32 directory
Write-Host "Removing pywin32_system32 directory: " -NoNewline
Remove-Item -Path "$SITE_PKGS_DIR\pywin32_system32" | Out-Null
if ( ! (Test-Path -Path "$SITE_PKGS_DIR\pywin32_system32") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
# Remove PyWin32 PostInstall & testall scripts
Write-Host "Removing pywin32 scripts: " -NoNewline
Remove-Item -Path "$SCRIPTS_DIR\pywin32_*" -Force | Out-Null
if ( ! (Test-Path -Path "$SCRIPTS_DIR\pywin32_*") ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Finished
#-------------------------------------------------------------------------------
Write-Host $("-" * 80)
Write-Host "Install Salt into Python Environment Complete" `
-ForegroundColor Cyan
Write-Host $("=" * 80)

View file

@ -0,0 +1,3 @@
@ echo off
Set "CurDir=%~dp0"
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\install_vs_buildtools.ps1" %*

View file

@ -0,0 +1,184 @@
<#
.SYNOPSIS
Script that installs Visual Studio Build Tools
.DESCRIPTION
This script installs the Visual Studio Build Tools if they are not already
present on the system. Visual Studio Build Tools are the binaries and libraries
needed to build Python from source.
.EXAMPLE
install_vc_buildtools.ps1
#>
# Script Preferences
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Import Modules
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
Import-Module $SCRIPT_DIR\Modules\uac-module.psm1
#-------------------------------------------------------------------------------
# Check for Elevated Privileges
#-------------------------------------------------------------------------------
If (!(Get-IsAdministrator)) {
If (Get-IsUacEnabled) {
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition
# Specify the current working directory
$newProcess.WorkingDirectory = "$SCRIPT_DIR"
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess);
# Exit from the current, unelevated, process
Exit
} Else {
Throw "You must be administrator to run this script"
}
}
#-------------------------------------------------------------------------------
# Start the Script
#-------------------------------------------------------------------------------
Write-Host $("=" * 80)
Write-Host "Install Visual Studio Build Tools" -ForegroundColor Cyan
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# Script Variables
#-------------------------------------------------------------------------------
# Dependency Variables
$VS_BLD_TOOLS = "https://aka.ms/vs/15/release/vs_buildtools.exe"
$VS_CL_BIN = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\VC\bin\cl.exe"
$MSBUILD_BIN = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe"
$WIN10_SDK_RC = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.17763.0\x64\rc.exe"
#-------------------------------------------------------------------------------
# Visual Studio
#-------------------------------------------------------------------------------
$install_build_tools = $false
Write-Host "Confirming Presence of Visual Studio Build Tools: " -NoNewline
@($VS_CL_BIN, $MSBUILD_BIN, $WIN10_SDK_RC) | ForEach-Object {
if ( ! (Test-Path -Path $_) ) {
$install_build_tools = $true
}
}
if ( $install_build_tools ) {
Write-Host "Missing" -ForegroundColor Yellow
Write-Host "Checking available disk space: " -NoNewLine
$available = (Get-PSDrive $env:SystemDrive.Trim(":")).Free
if ( $available -gt (1024 * 1024 * 1024 * 9.1) ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
Write-Host "Not enough disk space"
exit 1
}
Write-Host "Downloading Visual Studio 2017 build tools: " -NoNewline
Invoke-WebRequest -Uri "$VS_BLD_TOOLS" -OutFile "$env:TEMP\vs_buildtools.exe"
if ( Test-Path -Path "$env:TEMP\vs_buildtools.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
Write-Host "Creating Layout for Visual Studio 2017 build tools: " -NoNewline
if ( ! (Test-Path -Path "$($env:TEMP)\build_tools") ) {
New-Item -Path "$($env:TEMP)\build_tools" -ItemType Directory | Out-Null
}
Start-Process -FilePath "$env:TEMP\vs_buildtools.exe" `
-ArgumentList "--layout `"$env:TEMP\build_tools`"", `
"--add Microsoft.VisualStudio.Workload.MSBuildTools", `
"--add Microsoft.VisualStudio.Workload.VCTools", `
"--add Microsoft.VisualStudio.Component.Windows81SDK", `
"--add Microsoft.VisualStudio.Component.Windows10SDK.17763", `
"--add Microsoft.VisualStudio.Component.VC.140", `
"--add Microsoft.Component.VC.Runtime.UCRTSDK", `
"--lang en-US", `
"--includeRecommended", `
"--quiet", `
"--wait" `
-Wait -WindowStyle Hidden
if ( Test-Path -Path "$env:TEMP\build_tools\vs_buildtools.exe" ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
# Serial: 28cc3a25bfba44ac449a9b586b4339a
# Hash: 3b1efd3a66ea28b16697394703a72ca340a05bd5
if (! (Test-Path -Path Cert:\LocalMachine\Root\3b1efd3a66ea28b16697394703a72ca340a05bd5) ) {
Write-Host "Installing Certificate Sign Root Certificate: " -NoNewLine
Start-Process -FilePath "certutil" `
-ArgumentList "-addstore", `
"Root", `
"$($env:TEMP)\build_tools\certificates\manifestCounterSignRootCertificate.cer" `
-Wait -WindowStyle Hidden
if ( Test-Path -Path Cert:\LocalMachine\Root\3b1efd3a66ea28b16697394703a72ca340a05bd5 ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Yellow
}
}
# Serial: 3f8bc8b5fc9fb29643b569d66c42e144
# Hash: 8f43288ad272f3103b6fb1428485ea3014c0bcfe
if (! (Test-Path -Path Cert:\LocalMachine\Root\8f43288ad272f3103b6fb1428485ea3014c0bcfe) ) {
Write-Host "Installing Certificate Root Certificate: " -NoNewLine
Start-Process -FilePath "certutil" `
-ArgumentList "-addstore", `
"Root", `
"$($env:TEMP)\build_tools\certificates\manifestRootCertificate.cer" `
-Wait -WindowStyle Hidden
if ( Test-Path -Path Cert:\LocalMachine\Root\8f43288ad272f3103b6fb1428485ea3014c0bcfe ) {
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Failed" -ForegroundColor Yellow
}
}
Write-Host "Installing Visual Studio 2017 build tools: " -NoNewline
Start-Process -FilePath "$env:TEMP\build_tools\vs_setup.exe" `
-ArgumentList "--wait", "--noweb", "--quiet" `
-Wait
@($VS_CL_BIN, $MSBUILD_BIN, $WIN10_SDK_RC) | ForEach-Object {
if ( ! (Test-Path -Path $_) ) {
Write-Host "Failed" -ForegroundColor Red
exit 1
}
}
Write-Host "Success" -ForegroundColor Green
} else {
Write-Host "Success" -ForegroundColor Green
}
#-------------------------------------------------------------------------------
# Finished
#-------------------------------------------------------------------------------
Write-Host $("-" * 80)
Write-Host "Install Visual Studio Build Tools Completed" -ForegroundColor Cyan
Write-Host $("=" * 80)

View file

@ -1,6 +1,6 @@
Salt - Remote execution system
Copyright 2011 Thomas S Hatch
Copyright 2021 Salt Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -13,4 +13,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,90 +0,0 @@
=============
What is Salt?
=============
.. image:: https://secure.travis-ci.org/saltstack/salt.png?branch=develop
:target: http://travis-ci.org/saltstack/salt
.. rubric:: Were not just talking about NaCl.
Distributed Remote Execution
============================
Salt is a distributed remote execution system used to execute commands and
query data. It was developed in order to bring the best solutions found in the
world of remote execution together and make them better, faster and more
malleable. Salt accomplishes this via its ability to handle larger loads of
information, and not just dozens, but hundreds, or even thousands of individual
servers. It handles them quickly and through a simple yet manageable interface.
Simplicity
==========
Versatility between massive scale deployments and smaller systems may seem
daunting, but Salt is very simple to set up and maintain, regardless of the
size of the project. The architecture of Salt is designed to work with any
number of servers, from a handful of local network systems to international
deployments across disparate data centers. The topology is a simple
server/client model with the needed functionality built into a single set of
daemons. While the default configuration will work with little to no
modification, Salt can be fine-tuned to meet specific needs.
Granular Controls
=================
Salt also introduces powerful granular controls to the realm of remote execution.
By default, commands are executed in parallel. However, using more advanced
options, commands can be executed in batch groups or even in serial. By using
simple built-in filters or regular expression matching, systems can be targeted by
hostname, metadata or system properties such as number of cpus or OS type.
Building on Proven Technology
=============================
Salt takes advantage of a number of technologies and techniques. The networking
layer is built with the excellent `ZeroMQ`_ networking library. Salt itself
contains a viable, and transparent, ZeroMQ broker inside the daemon. Salt uses
public keys for authentication with the master daemon, then uses faster AES
encryption for payload communication. This means that authentication and
encryption are also built into Salt. Salt takes advantage of communication via
the most excellent `msgpack`_ library, enabling fast and light network traffic.
.. _`ZeroMQ`: http://zeromq.org/
.. _`msgpack`: http://msgpack.org/
Python Client Interface
=======================
Salt execution routines can be written as plain Python modules and the data
collected from execution can be sent back to the master server, or any
arbitrary program. Salt can be called from a simple Python API, or from the
command line. This makes it easy to execute one-off commands as well as
operate as an integral part of a larger application.
Fast, Flexible, Scalable, Secure
================================
The result is a system that can execute commands across groups of
varying size, from very few to very many servers at considerably high
speed. We consider speed to be a feature, not an afterthought. Salts
unique architecture brings together the best of the remote execution
world, amplifies its capabilities and expands its range, resulting in
this system that is as versatile as it is practical. Last but not least,
security is an intrinsic part of Salt and something not just
influencing how source code is written and how tests are done, but
also something that defines the overall architecture and has heavy
influence on the core design tenets.
Open
====
Salt is developed under the `Apache 2.0 license`_, and can be used for
open and proprietary projects. Please submit your expansions back to
the Salt project so that we can all benefit together as Salt grows.
Finally, please sprinkle some Salt around your systems and let the
deliciousness come forth.
.. _`Apache 2.0 license`: http://www.apache.org/licenses/LICENSE-2.0.html

File diff suppressed because it is too large Load diff

View file

@ -3,9 +3,6 @@
Function DownloadFileWithProgress {
# Code for this function borrowed from http://poshcode.org/2461
# Thanks Crazy Dave
# This function downloads the passed file and shows a progress bar
# It receives two parameters:
# $url - the file source
@ -14,11 +11,11 @@ Function DownloadFileWithProgress {
param(
[Parameter(Mandatory=$true)]
[String] $url,
[Parameter(Mandatory=$false)]
[String] $localFile = (Join-Path $pwd.Path $url.SubString($url.LastIndexOf('/')))
)
begin {
Write-Host -ForegroundColor DarkGreen " download-module.DownloadFileWithProgress $url"
$client = New-Object System.Net.WebClient
@ -30,6 +27,7 @@ Function DownloadFileWithProgress {
-SourceIdentifier WebClient.DownloadProgressChanged `
-Action { $Global:DPCEventArgs = $EventArgs }
}
process {
Write-Progress -Activity 'Downloading file' -Status $url
$client.DownloadFileAsync($url, $localFile)
@ -58,6 +56,5 @@ Function DownloadFileWithProgress {
Write-Error "Exiting because download missing or zero-length: $localfile"
exit 2
}
}
}

View file

@ -1,109 +1,102 @@
Function Get-Settings {
# Contains Settings used by the installer scripts
Write-Verbose "$($MyInvocation.MyCommand.Name):: Loading Settings"
[CmdletBinding()]
Param()
$ini = @{}
Begin
{Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started"}
# Gets the project directory
$env:ProjDir = $(git rev-parse --show-toplevel).Replace("/", "\")
Process
{
Write-Verbose "$($MyInvocation.MyCommand.Name):: Loading Settings"
# Source dir should be next to the project dir
$env:SrcDir = "$($env:ProjDir | Split-Path)\salt"
$ini = @{}
If ( -Not (Test-Path env:PyVerMajor)) { $env:PyVerMajor = "3" }
If ( -Not (Test-Path env:PyVerMinor)) { $env:PyVerMinor = "8" }
If ( -Not (Test-Path env:PyDir)) { $env:PyDir = "C:\Python38" }
If ( -Not (Test-Path env:SrcDir)) {
$env:SrcDir = $(git rev-parse --show-toplevel).Replace("/", "\")
# Location where the files are kept
$Settings = @{
"ProjDir" = "$env:ProjDir"
"SrcDir" = "$env:SrcDir"
"SaltRepo" = "https://repo.saltproject.io/windows/dependencies"
"SaltDir" = "C:\salt"
"PyVerMajor" = "$env:PyVerMajor"
"PyVerMinor" = "$env:PyVerMinor"
"Python3Dir" = "$env:PyDir"
"Scripts3Dir" = "$env:PyDir\Scripts"
"SitePkgs3Dir" = "$env:PyDir\Lib\site-packages"
"DownloadDir" = "$env:Temp\DevSalt"
}
If ( -Not (Test-Path env:PyVerMajor)) { $env:PyVerMajor = "3" }
If ( -Not (Test-Path env:PyVerMinor)) { $env:PyVerMinor = "8" }
If ( -Not (Test-Path env:PyDir)) { $env:PyDir = "C:\Python38" }
# Location where the files are kept
$Settings = @{
"SrcDir" = "$env:SrcDir"
"SaltRepo" = "https://repo.saltproject.io/windows/dependencies"
"SaltDir" = "C:\salt"
"PyVerMajor" = "$env:PyVerMajor"
"PyVerMinor" = "$env:PyVerMinor"
"Python3Dir" = "$env:PyDir"
"Scripts3Dir" = "$env:PyDir\Scripts"
"SitePkgs3Dir" = "$env:PyDir\Lib\site-packages"
"DownloadDir" = "$env:Temp\DevSalt"
}
$ini.Add("Settings", $Settings)
Write-Verbose "DownloadDir === $($ini['Settings']['DownloadDir']) ==="
$ini.Add("Settings", $Settings)
Write-Verbose "DownloadDir === $($ini['Settings']['DownloadDir']) ==="
# Prerequisite software
$Prerequisites = @{
"NSIS" = "nsis-3.03-setup.exe"
"NSISLibMoveFileFolder" = "nsis-MoveFileFolder.nsh"
"NSISPluginAccessControl" = "nsis-plugin-accesscontrol.zip"
"NSISPluginEnVar" = "nsis-plugin-envar.zip"
"NSISPluginUnzipA" = "nsis-plugin-nsisunz.zip"
"NSISPluginUnzipU" = "nsis-plugin-nsisunzu.zip"
"VS2015BuildTools" = "vcppbuildtools_full.zip"
}
$ini.Add("Prerequisites", $Prerequisites)
# Location of programs on 64 bit Windows
$64bitPaths = @{
"NSISDir" = "C:\Program Files (x86)\NSIS"
"NSISPluginsDirA" = "C:\Program Files (x86)\NSIS\Plugins\x86-ansi"
"NSISPluginsDirU" = "C:\Program Files (x86)\NSIS\Plugins\x86-unicode"
"VCforPythonDir" = "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0"
"VS2015BuildToolsDir" = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin"
}
$ini.Add("64bitPaths", $64bitPaths)
# Location of programs on 32 bit Windows
$32bitPaths = @{
"NSISDir" = "C:\Program Files\NSIS"
"NSISPluginsDirA" = "C:\Program Files\NSIS\Plugins\x86-ansi"
"NSISPluginsDirU" = "C:\Program Files\NSIS\Plugins\x86-unicode"
"VCforPythonDir" = "C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0"
"VS2015BuildToolsDir" = "C:\Program Files\Microsoft Visual Studio 14.0\VC\bin"
}
$ini.Add("32bitPaths", $32bitPaths)
# Filenames for 64 bit Windows
$64bitPrograms = @{
"Python3" = "python-3.8.8-amd64.exe"
"VCRedist" = "vcredist_x64_2013.exe"
"VCRedistReg" = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{53CF6934-A98D-3D84-9146-FC4EDF3D5641}"
}
$ini.Add("64bitPrograms", $64bitPrograms)
# Filenames for 32 bit Windows
$32bitPrograms = @{
"Python3" = "python-3.8.8.exe"
"VCRedist" = "vcredist_x86_2013.exe"
"VCRedistReg" = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8122DAB1-ED4D-3676-BB0A-CA368196543E}"
}
$ini.Add("32bitPrograms", $32bitPrograms)
# DLL's for 64 bit Windows
$64bitDLLs = @{
"Libeay" = "openssl/1.1.1k/libeay32.dll"
"SSLeay" = "openssl/1.1.1k/ssleay32.dll"
"OpenSSLLic" = "openssl/1.1.1k/OpenSSL_License.txt"
"Libsodium" = "libsodium/1.0.18/libsodium.dll"
}
$ini.Add("64bitDLLs", $64bitDLLs)
# DLL's for 32 bit Windows
$32bitDLLs = @{
"Libeay" = "openssl/1.1.1k/libeay32.dll"
"SSLeay" = "openssl/1.1.1k/ssleay32.dll"
"OpenSSLLic" = "openssl/1.1.1k/OpenSSL_License.txt"
"Libsodium" = "libsodium/1.0.18/libsodium.dll"
}
$ini.Add("32bitDLLs", $32bitDLLs)
Write-Verbose "$($MyInvocation.MyCommand.Name):: Finished Loading Settings"
Return $ini
# Prerequisite software
$Prerequisites = @{
"NSIS" = "nsis-3.03-setup.exe"
"NSISLibMoveFileFolder" = "nsis-MoveFileFolder.nsh"
"NSISPluginAccessControl" = "nsis-plugin-accesscontrol.zip"
"NSISPluginEnVar" = "nsis-plugin-envar.zip"
"NSISPluginUnzipA" = "nsis-plugin-nsisunz.zip"
"NSISPluginUnzipU" = "nsis-plugin-nsisunzu.zip"
"VS2015BuildTools" = "vcppbuildtools_full.zip"
}
End
{Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended"}
$ini.Add("Prerequisites", $Prerequisites)
# Location of programs on 64 bit Windows
$64bitPaths = @{
"NSISDir" = "C:\Program Files (x86)\NSIS"
"NSISPluginsDirA" = "C:\Program Files (x86)\NSIS\Plugins\x86-ansi"
"NSISPluginsDirU" = "C:\Program Files (x86)\NSIS\Plugins\x86-unicode"
"VCforPythonDir" = "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0"
"VS2015BuildToolsDir" = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin"
}
$ini.Add("64bitPaths", $64bitPaths)
# Location of programs on 32 bit Windows
$32bitPaths = @{
"NSISDir" = "C:\Program Files\NSIS"
"NSISPluginsDirA" = "C:\Program Files\NSIS\Plugins\x86-ansi"
"NSISPluginsDirU" = "C:\Program Files\NSIS\Plugins\x86-unicode"
"VCforPythonDir" = "C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0"
"VS2015BuildToolsDir" = "C:\Program Files\Microsoft Visual Studio 14.0\VC\bin"
}
$ini.Add("32bitPaths", $32bitPaths)
# Filenames for 64 bit Windows
$64bitPrograms = @{
"Python3" = "python-3.8.8-amd64.exe"
"VCRedist" = "vcredist_x64_2013.exe"
"VCRedistReg" = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{53CF6934-A98D-3D84-9146-FC4EDF3D5641}"
}
$ini.Add("64bitPrograms", $64bitPrograms)
# Filenames for 32 bit Windows
$32bitPrograms = @{
"Python3" = "python-3.8.8.exe"
"VCRedist" = "vcredist_x86_2013.exe"
"VCRedistReg" = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8122DAB1-ED4D-3676-BB0A-CA368196543E}"
}
$ini.Add("32bitPrograms", $32bitPrograms)
# DLL's for 64 bit Windows
$64bitDLLs = @{
"Libeay" = "openssl/1.1.1k/libeay32.dll"
"SSLeay" = "openssl/1.1.1k/ssleay32.dll"
"OpenSSLLic" = "openssl/1.1.1k/OpenSSL_License.txt"
"Libsodium" = "libsodium/1.0.18/libsodium.dll"
}
$ini.Add("64bitDLLs", $64bitDLLs)
# DLL's for 32 bit Windows
$32bitDLLs = @{
"Libeay" = "openssl/1.1.1k/libeay32.dll"
"SSLeay" = "openssl/1.1.1k/ssleay32.dll"
"OpenSSLLic" = "openssl/1.1.1k/OpenSSL_License.txt"
"Libsodium" = "libsodium/1.0.18/libsodium.dll"
}
$ini.Add("32bitDLLs", $32bitDLLs)
Write-Verbose "$($MyInvocation.MyCommand.Name):: Finished Loading Settings"
Return $ini
}

View file

@ -7,9 +7,14 @@ Function Start_Process_and_test_exitcode {
# $descr - the short description shown in the case of an error
Param(
[Parameter(Mandatory=$true)] [String] $fun,
[Parameter(Mandatory=$true)] [String] $args,
[Parameter(Mandatory=$true)] [String] $descr
[Parameter(Mandatory=$true)]
[String] $fun,
[Parameter(Mandatory=$true)]
[String] $args,
[Parameter(Mandatory=$true)]
[String] $descr
)
Begin { Write-Host "Executing Command: $fun $args" }

View file

@ -1,12 +1,12 @@
function Get-IsAdministrator
{
function Get-IsAdministrator {
# Detect if the user is Administrator
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$Principal = New-Object System.Security.Principal.WindowsPrincipal($Identity)
$Principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Get-IsUacEnabled
{
function Get-IsUacEnabled {
# Detect if UAC is enabled
(Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System).EnableLua -ne 0
}

View file

@ -1,19 +1,19 @@
Function Expand-ZipFile {
# A PowerShell 3.0 compatible function for unzipping files
Param(
[Parameter(Mandatory = $true)] [string] $zipfile,
[Parameter(Mandatory = $true)] [string] $destination
[Parameter(Mandatory=$true)]
[string] $zipfile,
[Parameter(Mandatory=$true)]
[string] $destination
)
# This function unzips a zip file
# Code obtained from:
# http://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/
Begin { Write-Host " - Unzipping '$zipfile' to '$destination'" }
Process {
# Create a new directory if it doesn't exist
If (!(Test-Path -Path $destination))
{
If (!(Test-Path -Path $destination)) {
New-Item -ItemType directory -Path $destination
}
@ -24,8 +24,7 @@ Function Expand-ZipFile {
$objZip = $objShell.NameSpace($zipfile)
# Unzip each item in the zip file
ForEach ($item in $objZip.Items())
{
ForEach ($item in $objZip.Items()) {
$objShell.Namespace($destination).CopyHere($item, 0x14)
}
}

View file

@ -1,60 +0,0 @@
#!/usr/bin/python
import getopt
import os
import sys
def display_help():
print("####################################################################")
print("# #")
print("# File: portable.py #")
print("# Description: #")
print("# - search and replace within a binary file #")
print("# #")
print("# Parameters: #")
print("# -f, --file : target file #")
print("# -s, --search : term to search for #")
print("# Default is the base path for the python #")
print("# executable that is running this script. #")
print("# In Py2 that would be C:\\Python27 #")
print("# -r, --replace : replace with this #")
print('# default is ".." #')
print("# #")
print("# example: #")
print("# portable.py -f <target_file> -s <search_term> -r <replace_term> #")
print("# #")
print("####################################################################")
sys.exit(2)
def main(argv):
target = ""
search = os.path.dirname(sys.executable)
replace = ".."
try:
opts, args = getopt.getopt(argv, "hf:s:r:", ["file=", "search=", "replace="])
except getopt.GetoptError:
display_help()
for opt, arg in opts:
if opt == "-h":
display_help()
elif opt in ("-f", "--file"):
target = arg
elif opt in ("-s", "--search"):
search = arg
elif opt in ("-r", "--replace"):
replace = arg
if target == "":
display_help()
search = search.encode("utf-8")
replace = replace.encode("utf-8")
f = open(target, "rb").read()
f = f.replace(search, replace)
f = f.replace(search.lower(), replace)
open(target, "wb").write(f)
if __name__ == "__main__":
main(sys.argv[1:])

View file

@ -17,13 +17,13 @@
:: COPYRIGHT: (c) 2012-2018 by the SaltStack Team
::
:: LICENSE: Apache 2.0
:: ORGANIZATION: VMware, Inc (saltstack.com)
:: ORGANIZATION: SaltStack, Inc (saltstack.com)
:: CREATED: 2017
::
:: ############################################################################
::
:: USAGE: The script must be located in a directory that has the installer
:: files in a subfolder named with the major version, ie: `2018.3`.
:: files in a sub-folder named with the major version, ie: `2018.3`.
:: Insert the key fob that contains the code signing certificate. Run
:: the script passing the full version: `.\sign.bat 2018.3.1`.
::
@ -37,6 +37,24 @@
:: would be named: `Salt-Minion-2018.3.1-Py3-AMD64-Setup.exe`. This
:: is how the file is created by the NSI Script anyway.
::
:: You can test the timestamp server with the following command:
:: curl -i timestamp.digicert.com/timestamp/health
::
:: REQUIREMENTS: This script requires the ``signtool.exe`` binary that is a part
:: of the Windows SDK. To install just the ``signtool.exe``:
::
:: OPTION 1:
:: 1. Download the Windows 10 SDK ISO:
:: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
:: 2. Mount the ISO and browse to the ``Installers`` directory
:: 3. Run the ``Windows SDK Signing Tools-x86_en-us.msi``
::
:: OPTION 2:
:: 1. Download the Visual Studio BUild Tools:
:: https://aka.ms/vs/15/release/vs_buildtools.exe
:: 2. Run the following command:
:: vs_buildtools.exe --quiet --add Microsoft.Component.ClickOnce.MSBuild
::
:: ############################################################################
@ echo off
if [%1]==[] (
@ -46,23 +64,13 @@ if [%1]==[] (
set "Version=%~1"
)
for /F "tokens=1,2 delims=." %%a in ("%Version%") do (set Series=%%a.%%b)
set Series=%Version:~0,4%
:: See if the Series Directory exists (uses new versioning)
if not exist .\%Series%\ (
echo - Series %Series% was not found, trying new naming convention
for /F "tokens=1,2 delims=." %%a in ("%Version%") do (set Series=%%a)
)
if not exist .\%Series%\ (
echo - Series %Series% is not valid
exit 1
)
:: If it ends in a '.' trim it
if "%Series:~-1%"=="." (
set Series=%Series:~0,-1%
)
:: Sign Installer Files
echo ===========================================================================
echo Signing...
@ -79,7 +87,9 @@ signtool.exe sign /a /t http://timestamp.digicert.com ^
"%Series%\Salt-Minion-%Version%-Py2-AMD64-Setup.exe" ^
"%Series%\Salt-Minion-%Version%-Py2-x86-Setup.exe" ^
"%Series%\Salt-Minion-%Version%-Py3-AMD64-Setup.exe" ^
"%Series%\Salt-Minion-%Version%-Py3-x86-Setup.exe"
"%Series%\Salt-Minion-%Version%-Py3-x86-Setup.exe" ^
"%Series%\Salt-Minion-%Version%-Py3-AMD64.msi" ^
"%Series%\Salt-Minion-%Version%-Py3-x86.msi"
echo %ERRORLEVEL%
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -94,86 +104,113 @@ set "file_name=Salt-Minion-%Version%-AMD64-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-x86-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-%Version%-AMD64-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-%Version%-x86-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-%Version%-Py2-AMD64-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-%Version%-Py2-x86-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-%Version%-Py3-AMD64-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-%Version%-Py3-x86-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-Py2-AMD64-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-Py2-x86-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-Py3-AMD64-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-Py3-x86-Setup.exe"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\"" -NoNewLine
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\"" -NoNewLine)
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-Py3-AMD64.msi"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
set "file_name=Salt-Minion-%Version%-Py3-x86.msi"
set "file=.\%Series%\%file_name%"
if exist "%file%" (
echo - %file_name%
powershell -c "$hash = (Get-FileHash -Algorithm MD5 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.md5\" -NoNewLine -Encoding ASCII"
powershell -c "$hash = (Get-FileHash -Algorithm SHA256 \"%file%\").Hash; Out-File -InputObject $hash\" %file_name%\" -FilePath \"%file%.sha256\" -NoNewLine -Encoding ASCII"
)
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Hashing Complete