mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fetch python tarball instead of building
This commit is contained in:
parent
c48d6c94cd
commit
1de7c34de7
21 changed files with 439 additions and 578 deletions
|
@ -58,52 +58,25 @@ param(
|
|||
# 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"
|
||||
[String] $PythonVersion = "3.8.14",
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[Alias("b")]
|
||||
# Build python from source instead of fetching a tarball
|
||||
# Requires VC Build Tools
|
||||
[Switch] $Build
|
||||
|
||||
)
|
||||
|
||||
# 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
|
||||
#-------------------------------------------------------------------------------
|
||||
$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"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -134,12 +107,12 @@ 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)
|
||||
Write-Host $("v" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Install NSIS
|
||||
#-------------------------------------------------------------------------------
|
||||
powershell -file "$SCRIPT_DIR\install_nsis.ps1"
|
||||
& "$SCRIPT_DIR\install_nsis.ps1"
|
||||
if ( ! $? ) {
|
||||
Write-Host "Failed to install NSIS"
|
||||
exit 1
|
||||
|
@ -148,7 +121,7 @@ if ( ! $? ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Install Visual Studio Build Tools
|
||||
#-------------------------------------------------------------------------------
|
||||
powershell -file "$SCRIPT_DIR\install_vs_buildtools.ps1"
|
||||
& "$SCRIPT_DIR\install_vs_buildtools.ps1"
|
||||
if ( ! $? ) {
|
||||
Write-Host "Failed to install Visual Studio Build Tools"
|
||||
exit 1
|
||||
|
@ -157,9 +130,14 @@ if ( ! $? ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Build Python
|
||||
#-------------------------------------------------------------------------------
|
||||
powershell -file "$SCRIPT_DIR\build_python.ps1" `
|
||||
-Version $PythonVersion `
|
||||
-Architecture $Architecture
|
||||
$KeywordArguments = @{
|
||||
Version = $PythonVersion
|
||||
Architecture = $Architecture
|
||||
}
|
||||
if ( $Build ) {
|
||||
$KeywordArguments["Build"] = $true
|
||||
}
|
||||
& "$SCRIPT_DIR\build_python.ps1" @KeywordArguments
|
||||
if ( ! $? ) {
|
||||
Write-Host "Failed to build Python"
|
||||
exit 1
|
||||
|
@ -168,7 +146,7 @@ if ( ! $? ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Install Salt
|
||||
#-------------------------------------------------------------------------------
|
||||
powershell -file "$SCRIPT_DIR\install_salt.ps1" -Architecture $Architecture
|
||||
& "$SCRIPT_DIR\install_salt.ps1"
|
||||
if ( ! $? ) {
|
||||
Write-Host "Failed to install Salt"
|
||||
exit 1
|
||||
|
@ -177,7 +155,7 @@ if ( ! $? ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Build Package
|
||||
#-------------------------------------------------------------------------------
|
||||
$KeywordArguments = @{Architecture = $Architecture}
|
||||
$KeywordArguments = @{}
|
||||
if ( ! [String]::IsNullOrEmpty($Version) ) {
|
||||
$KeywordArguments.Add("Version", $Version)
|
||||
}
|
||||
|
@ -189,6 +167,6 @@ if ( ! $? ) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
Write-Host $("#" * 80)
|
||||
Write-Host $("^" * 80)
|
||||
Write-Host "Build Salt $Architecture Completed" -ForegroundColor Cyan
|
||||
Write-Host $("#" * 80)
|
||||
|
|
|
@ -17,14 +17,7 @@ param(
|
|||
# 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"
|
||||
[String] $Version
|
||||
)
|
||||
|
||||
# Script Preferences
|
||||
|
@ -35,43 +28,35 @@ $ErrorActionPreference = "Stop"
|
|||
#-------------------------------------------------------------------------------
|
||||
# Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
|
||||
# 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"
|
||||
$BIN_DIR = "$SCRIPT_DIR\buildenv\bin"
|
||||
$SCRIPTS_DIR = "$BIN_DIR\Scripts"
|
||||
$PYTHON_BIN = "$SCRIPTS_DIR\python.exe"
|
||||
|
||||
# Build Variables
|
||||
$PROJECT_DIR = $(git rev-parse --show-toplevel)
|
||||
$SALT_REPO_URL = "https://github.com/saltstack/salt"
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
$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"
|
||||
$SCRIPTS_DIR = "$BUILD_DIR\Scripts"
|
||||
$PYTHON_BIN = "$SCRIPTS_DIR\python.exe"
|
||||
$BUILD_SALT_DIR = "$BUILD_DIR\Lib\site-packages\salt"
|
||||
$BUILD_CONF_DIR = "$BUILD_DIR\configs"
|
||||
$PY_VERSION = [Version]((Get-Command $PYTHON_BIN).FileVersionInfo.ProductVersion)
|
||||
$PY_VERSION = "$($PY_VERSION.Major).$($PY_VERSION.Minor)"
|
||||
$NSIS_BIN = "$( ${env:ProgramFiles(x86)} )\NSIS\makensis.exe"
|
||||
$ARCH = $(. $PYTHON_BIN -c "import platform; print(platform.architecture()[0])")
|
||||
|
||||
if ( $ARCH -eq "64bit" ) {
|
||||
$ARCH = "AMD64"
|
||||
$ARCH_X = "x64"
|
||||
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
|
||||
} else {
|
||||
$ARCH = "x86"
|
||||
$ARCH_X = "x86"
|
||||
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/32"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Verify Salt and Version
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if ( [String]::IsNullOrEmpty($Version) ) {
|
||||
$Version = $( git describe )
|
||||
$Version = $Version.Trim("v")
|
||||
$Version = $( git describe ).Trim("v")
|
||||
if ( [String]::IsNullOrEmpty($Version) ) {
|
||||
Write-Host "Failed to get version from $PROJECT_DIR"
|
||||
exit 1
|
||||
|
@ -81,10 +66,9 @@ if ( [String]::IsNullOrEmpty($Version) ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Start the Script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Build NullSoft Installer for Salt" -ForegroundColor Cyan
|
||||
Write-Host "- Architecture: $Architecture"
|
||||
Write-Host "- Architecture: $ARCH"
|
||||
Write-Host "- Salt Version: $Version"
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
|
@ -100,7 +84,7 @@ if ( Test-Path -Path "$PYTHON_BIN" ) {
|
|||
}
|
||||
|
||||
Write-Host "Verifying Salt Installation: " -NoNewline
|
||||
if ( Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe" ) {
|
||||
if ( Test-Path -Path "$BUILD_DIR\salt-minion.exe" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -108,7 +92,7 @@ if ( Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe" ) {
|
|||
}
|
||||
|
||||
Write-Host "Verifying NSIS Installation: " -NoNewline
|
||||
if ( Test-Path -Path "$NSIS_DIR\makensis.exe" ) {
|
||||
if ( Test-Path -Path "$NSIS_BIN" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -118,10 +102,10 @@ if ( Test-Path -Path "$NSIS_DIR\makensis.exe" ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Cleaning Build Environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path $BUILD_DIR_CONF ) {
|
||||
if ( Test-Path -Path $BUILD_CONF_DIR) {
|
||||
Write-Host "Removing Configs Directory: " -NoNewline
|
||||
Remove-Item -Path $BUILD_DIR_CONF -Recurse -Force
|
||||
if ( ! (Test-Path -Path $BUILD_DIR_CONF) ) {
|
||||
Remove-Item -Path $BUILD_CONF_DIR -Recurse -Force
|
||||
if ( ! (Test-Path -Path $BUILD_CONF_DIR) ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -144,9 +128,9 @@ if ( Test-Path -Path $PREREQ_DIR ) {
|
|||
# Staging the Build Environment
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Copying config files from Salt: " -NoNewline
|
||||
New-Item -Path $BUILD_DIR_CONF -ItemType Directory | Out-Null
|
||||
Copy-Item -Path "$PROJECT_DIR\conf\minion" -Destination "$BUILD_DIR_CONF"
|
||||
if ( Test-Path -Path "$BUILD_DIR_CONF\minion" ) {
|
||||
New-Item -Path $BUILD_CONF_DIR -ItemType Directory | Out-Null
|
||||
Copy-Item -Path "$PROJECT_DIR\conf\minion" -Destination "$BUILD_CONF_DIR"
|
||||
if ( Test-Path -Path "$BUILD_CONF_DIR\minion" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -154,8 +138,8 @@ if ( Test-Path -Path "$BUILD_DIR_CONF\minion" ) {
|
|||
}
|
||||
|
||||
Write-Host "Copying SSM to Bin: " -NoNewline
|
||||
Invoke-WebRequest -Uri "$SALT_DEP_URL/ssm-2.24-103-gdee49fc.exe" -OutFile "$SCRIPTS_DIR\ssm.exe"
|
||||
if ( Test-Path -Path "$SCRIPTS_DIR\ssm.exe" ) {
|
||||
Invoke-WebRequest -Uri "$SALT_DEP_URL/ssm-2.24-103-gdee49fc.exe" -OutFile "$BUILD_DIR\ssm.exe"
|
||||
if ( Test-Path -Path "$BUILD_DIR\ssm.exe" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -163,53 +147,29 @@ if ( Test-Path -Path "$SCRIPTS_DIR\ssm.exe" ) {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
Write-Host "Copying VCRedist 2013 $ARCH_X to prereqs: " -NoNewline
|
||||
$file = "vcredist_$ARCH_X`_2013.exe"
|
||||
Invoke-WebRequest -Uri "$SALT_DEP_URL/$file" -OutFile "$PREREQ_DIR\$file"
|
||||
if ( Test-Path -Path "$PREREQ_DIR\$file" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} 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 "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
|
||||
}
|
||||
Write-Host "Copying Universal C Runtimes $ARCH_X to prereqs: " -NoNewline
|
||||
$file = "ucrt_$ARCH_X.zip"
|
||||
Invoke-WebRequest -Uri "$SALT_DEP_URL/$file" -OutFile "$PREREQ_DIR\$file"
|
||||
if ( Test-Path -Path "$PREREQ_DIR\$file" ) {
|
||||
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",
|
||||
|
@ -230,31 +190,6 @@ $binaries | ForEach-Object {
|
|||
}
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove Unneeded Directories from bin dir
|
||||
#-------------------------------------------------------------------------------
|
||||
$delete = @(
|
||||
"doc",
|
||||
"share",
|
||||
"readme.rst"
|
||||
)
|
||||
Write-Host "Removing Unneeded Directories: " -NoNewline
|
||||
$delete | ForEach-Object {
|
||||
if ( Test-Path -Path "$BIN_DIR\$_" ) {
|
||||
# Use .net, the powershell function is asynchronous
|
||||
if ( (Get-Item "$BIN_DIR\$_") -is [System.IO.DirectoryInfo] ) {
|
||||
[System.IO.Directory]::Delete("$BIN_DIR\$_", $true)
|
||||
} else {
|
||||
[System.IO.File]::Delete("$BIN_DIR\$_")
|
||||
}
|
||||
if ( Test-Path -Path "$BIN_DIR\$_" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove Non-Windows Execution Modules
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -392,10 +327,10 @@ $modules = "acme",
|
|||
"zpool",
|
||||
"zypper"
|
||||
$modules | ForEach-Object {
|
||||
Remove-Item -Path "$BUILD_DIR_SALT\modules\$_*" -Recurse
|
||||
if ( Test-Path -Path "$BUILD_DIR_SALT\modules\$_*" ) {
|
||||
Remove-Item -Path "$BUILD_SALT_DIR\modules\$_*" -Recurse
|
||||
if ( Test-Path -Path "$BUILD_SALT_DIR\modules\$_*" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
Write-Host "Failed to remove: $BUILD_DIR_SALT\modules\$_"
|
||||
Write-Host "Failed to remove: $BUILD_SALT_DIR\modules\$_"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
@ -455,21 +390,21 @@ $states = "acme",
|
|||
"zfs",
|
||||
"zpool"
|
||||
$states | ForEach-Object {
|
||||
Remove-Item -Path "$BUILD_DIR_SALT\states\$_*" -Recurse
|
||||
if ( Test-Path -Path "$BUILD_DIR_SALT\states\$_*" ) {
|
||||
Remove-Item -Path "$BUILD_SALT_DIR\states\$_*" -Recurse
|
||||
if ( Test-Path -Path "$BUILD_SALT_DIR\states\$_*" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
Write-Host "Failed to remove: $BUILD_DIR_SALT\states\$_"
|
||||
Write-Host "Failed to remove: $BUILD_SALT_DIR\states\$_"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
||||
Write-Host "Removing unneeded files (.pyc, .chm): " -NoNewline
|
||||
$remove = "*.pyc",
|
||||
"__pycache__",
|
||||
$remove = "__pycache__",
|
||||
"*.pyc",
|
||||
"*.chm"
|
||||
$remove | ForEach-Object {
|
||||
$found = Get-ChildItem -Path "$BUILD_DIR_BIN\$_" -Recurse
|
||||
$found = Get-ChildItem -Path "$BUILD_DIR\$_" -Recurse
|
||||
$found | ForEach-Object {
|
||||
Remove-Item -Path "$_" -Recurse -Force
|
||||
if ( Test-Path -Path $_ ) {
|
||||
|
@ -486,15 +421,16 @@ Write-Host "Success" -ForegroundColor Green
|
|||
#-------------------------------------------------------------------------------
|
||||
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 `
|
||||
Start-Process -FilePath $NSIS_BIN `
|
||||
-ArgumentList "/DSaltVersion=$Version", `
|
||||
"/DPythonArchitecture=$Architecture", `
|
||||
"/DPythonArchitecture=$ARCH", `
|
||||
"$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
|
||||
Write-Host "Failed to find $installer_name in installer directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,14 @@ param(
|
|||
[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"
|
||||
[String] $Architecture = "x64",
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[Alias("b")]
|
||||
# Build python from source instead of fetching a tarball
|
||||
# Requires VC Build Tools
|
||||
[Switch] $Build
|
||||
|
||||
)
|
||||
|
||||
# Script Preferences
|
||||
|
@ -52,48 +59,20 @@ param(
|
|||
$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 with Relenv" -ForegroundColor Cyan
|
||||
if ( $Build ) {
|
||||
$SCRIPT_MSG = "Build Python with Relenv"
|
||||
} else {
|
||||
$SCRIPT_MSG = "Fetch Python with Relenv"
|
||||
}
|
||||
Write-Host "$SCRIPT_MSG" -ForegroundColor Cyan
|
||||
Write-Host "- Python Version: $Version"
|
||||
Write-Host "- Architecture: $Architecture"
|
||||
Write-Host "- Build: $Build"
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -137,33 +116,13 @@ Write-Host "Creating Temporary PowerShell Profile: " -NoNewline
|
|||
Write-Host "Success" -ForegroundColor Green
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Variables
|
||||
# Make sure we're not in a virtual environment
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
$RELENV_DIR = "$SCRIPT_DIR\relative-environment-for-python"
|
||||
$RELENV_URL = "https://github.com/saltstack/relative-environment-for-python"
|
||||
$BIN_DIR = "$SCRIPT_DIR\buildenv\bin"
|
||||
$SCRIPTS_DIR = "$BIN_DIR\Scripts"
|
||||
$BUILD_DIR = "${env:LOCALAPPDATA}\relenv\build"
|
||||
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies"
|
||||
|
||||
if ( $Architecture -eq "x64" ) {
|
||||
$SALT_DEP_URL = "$SALT_DEP_URL/64"
|
||||
$BUILD_DIR = "$BUILD_DIR\amd64-win"
|
||||
$ARCH = "amd64"
|
||||
} else {
|
||||
$SALT_DEP_URL = "$SALT_DEP_URL/32"
|
||||
$BUILD_DIR = "$BUILD_DIR\x86-win"
|
||||
$ARCH = "x86"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Prepping Environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$RELENV_DIR" ) {
|
||||
Write-Host "Removing existing relenv directory: " -NoNewline
|
||||
Remove-Item -Path "$RELENV_DIR" -Recurse -Force
|
||||
if ( Test-Path -Path "$RELENV_DIR" ) {
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
Write-Host "Deactivating virtual environment"
|
||||
. deactivate
|
||||
Write-Host $env:VIRTUAL_ENV
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
|
@ -171,10 +130,43 @@ if ( Test-Path -Path "$RELENV_DIR" ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( Test-Path -Path "$BIN_DIR" ) {
|
||||
Write-Host "Removing existing bin directory: " -NoNewline
|
||||
Remove-Item -Path "$BIN_DIR" -Recurse -Force
|
||||
if ( Test-Path -Path "$BIN_DIR" ) {
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
|
||||
$SCRIPTS_DIR = "$BUILD_DIR\Scripts"
|
||||
$RELENV_DIR = "${env:LOCALAPPDATA}\relenv"
|
||||
$SYS_PY_BIN = (cmd /c "where python")
|
||||
$BLD_PY_BIN = "$BUILD_DIR\Scripts\python.exe"
|
||||
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies"
|
||||
|
||||
if ( $Architecture -eq "x64" ) {
|
||||
$SALT_DEP_URL = "$SALT_DEP_URL/64"
|
||||
$ARCH = "amd64"
|
||||
} else {
|
||||
$SALT_DEP_URL = "$SALT_DEP_URL/32"
|
||||
$ARCH = "x86"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Prepping Environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Removing virtual environment directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\venv" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
if ( Test-Path -Path "$RELENV_DIR" ) {
|
||||
Write-Host "Removing existing relenv directory: " -NoNewline
|
||||
Remove-Item -Path "$RELENV_DIR" -Recurse -Force
|
||||
if ( Test-Path -Path "$RELENV_DIR" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
|
@ -194,17 +186,23 @@ if ( Test-Path -Path "$BUILD_DIR" ) {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Downloading Relenv
|
||||
# Setting Up Virtual Environment
|
||||
#-------------------------------------------------------------------------------
|
||||
# TODO: Eventually we should just download the tarball from a release, but since
|
||||
# TODO: there is no release yet, we'll just clone the directory
|
||||
|
||||
Write-Host "Cloning Relenv: " -NoNewline
|
||||
$args = "clone", "--depth", "1", "$RELENV_URL", "$RELENV_DIR"
|
||||
Start-Process -FilePath git `
|
||||
-ArgumentList $args `
|
||||
Write-Host "Installing virtual environment: " -NoNewline
|
||||
Start-Process -FilePath "$SYS_PY_BIN" `
|
||||
-ArgumentList "-m", "venv", "venv" `
|
||||
-WorkingDirectory "$SCRIPT_DIR" `
|
||||
-Wait -WindowStyle Hidden
|
||||
if ( Test-Path -Path "$RELENV_DIR\relenv") {
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Activating virtual environment: " -NoNewline
|
||||
. "$SCRIPT_DIR\venv\Scripts\activate.ps1"
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -215,7 +213,7 @@ if ( Test-Path -Path "$RELENV_DIR\relenv") {
|
|||
# Installing Relenv
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Installing Relenv: " -NoNewLine
|
||||
$output = pip install -e "$RELENV_DIR\." --disable-pip-version-check
|
||||
pip install relenv --disable-pip-version-check | Out-Null
|
||||
$output = pip list --disable-pip-version-check
|
||||
if ("relenv" -in $output.split()) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
@ -227,9 +225,14 @@ if ("relenv" -in $output.split()) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Building Python with Relenv
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Building Python with Relenv (long-running): " -NoNewLine
|
||||
$output = python -m relenv build --clean --arch $ARCH
|
||||
if ( Test-Path -Path "$BUILD_DIR\Scripts\python.exe") {
|
||||
if ( $Build ) {
|
||||
Write-Host "Building Python with Relenv (long-running): " -NoNewLine
|
||||
$output = relenv build --clean --arch $ARCH
|
||||
} else {
|
||||
Write-Host "Fetching Python with Relenv: " -NoNewLine
|
||||
relenv fetch --arch $ARCH | Out-Null
|
||||
}
|
||||
if ( Test-Path -Path "$RELENV_DIR\build\$ARCH-win.tar.xz") {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -237,22 +240,11 @@ if ( Test-Path -Path "$BUILD_DIR\Scripts\python.exe") {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Moving Python to Bin Dir
|
||||
# Extracting Python environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( !( Test-Path -Path $BIN_DIR ) ) {
|
||||
Write-Host "Creating the bin directory: " -NoNewLine
|
||||
New-Item -Path $BIN_DIR -ItemType Directory | Out-Null
|
||||
if ( Test-Path -Path $BIN_DIR ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Moving Python to bin: " -NoNewLine
|
||||
Move-Item -Path "$BUILD_DIR\*" -Destination "$BIN_DIR"
|
||||
if ( Test-Path -Path "$SCRIPTS_DIR\python.exe") {
|
||||
Write-Host "Extracting Python environment: " -NoNewLine
|
||||
relenv create --arch $ARCH "$BUILD_DIR"
|
||||
If ( Test-Path -Path "$BLD_PY_BIN" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -281,26 +273,28 @@ if ( Test-Path -Path "$SCRIPTS_DIR\ssleay32.dll" ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Removing Unneeded files from Python
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Removing Unneeded Files from Python: " -NoNewline
|
||||
$remove = "idlelib",
|
||||
"test",
|
||||
"tkinter",
|
||||
"turtledemo"
|
||||
$remove | ForEach-Object {
|
||||
Remove-Item -Path "$BIN_DIR\Lib\$_" -Recurse -Force
|
||||
if ( Test-Path -Path "$BIN_DIR\Lib\$_" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
Write-Host "Failed to remove: $BIN_DIR\Lib\$_"
|
||||
exit 1
|
||||
if ( Test-Path -Path "$BUILD_DIR\Lib\$_" ) {
|
||||
Write-Host "Removing $_`: " -NoNewline
|
||||
Remove-Item -Path "$BUILD_DIR\Lib\$_" -Recurse -Force
|
||||
if (Test-Path -Path "$BUILD_DIR\Lib\$_") {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Restoring Original Global Script Preferences
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( $CREATED_POWERSHELL_PROFILE_DIRECTORY ) {
|
||||
Write-Host "Removing PowerShell Profile Directory"
|
||||
Write-Host "Removing PowerShell Profile Directory: " -NoNewline
|
||||
Remove-Item -Path "$(Split-Path "$profile" -Parent)" -Recurse -Force
|
||||
if ( ! (Test-Path -Path "$(Split-Path "$profile" -Parent)") ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
|
@ -336,7 +330,6 @@ if ( Test-Path -Path "$profile.salt_bak" ) {
|
|||
# Finished
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("-" * 80)
|
||||
Write-Host "Build Python $Architecture with Relenv Completed" `
|
||||
-ForegroundColor Cyan
|
||||
Write-Host "Environment Location: $BIN_DIR"
|
||||
Write-Host "$SCRIPT_MSG Completed" -ForegroundColor Cyan
|
||||
Write-Host "Environment Location: $BUILD_DIR"
|
||||
Write-Host $("=" * 80)
|
||||
|
|
3
pkg/windows/clean.cmd
Normal file
3
pkg/windows/clean.cmd
Normal file
|
@ -0,0 +1,3 @@
|
|||
@ echo off
|
||||
Set "CurDir=%~dp0"
|
||||
PowerShell -ExecutionPolicy RemoteSigned -File "%CurDir%\clean.ps1" %*
|
131
pkg/windows/clean.ps1
Normal file
131
pkg/windows/clean.ps1
Normal file
|
@ -0,0 +1,131 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Clean the build environment
|
||||
|
||||
.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
|
||||
|
||||
#>
|
||||
|
||||
# Script Preferences
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Variables
|
||||
#-------------------------------------------------------------------------------
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
$RELENV_DIR = "${env:LOCALAPPDATA}\relenv"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Start the Script
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Clean Build Environment" -ForegroundColor Cyan
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Make sure we're not in a virtual environment
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
Write-Host "Deactivating virtual environment: "
|
||||
& deactivate
|
||||
Write-Host $env:VIRTUAL_ENV
|
||||
if ( $env:VIRTUAL_ENV ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove venv directory
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Removing venv directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\venv" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove build directory
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\build" ) {
|
||||
Write-Host "Removing build directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\build" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\build" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove buildenv directory
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\buildenv" ) {
|
||||
Write-Host "Removing buildenv directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\buildenv" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\buildenv" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove prereqs directory
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\prereqs" ) {
|
||||
Write-Host "Removing prereqs directory: " -NoNewline
|
||||
Remove-Item -Path "$SCRIPT_DIR\prereqs" -Recurse -Force
|
||||
if ( Test-Path -Path "$SCRIPT_DIR\prereqs" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Remove relenv local
|
||||
#-------------------------------------------------------------------------------
|
||||
if ( Test-Path -Path "$RELENV_DIR" ) {
|
||||
Write-Host "Removing relenv directory: " -NoNewline
|
||||
Remove-Item -Path "$RELENV_DIR" -Recurse -Force
|
||||
if ( Test-Path -Path "$RELENV_DIR" ) {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
} else {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Script Completed
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host $("-" * 80)
|
||||
Write-Host "Clean Build Environment Completed" -ForegroundColor Cyan
|
||||
Write-Host $("=" * 80)
|
|
@ -13,69 +13,30 @@ ready to be packaged.
|
|||
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 = "$SCRIPT_DIR\buildenv\bin"
|
||||
$PYTHON_BIN = "$SCRIPT_DIR\buildenv\bin\Scripts\python.exe"
|
||||
$SCRIPTS_DIR = "$SCRIPT_DIR\buildenv\bin\Scripts"
|
||||
$SITE_PKGS_DIR = "$PYTHON_DIR\Lib\site-packages"
|
||||
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
|
||||
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
|
||||
$SITE_PKGS_DIR = "$BUILD_DIR\Lib\site-packages"
|
||||
$SCRIPTS_DIR = "$BUILD_DIR\Scripts"
|
||||
$PYTHON_BIN = "$SCRIPTS_DIR\python.exe"
|
||||
$PY_VERSION = [Version]((Get-Command $PYTHON_BIN).FileVersionInfo.ProductVersion)
|
||||
$PY_VERSION = "$($PY_VERSION.Major).$($PY_VERSION.Minor)"
|
||||
$ARCH = $(. $PYTHON_BIN -c "import platform; print(platform.architecture()[0])")
|
||||
|
||||
# Script Variables
|
||||
$PROJECT_DIR = $(git rev-parse --show-toplevel)
|
||||
$SALT_DEPS = "$PROJECT_DIR\requirements\static\pkg\py$PY_VERSION\windows.txt"
|
||||
if ( $Architecture -eq "x64" ) {
|
||||
if ( $ARCH -eq "64bit" ) {
|
||||
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
|
||||
} else {
|
||||
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/32"
|
||||
|
@ -84,10 +45,9 @@ if ( $Architecture -eq "x64" ) {
|
|||
#-------------------------------------------------------------------------------
|
||||
# Start the Script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
Write-Host $("=" * 80)
|
||||
Write-Host "Install Salt into Python Environment" -ForegroundColor Cyan
|
||||
Write-Host "- Architecture: $Architecture"
|
||||
Write-Host "- Architecture: $ARCH"
|
||||
Write-Host $("-" * 80)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -103,25 +63,30 @@ if ( ! (Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe") ) {
|
|||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Cleaning Salt Build Environment: " -NoNewline
|
||||
# Cleaning previous builds
|
||||
$remove = "build", "dist"
|
||||
$remove | ForEach-Object {
|
||||
if ( Test-Path -Path "$PROJECT_DIR\$_" ) {
|
||||
Write-Host "Removing $_`:" -NoNewline
|
||||
Remove-Item -Path "$PROJECT_DIR\$_" -Recurse -Force
|
||||
if ( Test-Path -Path "$PROJECT_DIR\$_" ) {
|
||||
if ( ! (Test-Path -Path "$PROJECT_DIR\$_") ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
Write-Host "Failed to remove $_"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
# TODO: Do we use pip3.exe here or make a pip.exe?
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Installing dependencies
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Installing dependencies: " -NoNewline
|
||||
Start-Process -FilePath $SCRIPTS_DIR\pip3.exe `
|
||||
-ArgumentList "install", "." `
|
||||
-ArgumentList "install", "-r", "$SALT_DEPS" `
|
||||
-WorkingDirectory "$PROJECT_DIR" `
|
||||
-Wait -WindowStyle Hidden
|
||||
if ( Test-Path -Path "$SCRIPTS_DIR\salt-minion.exe" ) {
|
||||
if ( Test-Path -Path "$SCRIPTS_DIR\distro.exe" ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
|
@ -155,38 +120,49 @@ if ( ! (Test-Path -Path "$SCRIPTS_DIR\wmitest*") ) {
|
|||
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\$_*" ) {
|
||||
#-------------------------------------------------------------------------------
|
||||
# Complete PyWin32 Installation
|
||||
#-------------------------------------------------------------------------------
|
||||
# Part of the PyWin32 installation requires you to run a batch file that
|
||||
# finalizes the installation. The following performs those actions:
|
||||
|
||||
# Move DLL's to Python Root and win32
|
||||
# The dlls have to be in Python directory and the site-packages\win32 directory
|
||||
$dlls = "pythoncom38.dll",
|
||||
"pywintypes38.dll"
|
||||
$dlls | ForEach-Object {
|
||||
Write-Host "Copying $_ to Scripts: " -NoNewline
|
||||
Copy-Item "$SITE_PKGS_DIR\pywin32_system32\$_" "$SCRIPTS_DIR" -Force | Out-Null
|
||||
if ( Test-Path -Path "$SCRIPTS_DIR\$_") {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "Moving $_ to win32: " -NoNewline
|
||||
Move-Item "$SITE_PKGS_DIR\pywin32_system32\$_" "$SITE_PKGS_DIR\win32" -Force | Out-Null
|
||||
if ( Test-Path -Path "$SITE_PKGS_DIR\win32\$_" ){
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
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" "$SCRIPTS_DIR" -Force | Out-Null
|
||||
Move-Item "$SITE_PKGS_DIR\pywin32_system32\*.dll" "$SITE_PKGS_DIR\win32" -Force | Out-Null
|
||||
if ( ! ((Test-Path -Path "$SCRIPTS_DIR\pythoncom38.dll") -and (Test-Path -Path "$SCRIPTS_DIR\pythoncom38.dll")) ) {
|
||||
# Remove pywin32_system32 directory since it is now empty
|
||||
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
|
||||
}
|
||||
if ( (Test-Path -Path "$SITE_PKGS_DIR\win32\pythoncom38.dll") -and (Test-Path -Path "$SITE_PKGS_DIR\win32\pythoncom38.dll") ) {
|
||||
|
||||
# Remove PyWin32 PostInstall & testall scripts
|
||||
Write-Host "Removing pywin32 post-install 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
|
||||
|
@ -203,24 +179,49 @@ if ( Test-Path -Path "$SITE_PKGS_DIR\win32com\gen_py" ) {
|
|||
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") ) {
|
||||
#-------------------------------------------------------------------------------
|
||||
# Installing Salt
|
||||
#-------------------------------------------------------------------------------
|
||||
Write-Host "Installing Salt: " -NoNewline
|
||||
# We're setting RELENV_PIP_DIR so the binaries will be placed in the root
|
||||
try {
|
||||
$env:RELENV_PIP_DIR = "yes"
|
||||
Start-Process -FilePath $SCRIPTS_DIR\pip3.exe `
|
||||
-ArgumentList "install", "." `
|
||||
-WorkingDirectory "$PROJECT_DIR" `
|
||||
-Wait -WindowStyle Hidden
|
||||
} finally {
|
||||
Remove-Item env:\RELENV_PIP_DIR
|
||||
}
|
||||
if ( Test-Path -Path "$BUILD_DIR\salt-minion.exe" ) {
|
||||
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
|
||||
# Remove fluff
|
||||
$remove = "doc",
|
||||
"readme",
|
||||
"salt-api",
|
||||
"salt-key",
|
||||
"salt-run",
|
||||
"salt-syndic",
|
||||
"salt-unity",
|
||||
"share",
|
||||
"spm",
|
||||
"wheel"
|
||||
$remove | ForEach-Object {
|
||||
if ( Test-Path -Path "$BUILD_DIR\$_*" ) {
|
||||
Write-Host "Removing $_`: " -NoNewline
|
||||
Remove-Item -Path "$BUILD_DIR\$_*" -Recurse
|
||||
if ( ! ( Test-Path -Path "$BUILD_DIR\$_*" ) ) {
|
||||
Write-Host "Success" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
|
@ -30,20 +30,28 @@ ${StrStrAdv}
|
|||
# Required by MoveFileFolder.nsh
|
||||
!insertmacro Locate
|
||||
|
||||
# Get salt version from CLI argument /DSaltVersion
|
||||
!ifdef SaltVersion
|
||||
!define PRODUCT_VERSION "${SaltVersion}"
|
||||
!else
|
||||
!define PRODUCT_VERSION "Undefined Version"
|
||||
!endif
|
||||
|
||||
# Get architecture from CLI argument /DPythonArchitecture
|
||||
# Should be x64, AMD64, or x86
|
||||
!ifdef PythonArchitecture
|
||||
!define PYTHON_ARCHITECTURE "${PythonArchitecture}"
|
||||
!else
|
||||
# Default
|
||||
!define PYTHON_ARCHITECTURE "x64"
|
||||
!endif
|
||||
|
||||
|
||||
# x64 and AMD64 are AMD64, all others are x86
|
||||
!if "${PYTHON_ARCHITECTURE}" == "x64"
|
||||
!define CPUARCH "AMD64"
|
||||
!else if "${PYTHON_ARCHITECTURE}" == "AMD64"
|
||||
!define CPUARCH "AMD64"
|
||||
!else
|
||||
!define CPUARCH "x86"
|
||||
!endif
|
||||
|
@ -568,9 +576,9 @@ Section -install_ucrt
|
|||
|
||||
ClearErrors
|
||||
|
||||
detailPrint "Unzipping UCRT dll files to $INSTDIR\bin\Scripts"
|
||||
CreateDirectory $INSTDIR\bin\Scripts
|
||||
nsisunz::UnzipToLog "$PLUGINSDIR\$UcrtFileName" "$INSTDIR\bin\Scripts"
|
||||
detailPrint "Unzipping UCRT dll files to $INSTDIR\Scripts"
|
||||
CreateDirectory $INSTDIR\Scripts
|
||||
nsisunz::UnzipToLog "$PLUGINSDIR\$UcrtFileName" "$INSTDIR\Scripts"
|
||||
|
||||
# Clean up the stack
|
||||
Pop $R0 # Get Error
|
||||
|
@ -932,10 +940,10 @@ Section -Post
|
|||
"EstimatedSize" "$0"
|
||||
|
||||
# Write Commandline Registry Entries
|
||||
WriteRegStr HKLM "${PRODUCT_CALL_REGKEY}" "" "$INSTDIR\salt-call.bat"
|
||||
WriteRegStr HKLM "${PRODUCT_CALL_REGKEY}" "Path" "$INSTDIR\bin\Scripts\"
|
||||
WriteRegStr HKLM "${PRODUCT_MINION_REGKEY}" "" "$INSTDIR\salt-minion.bat"
|
||||
WriteRegStr HKLM "${PRODUCT_MINION_REGKEY}" "Path" "$INSTDIR\bin\Scripts\"
|
||||
WriteRegStr HKLM "${PRODUCT_CALL_REGKEY}" "" "$INSTDIR\salt-call.exe"
|
||||
WriteRegStr HKLM "${PRODUCT_CALL_REGKEY}" "Path" "$INSTDIR\"
|
||||
WriteRegStr HKLM "${PRODUCT_MINION_REGKEY}" "" "$INSTDIR\salt-minion.exe"
|
||||
WriteRegStr HKLM "${PRODUCT_MINION_REGKEY}" "Path" "$INSTDIR\"
|
||||
|
||||
# Write Salt Configuration Registry Entries
|
||||
# We want to write EXPAND_SZ string types to allow us to use environment
|
||||
|
@ -970,12 +978,12 @@ Section -Post
|
|||
SetRegView 32 # Set it back to the 32 bit portion of the registry
|
||||
|
||||
# Register the Salt-Minion Service
|
||||
nsExec::Exec `$INSTDIR\bin\Scripts\ssm.exe install salt-minion "$INSTDIR\bin\Scripts\salt-minion.exe" -c """$RootDir\conf""" -l quiet`
|
||||
nsExec::Exec "$INSTDIR\bin\Scripts\ssm.exe set salt-minion Description Salt Minion from saltstack.com"
|
||||
nsExec::Exec "$INSTDIR\bin\Scripts\ssm.exe set salt-minion Start SERVICE_AUTO_START"
|
||||
nsExec::Exec "$INSTDIR\bin\Scripts\ssm.exe set salt-minion AppStopMethodConsole 24000"
|
||||
nsExec::Exec "$INSTDIR\bin\Scripts\ssm.exe set salt-minion AppStopMethodWindow 2000"
|
||||
nsExec::Exec "$INSTDIR\bin\Scripts\ssm.exe set salt-minion AppRestartDelay 60000"
|
||||
nsExec::Exec `$INSTDIR\ssm.exe install salt-minion "$INSTDIR\salt-minion.exe" -c """$RootDir\conf""" -l quiet`
|
||||
nsExec::Exec "$INSTDIR\ssm.exe set salt-minion Description Salt Minion from saltstack.com"
|
||||
nsExec::Exec "$INSTDIR\ssm.exe set salt-minion Start SERVICE_AUTO_START"
|
||||
nsExec::Exec "$INSTDIR\ssm.exe set salt-minion AppStopMethodConsole 24000"
|
||||
nsExec::Exec "$INSTDIR\ssm.exe set salt-minion AppStopMethodWindow 2000"
|
||||
nsExec::Exec "$INSTDIR\ssm.exe set salt-minion AppRestartDelay 60000"
|
||||
|
||||
# There is a default minion config laid down in the $INSTDIR directory
|
||||
${Switch} $ConfigType
|
||||
|
@ -1009,7 +1017,7 @@ Function .onInstSuccess
|
|||
|
||||
# If StartMinionDelayed is 1, then set the service to start delayed
|
||||
${If} $StartMinionDelayed == 1
|
||||
nsExec::Exec "$INSTDIR\bin\Scripts\ssm.exe set salt-minion Start SERVICE_DELAYED_AUTO_START"
|
||||
nsExec::Exec "$INSTDIR\ssm.exe set salt-minion Start SERVICE_DELAYED_AUTO_START"
|
||||
${EndIf}
|
||||
|
||||
# If start-minion is 1, then start the service
|
||||
|
@ -1049,18 +1057,18 @@ Function ${un}uninstallSalt
|
|||
|
||||
# WARNING: Any changes made here need to be reflected in the MSI uninstaller
|
||||
# Make sure we're in the right directory
|
||||
${If} $INSTDIR == "c:\salt\bin\Scripts"
|
||||
${If} $INSTDIR == "c:\salt\Scripts"
|
||||
StrCpy $INSTDIR "C:\salt"
|
||||
${EndIf}
|
||||
# $ProgramFiles is different depending on the CPU Architecture
|
||||
# https://nsis.sourceforge.io/Reference/$PROGRAMFILES
|
||||
# x86 : C:\Program Files
|
||||
# x64 : C:\Program Files (x86)
|
||||
${If} $INSTDIR == "$ProgramFiles\Salt Project\Salt\bin\Scripts"
|
||||
${If} $INSTDIR == "$ProgramFiles\Salt Project\Salt\Scripts"
|
||||
StrCpy $INSTDIR "$ProgramFiles\Salt Project\Salt"
|
||||
${EndIf}
|
||||
# $ProgramFiles64 is the C:\Program Files directory
|
||||
${If} $INSTDIR == "$ProgramFiles64\Salt Project\Salt\bin\Scripts"
|
||||
${If} $INSTDIR == "$ProgramFiles64\Salt Project\Salt\Scripts"
|
||||
StrCpy $INSTDIR "$ProgramFiles64\Salt Project\Salt"
|
||||
${EndIf}
|
||||
|
||||
|
@ -1099,7 +1107,11 @@ Function ${un}uninstallSalt
|
|||
Delete "$INSTDIR\ssm.exe"
|
||||
Delete "$INSTDIR\salt*"
|
||||
Delete "$INSTDIR\vcredist.exe"
|
||||
RMDir /r "$INSTDIR\bin"
|
||||
RMDir /r "$INSTDIR\DLLs"
|
||||
RMDir /r "$INSTDIR\Include"
|
||||
RMDir /r "$INSTDIR\Lib"
|
||||
RMDir /r "$INSTDIR\libs"
|
||||
RMDir /r "$INSTDIR\Scripts"
|
||||
|
||||
# Remove everything in the 64 bit registry
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
# Powershell supports only TLS 1.0 by default. Add support up to TLS 1.2
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'
|
||||
|
||||
Function DownloadFileWithProgress {
|
||||
|
||||
# This function downloads the passed file and shows a progress bar
|
||||
# It receives two parameters:
|
||||
# $url - the file source
|
||||
# $localfile - the file destination on the local machine
|
||||
|
||||
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
|
||||
$Global:downloadComplete = $false
|
||||
$eventDataComplete = Register-ObjectEvent $client DownloadFileCompleted `
|
||||
-SourceIdentifier WebClient.DownloadFileComplete `
|
||||
-Action {$Global:downloadComplete = $true}
|
||||
$eventDataProgress = Register-ObjectEvent $client DownloadProgressChanged `
|
||||
-SourceIdentifier WebClient.DownloadProgressChanged `
|
||||
-Action { $Global:DPCEventArgs = $EventArgs }
|
||||
}
|
||||
|
||||
process {
|
||||
Write-Progress -Activity 'Downloading file' -Status $url
|
||||
$client.DownloadFileAsync($url, $localFile)
|
||||
|
||||
while (!($Global:downloadComplete)) {
|
||||
$pc = $Global:DPCEventArgs.ProgressPercentage
|
||||
if ($pc -ne $null) {
|
||||
Write-Progress -Activity 'Downloading file' -Status $url -PercentComplete $pc
|
||||
}
|
||||
}
|
||||
Write-Progress -Activity 'Downloading file' -Status $url -Complete
|
||||
}
|
||||
|
||||
end {
|
||||
Unregister-Event -SourceIdentifier WebClient.DownloadProgressChanged
|
||||
Unregister-Event -SourceIdentifier WebClient.DownloadFileComplete
|
||||
$client.Dispose()
|
||||
$Global:downloadComplete = $null
|
||||
$Global:DPCEventArgs = $null
|
||||
Remove-Variable client
|
||||
Remove-Variable eventDataComplete
|
||||
Remove-Variable eventDataProgress
|
||||
[GC]::Collect()
|
||||
# 2016-07-06 mkr Errorchecking added. nice-to-have: integration into the above code.
|
||||
If (!((Test-Path "$localfile") -and ((Get-Item "$localfile").length -gt 0kb))) {
|
||||
Write-Error "Exiting because download missing or zero-length: $localfile"
|
||||
exit 2
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
Function Get-Settings {
|
||||
# Contains Settings used by the installer scripts
|
||||
Write-Verbose "$($MyInvocation.MyCommand.Name):: Loading Settings"
|
||||
|
||||
$ini = @{}
|
||||
|
||||
# Gets the project directory
|
||||
$env:ProjDir = $(git rev-parse --show-toplevel).Replace("/", "\")
|
||||
|
||||
# Source dir should be next to the project dir
|
||||
$env:SrcDir = "$($env:ProjDir | Split-Path)\salt"
|
||||
|
||||
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 = @{
|
||||
"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"
|
||||
}
|
||||
|
||||
$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
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
Function Start_Process_and_test_exitcode {
|
||||
|
||||
# This function is a wrapper for Start-Process that checks the exitcode
|
||||
# It receives 3 parameters:
|
||||
# $fun - the process that shall be started
|
||||
# $args - the arguments of $fun
|
||||
# $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
|
||||
)
|
||||
|
||||
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" }
|
||||
}
|
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 137 KiB |
Loading…
Add table
Reference in a new issue