mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add python 3 installer for Windows
This commit is contained in:
parent
327d1bb5d1
commit
02757db1e4
16 changed files with 692 additions and 189 deletions
|
@ -32,38 +32,80 @@ if %errorLevel%==0 (
|
|||
@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
|
||||
if "%Version%"=="" (
|
||||
for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
|
||||
)
|
||||
|
||||
:: If Python not defined, Assume Python 2
|
||||
if "%Python%"=="" (
|
||||
set Python=2
|
||||
)
|
||||
|
||||
:: Verify valid Python value (2 or 3)
|
||||
set "x="
|
||||
for /f "delims=23" %%i in ("%Python%") do set x=%%i
|
||||
if Defined x (
|
||||
echo Invalid Python Version specified. Must be 2 or 3. Passed %Python%
|
||||
goto eof
|
||||
)
|
||||
|
||||
@echo =====================================================================
|
||||
@echo.
|
||||
|
||||
:: Define Variables
|
||||
@echo %0 :: Defining Variables...
|
||||
@echo ---------------------------------------------------------------------
|
||||
Set "PyDir=C:\Python27"
|
||||
if %Python%==2 (
|
||||
Set "PyDir=C:\Python27"
|
||||
) else (
|
||||
Set "PyDir=C:\Program Files\Python35"
|
||||
)
|
||||
Set "PATH=%PATH%;%PyDir%;%PyDir%\Scripts"
|
||||
|
||||
Set "CurDir=%~dp0"
|
||||
Set PATH=%PATH%;C:\Python27;C:\Python27\Scripts
|
||||
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"
|
||||
|
||||
:: Get the version from git if not passed
|
||||
if [%1]==[] (
|
||||
for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
|
||||
echo ... Version from git describe == %Version%
|
||||
) else (
|
||||
set "Version=%~1"
|
||||
)
|
||||
@echo =====================================================================
|
||||
@echo.
|
||||
|
||||
:: Version must be set
|
||||
if [%Version%]==[] (
|
||||
echo Failure: Version must be set
|
||||
goto eof
|
||||
)
|
||||
|
||||
:: Create Build Environment
|
||||
@echo %0 :: Create the Build Environment...
|
||||
@echo ---------------------------------------------------------------------
|
||||
PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env.ps1" -Silent
|
||||
PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env_%Python%.ps1" -Silent
|
||||
|
||||
if not %errorLevel%==0 (
|
||||
echo "%CurDir%build_env.ps1" returned errorlevel %errorLevel%. Aborting %0
|
||||
echo "%CurDir%build_env_%Python%.ps1" returned errorlevel %errorLevel%. Aborting %0
|
||||
goto eof
|
||||
)
|
||||
@echo.
|
||||
|
@ -80,7 +122,7 @@ if not %errorLevel%==0 (
|
|||
:: Build the Salt Package
|
||||
@echo %0 :: Build the Salt Package...
|
||||
@echo ---------------------------------------------------------------------
|
||||
call "%CurDir%build_pkg.bat" "%Version%"
|
||||
call "%CurDir%build_pkg.bat" "%Version%" %Python%
|
||||
@echo.
|
||||
|
||||
:eof
|
||||
|
|
|
@ -164,18 +164,18 @@ If (Test-Path "$($ini[$bitPaths]['VCforPythonDir'])\vcvarsall.bat") {
|
|||
# Install Python
|
||||
#------------------------------------------------------------------------------
|
||||
Write-Output " - Checking for Python 2.7 installation . . ."
|
||||
If (Test-Path "$($ini['Settings']['PythonDir'])\python.exe") {
|
||||
If (Test-Path "$($ini['Settings']['Python2Dir'])\python.exe") {
|
||||
# Found Python2.7, do nothing
|
||||
Write-Output " - Python 2.7 Found . . ."
|
||||
} Else {
|
||||
Write-Output " - Downloading $($ini[$bitPrograms]['Python']) . . ."
|
||||
$file = "$($ini[$bitPrograms]['Python'])"
|
||||
Write-Output " - Downloading $($ini[$bitPrograms]['Python2']) . . ."
|
||||
$file = "$($ini[$bitPrograms]['Python2'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
Write-Output " - $script_name :: Installing $($ini[$bitPrograms]['Python']) . . ."
|
||||
$p = Start-Process msiexec -ArgumentList "/i $file /qb ADDLOCAL=DefaultFeature,Extensions,pip_feature,PrependPath TARGETDIR=$($ini['Settings']['PythonDir'])" -Wait -NoNewWindow -PassThru
|
||||
Write-Output " - $script_name :: Installing $($ini[$bitPrograms]['Python2']) . . ."
|
||||
$p = Start-Process msiexec -ArgumentList "/i $file /qb ADDLOCAL=DefaultFeature,Extensions,pip_feature,PrependPath TARGETDIR=$($ini['Settings']['Python2Dir'])" -Wait -NoNewWindow -PassThru
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
@ -183,8 +183,8 @@ If (Test-Path "$($ini['Settings']['PythonDir'])\python.exe") {
|
|||
#------------------------------------------------------------------------------
|
||||
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']['ScriptsDir'])".ToLower()))) {
|
||||
$newPath = "$($ini['Settings']['ScriptsDir']);$Path"
|
||||
If (!($Path.ToLower().Contains("$($ini['Settings']['Scripts2Dir'])".ToLower()))) {
|
||||
$newPath = "$($ini['Settings']['Scripts2Dir']);$Path"
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
|
||||
$env:Path = $newPath
|
||||
}
|
||||
|
@ -197,17 +197,17 @@ Write-Output " ----------------------------------------------------------------"
|
|||
Write-Output " - $script_name :: Updating PIP and SetupTools . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
if ( ! [bool]$Env:SALT_PIP_LOCAL_CACHE) {
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['PythonDir'])\python.exe" "-m pip --no-cache-dir install -r $($script_path)\req_pip.txt" "python pip"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python2Dir'])\python.exe" "-m pip --no-cache-dir install -r $($script_path)\req_pip.txt" "python pip"
|
||||
} else {
|
||||
$p = New-Item $Env:SALT_PIP_LOCAL_CACHE -ItemType Directory -Force # Ensure directory exists
|
||||
if ( (Get-ChildItem $Env:SALT_PIP_LOCAL_CACHE | Measure-Object).Count -eq 0 ) {
|
||||
# folder empty
|
||||
Write-Output " pip download from req_pip.txt into empty local cache SALT_REQ_PIP $Env:SALT_PIP_LOCAL_CACHE"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['PythonDir'])\python.exe" "-m pip download --dest $Env:SALT_PIP_LOCAL_CACHE -r $($script_path)\req_pip.txt" "pip download"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python2Dir'])\python.exe" "-m pip download --dest $Env:SALT_PIP_LOCAL_CACHE -r $($script_path)\req_pip.txt" "pip download"
|
||||
}
|
||||
Write-Output " reading from local pip cache $Env:SALT_PIP_LOCAL_CACHE"
|
||||
Write-Output " If a (new) ressource is missing, please delete all files in this cache, go online and repeat"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['PythonDir'])\python.exe" "-m pip install --no-index --find-links=$Env:SALT_PIP_LOCAL_CACHE -r $($script_path)\req_pip.txt" "pip install"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python2Dir'])\python.exe" "-m pip install --no-index --find-links=$Env:SALT_PIP_LOCAL_CACHE -r $($script_path)\req_pip.txt" "pip install"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
@ -218,16 +218,16 @@ Write-Output " ----------------------------------------------------------------"
|
|||
Write-Output " - $script_name :: Installing pypi resources using pip . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
if ( ! [bool]$Env:SALT_REQ_LOCAL_CACHE) {
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['ScriptsDir'])\pip.exe" "--no-cache-dir install -r $($script_path)\req.txt" "pip install"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Scripts2Dir'])\pip.exe" "--no-cache-dir install -r $($script_path)\req_2.txt" "pip install"
|
||||
} else {
|
||||
if ( (Get-ChildItem $Env:SALT_REQ_LOCAL_CACHE | Measure-Object).Count -eq 0 ) {
|
||||
# folder empty
|
||||
Write-Output " pip download from req.txt into empty local cache SALT_REQ $Env:SALT_REQ_LOCAL_CACHE"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['PythonDir'])\python.exe" "-m pip download --dest $Env:SALT_REQ_LOCAL_CACHE -r $($script_path)\req.txt" "pip download"
|
||||
Write-Output " pip download from req_2.txt into empty local cache SALT_REQ $Env:SALT_REQ_LOCAL_CACHE"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python2Dir'])\python.exe" "-m pip download --dest $Env:SALT_REQ_LOCAL_CACHE -r $($script_path)\req_2.txt" "pip download"
|
||||
}
|
||||
Write-Output " reading from local pip cache $Env:SALT_REQ_LOCAL_CACHE"
|
||||
Write-Output " If a (new) ressource is missing, please delete all files in this cache, go online and repeat"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['PythonDir'])\python.exe" "-m pip install --no-index --find-links=$Env:SALT_REQ_LOCAL_CACHE -r $($script_path)\req.txt" "pip install"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python2Dir'])\python.exe" "-m pip install --no-index --find-links=$Env:SALT_REQ_LOCAL_CACHE -r $($script_path)\req_2.txt" "pip install"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
@ -238,13 +238,13 @@ Write-Output " ----------------------------------------------------------------"
|
|||
Write-Output " - $script_name :: Installing PyYAML . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
# Download
|
||||
$file = "$($ini[$bitPrograms]['PyYAML'])"
|
||||
$file = "$($ini[$bitPrograms]['PyYAML2'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
# Install
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['ScriptsDir'])\easy_install.exe" "-Z $file " "easy_install PyYAML"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Scripts2Dir'])\easy_install.exe" "-Z $file " "easy_install PyYAML"
|
||||
|
||||
#==============================================================================
|
||||
# Install PyCrypto from wheel file
|
||||
|
@ -253,13 +253,13 @@ Write-Output " ----------------------------------------------------------------"
|
|||
Write-Output " - $script_name :: Installing PyCrypto . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
# Download
|
||||
$file = "$($ini[$bitPrograms]['PyCrypto'])"
|
||||
$file = "$($ini[$bitPrograms]['PyCrypto2'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
# Install
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['ScriptsDir'])\pip.exe" "install --no-index --find-links=$($ini['Settings']['DownloadDir']) $file " "pip install PyCrypto"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Scripts2Dir'])\pip.exe" "install --no-index --find-links=$($ini['Settings']['DownloadDir']) $file " "pip install PyCrypto"
|
||||
|
||||
#==============================================================================
|
||||
# Copy DLLs to Python Directory
|
||||
|
@ -275,7 +275,7 @@ ForEach($key in $ini[$bitDLLs].Keys) {
|
|||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
Copy-Item $file -destination $($ini['Settings']['PythonDir'])
|
||||
Copy-Item $file -destination $($ini['Settings']['Python2Dir'])
|
||||
}
|
||||
}
|
||||
|
298
pkg/windows/build_env_3.ps1
Normal file
298
pkg/windows/build_env_3.ps1
Normal file
|
@ -0,0 +1,298 @@
|
|||
#==============================================================================
|
||||
# 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-2015 by the SaltStack Team, see AUTHORS.rst for more
|
||||
# details.
|
||||
#
|
||||
# LICENSE: Apache 2.0
|
||||
# ORGANIZATION: SaltStack (saltstack.org)
|
||||
# CREATED: 03/15/2015
|
||||
#==============================================================================
|
||||
|
||||
# Load parameters
|
||||
param(
|
||||
[switch]$Silent
|
||||
)
|
||||
|
||||
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: dev_env.ps1 -Silent"
|
||||
Write-Output ""
|
||||
Write-Output "================================================================="
|
||||
Write-Output ""
|
||||
|
||||
#==============================================================================
|
||||
# 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
|
||||
|
||||
#==============================================================================
|
||||
# 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 Microsoft Visual C++ Build Tools
|
||||
#------------------------------------------------------------------------------
|
||||
Write-Output " - Checking for Microsoft Visual C++ Build Tools installation . . ."
|
||||
If (Test-Path "$($ini[$bitPaths]['VCppBuildToolsDir'])\vcbuildtools.bat") {
|
||||
# Found Microsoft Visual C++ Build Tools, do nothing
|
||||
Write-Output " - Microsoft Visual C++ Build Tools Found . . ."
|
||||
} Else {
|
||||
# Microsoft Visual C++ Build Tools not found, install
|
||||
Write-Output " - Microsoft Visual C++ Build Tools Not Found . . ."
|
||||
Write-Output " - Downloading $($ini['Prerequisites']['VCppBuildTools']) . . ."
|
||||
$file = "$($ini['Prerequisites']['VCppBuildTools'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
# Install Microsoft Visual C++ Build Tools
|
||||
Write-Output " - Installing $($ini['Prerequisites']['VCppBuildTools']) . . ."
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$($ini['Prerequisites']['VCppBuildTools'])"
|
||||
$p = Start-Process $file -ArgumentList '/Passive' -Wait -NoNewWindow -PassThru
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Install Python
|
||||
#------------------------------------------------------------------------------
|
||||
Write-Output " - Checking for Python 3.5 installation . . ."
|
||||
If (Test-Path "$($ini['Settings']['Python3Dir'])\python.exe") {
|
||||
# Found Python 3.5, do nothing
|
||||
Write-Output " - Python 3.5 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 '/passive InstallAllUsers=1 TargetDir="C:\Program Files\Python35" Include_doc=0 Include_tcltk=0 Include_test=0 Include_launcher=0 PrependPath=1 Shortcuts=0' -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
|
||||
# caching depends on environmant variable SALT_PIP_LOCAL_CACHE
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - $script_name :: Updating PIP and SetupTools . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
if ( ! [bool]$Env:SALT_PIP_LOCAL_CACHE) {
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python3Dir'])\python.exe" "-m pip --no-cache-dir install -r $($script_path)\req_pip.txt" "python pip"
|
||||
} else {
|
||||
$p = New-Item $Env:SALT_PIP_LOCAL_CACHE -ItemType Directory -Force # Ensure directory exists
|
||||
if ( (Get-ChildItem $Env:SALT_PIP_LOCAL_CACHE | Measure-Object).Count -eq 0 ) {
|
||||
# folder empty
|
||||
Write-Output " pip download from req_pip.txt into empty local cache SALT_REQ_PIP $Env:SALT_PIP_LOCAL_CACHE"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python3Dir'])\python.exe" "-m pip download --dest $Env:SALT_PIP_LOCAL_CACHE -r $($script_path)\req_pip.txt" "pip download"
|
||||
}
|
||||
Write-Output " reading from local pip cache $Env:SALT_PIP_LOCAL_CACHE"
|
||||
Write-Output " If a (new) ressource is missing, please delete all files in this cache, go online and repeat"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python3Dir'])\python.exe" "-m pip install --no-index --find-links=$Env:SALT_PIP_LOCAL_CACHE -r $($script_path)\req_pip.txt" "pip install"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install pypi resources using pip
|
||||
# caching depends on environmant variable SALT_REQ_LOCAL_CACHE
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - $script_name :: Installing pypi resources using pip . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
if ( ! [bool]$Env:SALT_REQ_LOCAL_CACHE) {
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Scripts3Dir'])\pip.exe" "--no-cache-dir install -r $($script_path)\req_3.txt" "pip install"
|
||||
} else {
|
||||
if ( (Get-ChildItem $Env:SALT_REQ_LOCAL_CACHE | Measure-Object).Count -eq 0 ) {
|
||||
# folder empty
|
||||
Write-Output " pip download from req_3.txt into empty local cache SALT_REQ $Env:SALT_REQ_LOCAL_CACHE"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python3Dir'])\python.exe" "-m pip download --dest $Env:SALT_REQ_LOCAL_CACHE -r $($script_path)\req_3.txt" "pip download"
|
||||
}
|
||||
Write-Output " reading from local pip cache $Env:SALT_REQ_LOCAL_CACHE"
|
||||
Write-Output " If a (new) ressource is missing, please delete all files in this cache, go online and repeat"
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Python3Dir'])\python.exe" "-m pip install --no-index --find-links=$Env:SALT_REQ_LOCAL_CACHE -r $($script_path)\req_3.txt" "pip install"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install PyWin32 from wheel file
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - $script_name :: Installing PyWin32 . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
# Download
|
||||
$file = "$($ini[$bitPrograms]['PyWin323'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
# Install
|
||||
Start_Process_and_test_exitcode "$($ini['Settings']['Scripts3Dir'])\pip.exe" "install --no-index --find-links=$($ini['Settings']['DownloadDir']) $file " "pip install PyWin32"
|
||||
|
||||
#==============================================================================
|
||||
# Fix PyCrypto
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - $script_name :: Fixing PyCrypto . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
$nt_file = "$($ini['Settings']['Python3Dir'])\Lib\site-packages\Crypto\Random\OSRNG\nt.py"
|
||||
(Get-Content $nt_file) | Foreach-Object {$_ -replace '^import winrandom$', 'from Crypto.Random.OSRNG import winrandom'} | Set-Content $nt_file
|
||||
|
||||
#==============================================================================
|
||||
# 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) {
|
||||
If ($arrInstalled -notcontains $key) {
|
||||
Write-Output " - $key . . ."
|
||||
$file = "$($ini[$bitDLLs][$key])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$bitFolder\$file"
|
||||
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 unless you use SALTREPO_LOCAL_CACHE"
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output ""
|
||||
if ( ! [bool]$Env:SALTREPO_LOCAL_CACHE ) {
|
||||
Remove-Item $($ini['Settings']['DownloadDir']) -Force -Recurse
|
||||
}
|
|
@ -1,74 +1,122 @@
|
|||
@echo off
|
||||
@echo Salt Windows Build Package Script
|
||||
@echo ----------------------------------------------------------------------
|
||||
@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
|
||||
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 2
|
||||
if "%Python%"=="" (
|
||||
set Python=2
|
||||
)
|
||||
|
||||
:: Verify valid Python value (2 or 3)
|
||||
set "x="
|
||||
for /f "delims=23" %%i in ("%Python%") do set x=%%i
|
||||
if Defined x (
|
||||
echo Invalid Python Version specified. Must be 2 or 3. Passed %Python%
|
||||
goto eof
|
||||
)
|
||||
@echo.
|
||||
|
||||
:: Define Variables
|
||||
@echo Defining Variables...
|
||||
@echo ----------------------------------------------------------------------
|
||||
if %Python%==2 (
|
||||
Set "PyDir=C:\Python27"
|
||||
Set "PyVerMajor=2"
|
||||
Set "PyVerMinor=7"
|
||||
) else (
|
||||
Set "PyDir=C:\Program Files\Python35"
|
||||
Set "PyVerMajor=3"
|
||||
Set "PyVerMinor=5"
|
||||
)
|
||||
|
||||
:: Verify the Python Installation
|
||||
If not Exist "%PyDir%\python.exe" (
|
||||
@echo Expected version of Python not found: Python %PyVerMajor%.%PyVerMinor%"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
Set "CurrDir=%cd%"
|
||||
Set "BinDir=%cd%\buildenv\bin"
|
||||
Set "InsDir=%cd%\installer"
|
||||
Set "PreDir=%cd%\prereqs"
|
||||
Set "PyDir27=C:\Python27"
|
||||
Set "PyDir35=C:\Program Files\Python35"
|
||||
Set "PyDir36=C:\Program Files\Python36"
|
||||
|
||||
:: Get the version from git if not passed
|
||||
if [%1]==[] (
|
||||
for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
|
||||
) else (
|
||||
set "Version=%~1"
|
||||
)
|
||||
|
||||
If Exist "%PyDir36%\python.exe" (
|
||||
Set "PyDir=%PyDir36%"
|
||||
Set "PyVerMajor=3"
|
||||
Set "PyVerMinor=6"
|
||||
) Else (
|
||||
If Exist "%PyDir35%\python.exe" (
|
||||
Set "PyDir=%PyDir35%"
|
||||
Set "PyVerMajor=3"
|
||||
Set "PyVerMinor=5"
|
||||
) Else (
|
||||
If Exist "%PyDir27%\python.exe" (
|
||||
Set "PyDir=%PyDir27%"
|
||||
Set "PyVerMajor=2"
|
||||
Set "PyVerMinor=7"
|
||||
) Else (
|
||||
@echo Could not find Python on the system
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
:: Find the NSIS Installer
|
||||
If Exist "C:\Program Files\NSIS\" (
|
||||
Set NSIS="C:\Program Files\NSIS\"
|
||||
Set "NSIS=C:\Program Files\NSIS\"
|
||||
) Else (
|
||||
Set NSIS="C:\Program Files (x86)\NSIS\"
|
||||
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 ----------------------------------------------------------------------
|
||||
:: Check for existing bin directory and remove
|
||||
If Exist "%BinDir%\" rd /S /Q "%BinDir%"
|
||||
|
||||
:: Copy the Python directory to bin
|
||||
@echo xcopy /E /Q "%PyDir%" "%BinDir%\"
|
||||
xcopy /E /Q "%PyDir%" "%BinDir%\"
|
||||
@echo.
|
||||
|
||||
@echo Copying VCRedist 2008 MFC to Prerequisites
|
||||
@echo Copying VCRedist to Prerequisites
|
||||
@echo ----------------------------------------------------------------------
|
||||
:: Make sure the "prereq" directory exists
|
||||
If NOT Exist "%PreDir%" mkdir "%PreDir%"
|
||||
|
||||
:: Set the location of the vcredist to download
|
||||
If %Python%==3 (
|
||||
Set Url64="http://repo.saltstack.com/windows/dependencies/64/vcredist_x64_2015.exe"
|
||||
Set Url32="http://repo.saltstack.com/windows/dependencies/32/vcredist_x86_2015.exe"
|
||||
|
||||
) Else (
|
||||
Set Url64="http://repo.saltstack.com/windows/dependencies/64/vcredist_x64_2008_mfc.exe"
|
||||
Set Url32="http://repo.saltstack.com/windows/dependencies/32/vcredist_x86_2008_mfc.exe"
|
||||
)
|
||||
|
||||
:: Check for 64 bit by finding the Program Files (x86) directory
|
||||
Set Url64="http://repo.saltstack.com/windows/dependencies/64/vcredist_x64_2008_mfc.exe"
|
||||
Set Url32="http://repo.saltstack.com/windows/dependencies/32/vcredist_x86_2008_mfc.exe"
|
||||
If Defined ProgramFiles(x86) (
|
||||
powershell -ExecutionPolicy RemoteSigned -File download_url_file.ps1 -url "%Url64%" -file "%PreDir%\vcredist.exe"
|
||||
) Else (
|
||||
|
@ -500,7 +548,7 @@ If Exist "%BinDir%\Scripts\salt-unity*"^
|
|||
|
||||
@echo Building the installer...
|
||||
@echo ----------------------------------------------------------------------
|
||||
makensis.exe /DSaltVersion=%Version% "%InsDir%\Salt-Minion-Setup.nsi"
|
||||
makensis.exe /DSaltVersion=%Version% /DPythonVersion=%Python% "%InsDir%\Salt-Minion-Setup.nsi"
|
||||
@echo.
|
||||
|
||||
@echo.
|
||||
|
|
|
@ -27,12 +27,23 @@ if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
|||
)
|
||||
@echo.
|
||||
|
||||
:: wipe the Python directory
|
||||
@echo %0 :: Removing the C:\Python27 Directory ...
|
||||
:: Uninstall Python 3.5.3
|
||||
@echo %0 :: Uninstalling Python 3.5.3 ...
|
||||
@echo ---------------------------------------------------------------------
|
||||
"%LOCALAPPDATA%\Package Cache\{b94f45d6-8461-440c-aa4d-bf197b2c2499}\python-3.5.3-amd64.exe" /uninstall
|
||||
|
||||
|
||||
:: wipe the Python directory
|
||||
if exist C:\Python27 (
|
||||
@echo %0 :: Removing the C:\Python27 Directory ...
|
||||
@echo ---------------------------------------------------------------------
|
||||
rd /s /q c:\Python27 || echo Failure: c:\Python27 still exists, please find out why and repeat.
|
||||
)
|
||||
if exist "C:\Program Files\Python35" (
|
||||
@echo %0 :: Removing the C:\Program Files\Python35 Directory ...
|
||||
@echo ---------------------------------------------------------------------
|
||||
rd /s /q "C:\Program Files\Python35" || echo Failure: c:\Python27 still exists, please find out why and repeat.
|
||||
)
|
||||
@echo.
|
||||
|
||||
@echo.
|
||||
|
|
|
@ -30,6 +30,12 @@ ${StrStrAdv}
|
|||
!define PRODUCT_VERSION "Undefined Version"
|
||||
!endif
|
||||
|
||||
!ifdef PythonVersion
|
||||
!define PYTHON_VERSION "${PythonVersion}"
|
||||
!else
|
||||
!define PYTHON_VERSION "2"
|
||||
!endif
|
||||
|
||||
!if "$%PROCESSOR_ARCHITECTURE%" == "AMD64"
|
||||
!define CPUARCH "AMD64"
|
||||
!else if "$%PROCESSOR_ARCHITEW6432%" == "AMD64"
|
||||
|
@ -92,6 +98,7 @@ Var MinionName
|
|||
Var MinionName_State
|
||||
Var StartMinion
|
||||
Var StartMinionDelayed
|
||||
Var DeleteInstallDir
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
@ -182,47 +189,83 @@ FunctionEnd
|
|||
###############################################################################
|
||||
# Installation Settings
|
||||
###############################################################################
|
||||
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
|
||||
OutFile "Salt-Minion-${PRODUCT_VERSION}-${CPUARCH}-Setup.exe"
|
||||
!if ${PYTHON_VERSION} == 3
|
||||
Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (Python ${PYTHON_VERSION})"
|
||||
!else
|
||||
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
|
||||
!endif
|
||||
OutFile "Salt-Minion-${PRODUCT_VERSION}-Py${PYTHON_VERSION}-${CPUARCH}-Setup.exe"
|
||||
InstallDir "c:\salt"
|
||||
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
|
||||
ShowInstDetails show
|
||||
ShowUnInstDetails show
|
||||
|
||||
|
||||
; Check and install Visual C++ 2008 SP1 MFC Security Update redist packages
|
||||
; Check and install Visual C++ redist packages
|
||||
; See http://blogs.msdn.com/b/astebner/archive/2009/01/29/9384143.aspx for more info
|
||||
Section -Prerequisites
|
||||
|
||||
; VCRedist only needed on Windows Server 2008R2/Windows 7 and below
|
||||
${If} ${AtMostWin2008R2}
|
||||
Var /GLOBAL VcRedistName
|
||||
Var /GLOBAL VcRedistGuid
|
||||
Var /GLOBAL NeedVcRedist
|
||||
Var /Global CheckVcRedist
|
||||
StrCpy $CheckVcRedist "False"
|
||||
|
||||
!define VC_REDIST_X64_GUID "{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}"
|
||||
!define VC_REDIST_X86_GUID "{9BE518E6-ECC6-35A9-88E4-87755C07200F}"
|
||||
; Visual C++ 2015 redist packages
|
||||
!define PY3_VC_REDIST_NAME "VC_Redist_2015"
|
||||
!define PY3_VC_REDIST_X64_GUID "{50A2BC33-C9CD-3BF1-A8FF-53C10A0B183C}"
|
||||
!define PY3_VC_REDIST_X86_GUID "{BBF2AC74-720C-3CB3-8291-5E34039232FA}"
|
||||
|
||||
Var /GLOBAL VcRedistGuid
|
||||
Var /GLOBAL NeedVcRedist
|
||||
; Visual C++ 2008 SP1 MFC Security Update redist packages
|
||||
!define PY2_VC_REDIST_NAME "VC_Redist_2008_SP1_MFC"
|
||||
!define PY2_VC_REDIST_X64_GUID "{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}"
|
||||
!define PY2_VC_REDIST_X86_GUID "{9BE518E6-ECC6-35A9-88E4-87755C07200F}"
|
||||
|
||||
${If} ${PYTHON_VERSION} == 3
|
||||
StrCpy $VcRedistName ${PY3_VC_REDIST_NAME}
|
||||
${If} ${CPUARCH} == "AMD64"
|
||||
StrCpy $VcRedistGuid ${VC_REDIST_X64_GUID}
|
||||
StrCpy $VcRedistGuid ${PY3_VC_REDIST_X64_GUID}
|
||||
${Else}
|
||||
StrCpy $VcRedistGuid ${VC_REDIST_X86_GUID}
|
||||
StrCpy $VcRedistGuid ${PY3_VC_REDIST_X86_GUID}
|
||||
${EndIf}
|
||||
StrCpy $CheckVcRedist "True"
|
||||
|
||||
${Else}
|
||||
|
||||
StrCpy $VcRedistName ${PY2_VC_REDIST_NAME}
|
||||
${If} ${CPUARCH} == "AMD64"
|
||||
StrCpy $VcRedistGuid ${PY2_VC_REDIST_X64_GUID}
|
||||
${Else}
|
||||
StrCpy $VcRedistGuid ${PY2_VC_REDIST_X86_GUID}
|
||||
${EndIf}
|
||||
|
||||
; VCRedist 2008 only needed on Windows Server 2008R2/Windows 7 and below
|
||||
${If} ${AtMostWin2008R2}
|
||||
StrCpy $CheckVcRedist "True"
|
||||
${EndIf}
|
||||
|
||||
${EndIf}
|
||||
|
||||
${If} $CheckVcRedist == "True"
|
||||
|
||||
Push $VcRedistGuid
|
||||
Call MsiQueryProductState
|
||||
${If} $NeedVcRedist == "True"
|
||||
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
|
||||
"VC Redist 2008 SP1 MFC is currently not installed. Would you like to install?" \
|
||||
"$VcRedistName is currently not installed. Would you like to install?" \
|
||||
/SD IDYES IDNO endVcRedist
|
||||
|
||||
ClearErrors
|
||||
; The Correct version of VCRedist is copied over by "build_pkg.bat"
|
||||
SetOutPath "$INSTDIR\"
|
||||
File "..\prereqs\vcredist.exe"
|
||||
ExecWait "$INSTDIR\vcredist.exe /qb!"
|
||||
; /passive used by 2015 installer
|
||||
; /qb! used by 2008 installer
|
||||
; It just ignores the unrecognized switches...
|
||||
ExecWait "$INSTDIR\vcredist.exe /qb! /passive"
|
||||
IfErrors 0 endVcRedist
|
||||
MessageBox MB_OK \
|
||||
"VC Redist 2008 SP1 MFC failed to install. Try installing the package manually." \
|
||||
"$VcRedistName failed to install. Try installing the package manually." \
|
||||
/SD IDOK
|
||||
|
||||
endVcRedist:
|
||||
|
@ -277,39 +320,26 @@ Function .onInit
|
|||
Abort
|
||||
|
||||
uninst:
|
||||
; Make sure we're in the right directory
|
||||
${If} $INSTDIR == "c:\salt\bin\Scripts"
|
||||
StrCpy $INSTDIR "C:\salt"
|
||||
|
||||
; Get current Silent status
|
||||
StrCpy $R0 0
|
||||
${If} ${Silent}
|
||||
StrCpy $R0 1
|
||||
${EndIf}
|
||||
|
||||
; Stop and remove the salt-minion service
|
||||
nsExec::Exec 'net stop salt-minion'
|
||||
nsExec::Exec 'sc delete salt-minion'
|
||||
; Turn on Silent mode
|
||||
SetSilent silent
|
||||
|
||||
; Stop and remove the salt-master service
|
||||
nsExec::Exec 'net stop salt-master'
|
||||
nsExec::Exec 'sc delete salt-master'
|
||||
; Don't remove all directories
|
||||
StrCpy $DeleteInstallDir 0
|
||||
|
||||
; Remove salt binaries and batch files
|
||||
Delete "$INSTDIR\uninst.exe"
|
||||
Delete "$INSTDIR\nssm.exe"
|
||||
Delete "$INSTDIR\salt*"
|
||||
Delete "$INSTDIR\vcredist.exe"
|
||||
RMDir /r "$INSTDIR\bin"
|
||||
; Uninstall silently
|
||||
Call uninstallSalt
|
||||
|
||||
; Remove registry entries
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY_OTHER}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_CALL_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_CP_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_KEY_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_MASTER_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_MINION_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_RUN_REGKEY}"
|
||||
|
||||
; Remove C:\salt from the Path
|
||||
Push "C:\salt"
|
||||
Call RemoveFromPath
|
||||
; Set it back to Normal mode, if that's what it was before
|
||||
${If} $R0 == 0
|
||||
SetSilent normal
|
||||
${EndIf}
|
||||
|
||||
skipUninstall:
|
||||
|
||||
|
@ -382,47 +412,92 @@ FunctionEnd
|
|||
|
||||
|
||||
Function un.onInit
|
||||
|
||||
; Load the parameters
|
||||
${GetParameters} $R0
|
||||
|
||||
# Uninstaller: Remove Installation Directory
|
||||
${GetOptions} $R0 "/delete-install-dir" $R1
|
||||
IfErrors delete_install_dir_not_found
|
||||
StrCpy $DeleteInstallDir 1
|
||||
delete_install_dir_not_found:
|
||||
|
||||
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
|
||||
"Are you sure you want to completely remove $(^Name) and all of its components?" \
|
||||
/SD IDYES IDYES +2
|
||||
Abort
|
||||
|
||||
FunctionEnd
|
||||
|
||||
|
||||
Section Uninstall
|
||||
|
||||
Call un.uninstallSalt
|
||||
|
||||
; Remove C:\salt from the Path
|
||||
Push "C:\salt"
|
||||
Call un.RemoveFromPath
|
||||
|
||||
SectionEnd
|
||||
|
||||
|
||||
!macro uninstallSalt un
|
||||
Function ${un}uninstallSalt
|
||||
|
||||
; Make sure we're in the right directory
|
||||
${If} $INSTDIR == "c:\salt\bin\Scripts"
|
||||
StrCpy $INSTDIR "C:\salt"
|
||||
${EndIf}
|
||||
|
||||
; Stop and Remove salt-minion service
|
||||
nsExec::Exec 'net stop salt-minion'
|
||||
nsExec::Exec 'sc delete salt-minion'
|
||||
|
||||
; Stop and remove the salt-master service
|
||||
nsExec::Exec 'net stop salt-master'
|
||||
nsExec::Exec 'sc delete salt-master'
|
||||
|
||||
; Remove files
|
||||
Delete "$INSTDIR\uninst.exe"
|
||||
Delete "$INSTDIR\nssm.exe"
|
||||
Delete "$INSTDIR\salt*"
|
||||
Delete "$INSTDIR\vcredist.exe"
|
||||
RMDir /r "$INSTDIR\bin"
|
||||
|
||||
; Remove salt directory, you must check to make sure you're not removing
|
||||
; the Program Files directory
|
||||
; Remove Registry entries
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY_OTHER}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_CALL_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_CP_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_KEY_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_MASTER_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_MINION_REGKEY}"
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_RUN_REGKEY}"
|
||||
|
||||
; Automatically close when finished
|
||||
SetAutoClose true
|
||||
|
||||
; Prompt to remove the Installation directory
|
||||
${IfNot} $DeleteInstallDir == 1
|
||||
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
|
||||
"Would you like to completely remove $INSTDIR and all of its contents?" \
|
||||
/SD IDNO IDNO finished
|
||||
${EndIf}
|
||||
|
||||
; Make sure you're not removing Program Files
|
||||
${If} $INSTDIR != 'Program Files'
|
||||
${AndIf} $INSTDIR != 'Program Files (x86)'
|
||||
RMDir /r "$INSTDIR"
|
||||
${EndIf}
|
||||
|
||||
; Remove Uninstall Entries
|
||||
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
|
||||
finished:
|
||||
|
||||
; Remove Commandline Entries
|
||||
DeleteRegKey HKLM "${PRODUCT_CALL_REGKEY}"
|
||||
DeleteRegKey HKLM "${PRODUCT_MINION_REGKEY}"
|
||||
FunctionEnd
|
||||
!macroend
|
||||
|
||||
; Remove C:\salt from the Path
|
||||
Push "C:\salt"
|
||||
Call un.RemoveFromPath
|
||||
|
||||
; Automatically close when finished
|
||||
SetAutoClose true
|
||||
|
||||
SectionEnd
|
||||
!insertmacro uninstallSalt ""
|
||||
!insertmacro uninstallSalt "un."
|
||||
|
||||
|
||||
Function un.onUninstSuccess
|
||||
|
@ -818,7 +893,7 @@ Function parseCommandLineSwitches
|
|||
; If start-minion was passed something, then set it
|
||||
StrCpy $StartMinion $R2
|
||||
${ElseIfNot} $R1 == ""
|
||||
; If start-service was passed something, then set it
|
||||
; If start-service was passed something, then set StartMinion to that
|
||||
StrCpy $StartMinion $R1
|
||||
${Else}
|
||||
; Otherwise default to 1
|
||||
|
|
|
@ -16,8 +16,10 @@ Function Get-Settings {
|
|||
$Settings = @{
|
||||
"SaltRepo" = "https://repo.saltstack.com/windows/dependencies"
|
||||
"SaltDir" = "C:\salt"
|
||||
"PythonDir" = "C:\Python27"
|
||||
"ScriptsDir" = "C:\Python27\Scripts"
|
||||
"Python2Dir" = "C:\Python27"
|
||||
"Scripts2Dir" = "C:\Python27\Scripts"
|
||||
"Python3Dir" = "C:\Program Files\Python35"
|
||||
"Scripts3Dir" = "C:\Program Files\Python35\Scripts"
|
||||
"DownloadDir" = "$env:Temp\DevSalt"
|
||||
}
|
||||
# The script deletes the DownLoadDir (above) for each install.
|
||||
|
@ -31,38 +33,45 @@ Function Get-Settings {
|
|||
|
||||
# Prerequisite software
|
||||
$Prerequisites = @{
|
||||
"NSIS" = "nsis-3.0b1-setup.exe"
|
||||
"VCforPython" = "VCForPython27.msi"
|
||||
"NSIS" = "nsis-3.0b1-setup.exe"
|
||||
"VCforPython" = "VCForPython27.msi"
|
||||
"VCppBuildTools" = "visualcppbuildtools_full.exe"
|
||||
}
|
||||
$ini.Add("Prerequisites", $Prerequisites)
|
||||
|
||||
# Location of programs on 64 bit Windows
|
||||
$64bitPaths = @{
|
||||
"NSISDir" = "C:\Program Files (x86)\NSIS"
|
||||
"VCforPythonDir" = "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0"
|
||||
"NSISDir" = "C:\Program Files (x86)\NSIS"
|
||||
"VCforPythonDir" = "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0"
|
||||
"VCppBuildToolsDir" = "C:\Program Files (x86)\Microsoft Visual C++ Build Tools"
|
||||
}
|
||||
$ini.Add("64bitPaths", $64bitPaths)
|
||||
|
||||
# Location of programs on 32 bit Windows
|
||||
$32bitPaths = @{
|
||||
"NSISDir" = "C:\Program Files\NSIS"
|
||||
"VCforPythonDir" = "C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0"
|
||||
"NSISDir" = "C:\Program Files\NSIS"
|
||||
"VCforPythonDir" = "C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0"
|
||||
"VCppBuildToolsDir" = "C:\Program Files\Microsoft Visual C++ Build Tools"
|
||||
}
|
||||
$ini.Add("32bitPaths", $32bitPaths)
|
||||
|
||||
# Filenames for 64 bit Windows
|
||||
$64bitPrograms = @{
|
||||
"PyCrypto" = "pycrypto-2.6.1-cp27-none-win_amd64.whl"
|
||||
"Python" = "python-2.7.12.amd64.msi"
|
||||
"PyYAML" = "PyYAML-3.11.win-amd64-py2.7.exe"
|
||||
"PyCrypto2" = "pycrypto-2.6.1-cp27-none-win_amd64.whl"
|
||||
"Python2" = "python-2.7.12.amd64.msi"
|
||||
"PyYAML2" = "PyYAML-3.11.win-amd64-py2.7.exe"
|
||||
"Python3" = "python-3.5.3-amd64.exe"
|
||||
"PyWin323" = "pywin32-220.1-cp35-cp35m-win_amd64.whl"
|
||||
}
|
||||
$ini.Add("64bitPrograms", $64bitPrograms)
|
||||
|
||||
# Filenames for 32 bit Windows
|
||||
$32bitPrograms = @{
|
||||
"PyCrypto" = "pycrypto-2.6.1-cp27-none-win32.whl"
|
||||
"Python" = "python-2.7.12.msi"
|
||||
"PyYAML" = "PyYAML-3.11.win32-py2.7.exe"
|
||||
"PyCrypto2" = "pycrypto-2.6.1-cp27-none-win32.whl"
|
||||
"Python2" = "python-2.7.12.msi"
|
||||
"PyYAML2" = "PyYAML-3.11.win32-py2.7.exe"
|
||||
"Python3" = "python-3.5.3.exe"
|
||||
"PyWin323" = "pywin32-220.1-cp35-cp35m-win32.whl"
|
||||
}
|
||||
$ini.Add("32bitPrograms", $32bitPrograms)
|
||||
|
||||
|
|
|
@ -6,17 +6,21 @@ Function Start_Process_and_test_exitcode {
|
|||
# $args - the the arguments of $fun
|
||||
# $descr - the short description shown in the case of an error
|
||||
|
||||
param(
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)] [String] $fun,
|
||||
[Parameter(Mandatory=$true)] [String] $args,
|
||||
[Parameter(Mandatory=$true)] [String] $descr
|
||||
)
|
||||
|
||||
begin {
|
||||
Begin { Write-Host "Executing Command: $fun $args" }
|
||||
|
||||
Process {
|
||||
$p = Start-Process "$fun" -ArgumentList "$args" -Wait -NoNewWindow -PassThru
|
||||
If ( $($p.ExitCode) -ne 0) {
|
||||
Write-Error "$descr returned exitcode $($p.ExitCode). "
|
||||
exit $($p.ExitCode)
|
||||
}
|
||||
}
|
||||
|
||||
End { Write-Host "Finished Executing Command: $fun $args" }
|
||||
}
|
||||
|
|
4
pkg/windows/req_2.txt
Normal file
4
pkg/windows/req_2.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
-r req_base.txt
|
||||
|
||||
lxml==3.6.0
|
||||
pypiwin32==219
|
5
pkg/windows/req_3.txt
Normal file
5
pkg/windows/req_3.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
-r req_base.txt
|
||||
|
||||
lxml==3.7.3
|
||||
pycrypto==2.6.1
|
||||
PyYAML==3.12
|
|
@ -13,7 +13,6 @@ ioloop==0.1a0
|
|||
ipaddress==1.0.16
|
||||
Jinja2==2.9.4
|
||||
libnacl==1.4.5
|
||||
lxml==3.6.0
|
||||
Mako==1.0.4
|
||||
MarkupSafe==0.23
|
||||
msgpack-python==0.4.8
|
||||
|
@ -22,7 +21,6 @@ pyasn1==0.1.9
|
|||
pycparser==2.14
|
||||
pycurl==7.43.0
|
||||
PyMySQL==0.7.6
|
||||
pypiwin32==219
|
||||
pyOpenSSL==16.1.0
|
||||
python-dateutil==2.5.3
|
||||
python-gnupg==0.3.8
|
|
@ -1,2 +1,2 @@
|
|||
pip==8.1.2
|
||||
setuptools==25.1.3
|
||||
pip==9.0.1
|
||||
setuptools==34.3.1
|
|
@ -3,7 +3,7 @@ backports.ssl-match-hostname
|
|||
certifi
|
||||
psutil
|
||||
python-dateutil
|
||||
pypiwin32
|
||||
pywin32
|
||||
pyzmq
|
||||
six
|
||||
timelib
|
||||
|
|
|
@ -1005,7 +1005,7 @@ def dacl(obj_name=None, obj_type='file'):
|
|||
None, None, self.dacl, None)
|
||||
except pywintypes.error as exc:
|
||||
raise CommandExecutionError(
|
||||
'Failed to set permissions: {0}'.format(exc[2]))
|
||||
'Failed to set permissions: {0}'.format(exc.strerror))
|
||||
|
||||
return True
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ def get_owner(obj_name):
|
|||
owner_sid = 'S-1-1-0'
|
||||
else:
|
||||
raise CommandExecutionError(
|
||||
'Failed to set permissions: {0}'.format(exc[2]))
|
||||
'Failed to set permissions: {0}'.format(exc.strerror))
|
||||
|
||||
return get_name(win32security.ConvertSidToStringSid(owner_sid))
|
||||
|
||||
|
@ -1201,7 +1201,7 @@ def get_primary_group(obj_name):
|
|||
primary_group_gid = 'S-1-1-0'
|
||||
else:
|
||||
raise CommandExecutionError(
|
||||
'Failed to set permissions: {0}'.format(exc[2]))
|
||||
'Failed to set permissions: {0}'.format(exc.strerror))
|
||||
|
||||
return get_name(win32security.ConvertSidToStringSid(primary_group_gid))
|
||||
|
||||
|
@ -1265,9 +1265,9 @@ def set_owner(obj_name, principal, obj_type='file'):
|
|||
sid,
|
||||
None, None, None)
|
||||
except pywintypes.error as exc:
|
||||
log.debug('Failed to make {0} the owner: {1}'.format(principal, exc[2]))
|
||||
log.debug('Failed to make {0} the owner: {1}'.format(principal, exc.strerror))
|
||||
raise CommandExecutionError(
|
||||
'Failed to set owner: {0}'.format(exc[2]))
|
||||
'Failed to set owner: {0}'.format(exc.strerror))
|
||||
|
||||
return True
|
||||
|
||||
|
@ -1340,9 +1340,9 @@ def set_primary_group(obj_name, principal, obj_type='file'):
|
|||
except pywintypes.error as exc:
|
||||
log.debug(
|
||||
'Failed to make {0} the primary group: {1}'
|
||||
''.format(principal, exc[2]))
|
||||
''.format(principal, exc.strerror))
|
||||
raise CommandExecutionError(
|
||||
'Failed to set primary group: {0}'.format(exc[2]))
|
||||
'Failed to set primary group: {0}'.format(exc.strerror))
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ def get_sid_from_name(name):
|
|||
sid = win32security.LookupAccountName(None, name)[0]
|
||||
except pywintypes.error as exc:
|
||||
raise CommandExecutionError(
|
||||
'User {0} found: {1}'.format(name, exc[2]))
|
||||
'User {0} found: {1}'.format(name, exc.strerror))
|
||||
|
||||
return win32security.ConvertSidToStringSid(sid)
|
||||
|
||||
|
@ -128,7 +128,7 @@ def get_current_user():
|
|||
user_name = 'SYSTEM'
|
||||
except pywintypes.error as exc:
|
||||
raise CommandExecutionError(
|
||||
'Failed to get current user: {0}'.format(exc[2]))
|
||||
'Failed to get current user: {0}'.format(exc.strerror))
|
||||
|
||||
if not user_name:
|
||||
return False
|
||||
|
|
51
setup.py
51
setup.py
|
@ -145,8 +145,8 @@ def _parse_requirements_file(requirements_file):
|
|||
if IS_WINDOWS_PLATFORM:
|
||||
if 'libcloud' in line:
|
||||
continue
|
||||
if 'pycrypto' in line.lower():
|
||||
# On windows we install PyCrypto using python wheels
|
||||
if 'pycrypto' in line.lower() and not IS_PY3:
|
||||
# On Python 2 in Windows we install PyCrypto using python wheels
|
||||
continue
|
||||
if 'm2crypto' in line.lower() and __saltstack_version__.info < (2015, 8): # pylint: disable=undefined-variable
|
||||
# In Windows, we're installing M2CryptoWin{32,64} which comes
|
||||
|
@ -314,15 +314,17 @@ if WITH_SETUPTOOLS:
|
|||
self.run_command('install-m2crypto-windows')
|
||||
self.distribution.salt_installing_m2crypto_windows = None
|
||||
|
||||
# Install PyCrypto
|
||||
self.distribution.salt_installing_pycrypto_windows = True
|
||||
self.run_command('install-pycrypto-windows')
|
||||
self.distribution.salt_installing_pycrypto_windows = None
|
||||
if not IS_PY3:
|
||||
|
||||
# Install PyYAML
|
||||
self.distribution.salt_installing_pyyaml_windows = True
|
||||
self.run_command('install-pyyaml-windows')
|
||||
self.distribution.salt_installing_pyyaml_windows = None
|
||||
# Install PyCrypto
|
||||
self.distribution.salt_installing_pycrypto_windows = True
|
||||
self.run_command('install-pycrypto-windows')
|
||||
self.distribution.salt_installing_pycrypto_windows = None
|
||||
|
||||
# Install PyYAML
|
||||
self.distribution.salt_installing_pyyaml_windows = True
|
||||
self.run_command('install-pyyaml-windows')
|
||||
self.distribution.salt_installing_pyyaml_windows = None
|
||||
|
||||
# Download the required DLLs
|
||||
self.distribution.salt_download_windows_dlls = True
|
||||
|
@ -759,14 +761,18 @@ class Install(install):
|
|||
self.distribution.salt_installing_m2crypto_windows = True
|
||||
self.run_command('install-m2crypto-windows')
|
||||
self.distribution.salt_installing_m2crypto_windows = None
|
||||
# Install PyCrypto
|
||||
self.distribution.salt_installing_pycrypto_windows = True
|
||||
self.run_command('install-pycrypto-windows')
|
||||
self.distribution.salt_installing_pycrypto_windows = None
|
||||
# Install PyYAML
|
||||
self.distribution.salt_installing_pyyaml_windows = True
|
||||
self.run_command('install-pyyaml-windows')
|
||||
self.distribution.salt_installing_pyyaml_windows = None
|
||||
|
||||
if not IS_PY3:
|
||||
# Install PyCrypto
|
||||
self.distribution.salt_installing_pycrypto_windows = True
|
||||
self.run_command('install-pycrypto-windows')
|
||||
self.distribution.salt_installing_pycrypto_windows = None
|
||||
|
||||
# Install PyYAML
|
||||
self.distribution.salt_installing_pyyaml_windows = True
|
||||
self.run_command('install-pyyaml-windows')
|
||||
self.distribution.salt_installing_pyyaml_windows = None
|
||||
|
||||
# Download the required DLLs
|
||||
self.distribution.salt_download_windows_dlls = True
|
||||
self.run_command('download-windows-dlls')
|
||||
|
@ -901,9 +907,12 @@ class SaltDistribution(distutils.dist.Distribution):
|
|||
self.cmdclass.update({'sdist': CloudSdist,
|
||||
'install_lib': InstallLib})
|
||||
if IS_WINDOWS_PLATFORM:
|
||||
self.cmdclass.update({'install-pycrypto-windows': InstallPyCryptoWindowsWheel,
|
||||
'install-pyyaml-windows': InstallCompiledPyYaml,
|
||||
'download-windows-dlls': DownloadWindowsDlls})
|
||||
if IS_PY3:
|
||||
self.cmdclass.update({'download-windows-dlls': DownloadWindowsDlls})
|
||||
else:
|
||||
self.cmdclass.update({'install-pycrypto-windows': InstallPyCryptoWindowsWheel,
|
||||
'install-pyyaml-windows': InstallCompiledPyYaml,
|
||||
'download-windows-dlls': DownloadWindowsDlls})
|
||||
if __saltstack_version__.info < (2015, 8): # pylint: disable=undefined-variable
|
||||
self.cmdclass.update({'install-m2crypto-windows': InstallM2CryptoWindows})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue