mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #31173 from twangboy/win_build
Move build files to salt/pkg/windows
This commit is contained in:
commit
6ec92714cb
37
pkg/windows/build.bat
Normal file
37
pkg/windows/build.bat
Normal file
@ -0,0 +1,37 @@
|
||||
@ echo off
|
||||
@ echo Salt Windows Build Script
|
||||
@ echo.
|
||||
|
||||
:: Make sure the script is run as Admin
|
||||
@ echo Administrative permissions required. Detecting permissions...
|
||||
net session >nul 2>&1
|
||||
if %errorLevel%==0 (
|
||||
echo Success: Administrative permissions confirmed.
|
||||
) else (
|
||||
echo Failure: This script must be run as Administrator
|
||||
goto eof
|
||||
)
|
||||
|
||||
:: Define Variables
|
||||
@echo Defining Variables...
|
||||
@echo ---------------------
|
||||
Set "PyDir=C:\Python27"
|
||||
Set "CurDir=%~dp0"
|
||||
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"
|
||||
|
||||
if [%1]==[] (
|
||||
for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
|
||||
) else (
|
||||
set "Version=%~1"
|
||||
)
|
||||
|
||||
:: Create Build Environment
|
||||
cmd /c powershell -ExecutionPolicy RemoteSigned -File "%CurDir%build_env.ps1" -Silent
|
||||
|
||||
:: Install Current Version of salt
|
||||
cmd /c "%PyDir%\python.exe %SrcDir%\setup.py" install --force
|
||||
|
||||
:: Build the Salt Package
|
||||
call "%CurDir%build_pkg.bat" "%Version%"
|
||||
|
||||
:eof
|
250
pkg/windows/build_env.ps1
Normal file
250
pkg/windows/build_env.ps1
Normal file
@ -0,0 +1,250 @@
|
||||
#==============================================================================
|
||||
# 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
|
||||
)
|
||||
|
||||
Clear-Host
|
||||
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
|
||||
|
||||
#==============================================================================
|
||||
# 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
|
||||
|
||||
#==============================================================================
|
||||
# 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']['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
|
||||
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Install Python
|
||||
#------------------------------------------------------------------------------
|
||||
Write-Output " - Downloading $($ini[$bitPrograms]['Python']) . . ."
|
||||
$file = "$($ini[$bitPrograms]['Python'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
Write-Output " - Installing $($ini[$bitPrograms]['Python']) . . ."
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$($ini[$bitPrograms]['Python'])"
|
||||
$p = Start-Process msiexec -ArgumentList "/i $file /qb ADDLOCAL=DefaultFeature,Extensions,pip_feature,PrependPath TARGETDIR=$($ini['Settings']['PythonDir'])" -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']['ScriptsDir'])".ToLower()))) {
|
||||
$newPath = "$($ini['Settings']['ScriptsDir']);$Path"
|
||||
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
|
||||
$env:Path = $newPath
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# update pip and easy_install
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - Updating pip and easy_install . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
$p = Start-Process "$($ini['Settings']['PythonDir'])\python.exe" -ArgumentList "-m pip --no-cache-dir install -r $($script_path)\req_pip.txt" -Wait -NoNewWindow -PassThru
|
||||
|
||||
#==============================================================================
|
||||
# Install pypi resources using pip
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - Installing additional prereqs . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
$p = Start-Process "$($ini['Settings']['ScriptsDir'])\pip.exe" -ArgumentList "--no-cache-dir install -r $($script_path)\req.txt" -Wait -NoNewWindow -PassThru
|
||||
|
||||
#==============================================================================
|
||||
# Install PyCrypto from wheel file
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - Installing PyCrypto . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
# Download
|
||||
$file = "$($ini[$bitPrograms]['PyCrypto'])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$bitFolder/$file"
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
|
||||
# Install
|
||||
$file = "$($ini['Settings']['DownloadDir'])\$($ini[$bitPrograms]['PyCrypto'])"
|
||||
$file = dir "$($file)"
|
||||
$p = Start-Process "$($ini['Settings']['ScriptsDir'])\pip.exe" -ArgumentList "install --no-index --find-links=$($ini['Settings']['DownloadDir']) $file " -Wait -NoNewWindow -PassThru
|
||||
|
||||
#==============================================================================
|
||||
# Copy DLLs to Python Directory
|
||||
#==============================================================================
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output " - Copying DLLs . . ."
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
ForEach ($key in $ini['CommonDLLs'].Keys) {
|
||||
If ($arrInstalled -notcontains $key) {
|
||||
Write-Output " - $key . . ."
|
||||
$file = "$($ini['CommonDLLs'][$key])"
|
||||
$url = "$($ini['Settings']['SaltRepo'])/$file"
|
||||
$file = "$($ini['Settings']['PythonDir'])\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
}
|
||||
}
|
||||
|
||||
# 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']['PythonDir'])\$file"
|
||||
DownloadFileWithProgress $url $file
|
||||
}
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Script complete
|
||||
#------------------------------------------------------------------------------
|
||||
Write-Output "================================================================="
|
||||
Write-Output "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 " - Cleaning up downloaded files"
|
||||
Write-Output " ----------------------------------------------------------------"
|
||||
Write-Output ""
|
||||
Remove-Item $($ini['Settings']['DownloadDir']) -Force -Recurse
|
@ -1,5 +1,5 @@
|
||||
@ echo off
|
||||
@ echo Salt Windows Build Script
|
||||
@ echo Salt Windows Build Package Script
|
||||
@ echo.
|
||||
|
||||
:: Define Variables
|
52
pkg/windows/modules/download-module.psm1
Normal file
52
pkg/windows/modules/download-module.psm1
Normal file
@ -0,0 +1,52 @@
|
||||
Function DownloadFileWithProgress {
|
||||
|
||||
# Code for this function borrowed from http://poshcode.org/2461
|
||||
# Thanks Crazy Dave
|
||||
|
||||
# This function downloads the passed file and shows a progress bar
|
||||
# It receives two parameters:
|
||||
# $url - the file source
|
||||
# $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 {
|
||||
$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()
|
||||
}
|
||||
}
|
85
pkg/windows/modules/get-settings.psm1
Normal file
85
pkg/windows/modules/get-settings.psm1
Normal file
@ -0,0 +1,85 @@
|
||||
Function Get-Settings {
|
||||
|
||||
[CmdletBinding()]
|
||||
Param()
|
||||
|
||||
Begin
|
||||
{Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started"}
|
||||
|
||||
Process
|
||||
{
|
||||
Write-Verbose "$($MyInvocation.MyCommand.Name):: Loading Settings"
|
||||
|
||||
$ini = @{}
|
||||
|
||||
# Location where the files are kept
|
||||
$Settings = @{
|
||||
"SaltRepo" = "https://repo.saltstack.com/windows/dependencies"
|
||||
"SaltDir" = "C:\salt"
|
||||
"PythonDir" = "C:\Python27"
|
||||
"ScriptsDir" = "C:\Python27\Scripts"
|
||||
"DownloadDir" = "$env:Temp\DevSalt"
|
||||
}
|
||||
$ini.Add("Settings", $Settings)
|
||||
|
||||
# Prerequisite software
|
||||
$Prerequisites = @{
|
||||
"Git" = "Git-1.9.5-preview20141217.exe"
|
||||
"NSIS" = "nsis-3.0b1-setup.exe"
|
||||
}
|
||||
$ini.Add("Prerequisites", $Prerequisites)
|
||||
|
||||
# Location of programs on 64 bit Windows
|
||||
$64bitPaths = @{
|
||||
"NSISDir" = "C:\Program Files (x86)\NSIS"
|
||||
}
|
||||
$ini.Add("64bitPaths", $64bitPaths)
|
||||
|
||||
# Location of programs on 32 bit Windows
|
||||
$32bitPaths = @{
|
||||
"NSISDir" = "C:\Program Files\NSIS"
|
||||
}
|
||||
$ini.Add("32bitPaths", $32bitPaths)
|
||||
|
||||
# Filenames for 64 bit Windows
|
||||
$64bitPrograms = @{
|
||||
"PyCrypto" = "pycrypto-2.6.1-cp27-none-win_amd64.whl"
|
||||
"Python" = "python-2.7.11.amd64.msi"
|
||||
}
|
||||
$ini.Add("64bitPrograms", $64bitPrograms)
|
||||
|
||||
# Filenames for 32 bit Windows
|
||||
$32bitPrograms = @{
|
||||
"PyCrypto" = "pycrypto-2.6.1-cp27-none-win32.whl"
|
||||
"Python" = "python-2.7.11.msi"
|
||||
}
|
||||
$ini.Add("32bitPrograms", $32bitPrograms)
|
||||
|
||||
# CPU Architecture Independent DLL's
|
||||
$CommonDLLs = @{
|
||||
"libsodium" = "libsodium-13.dll"
|
||||
}
|
||||
$ini.Add("CommonDLLs", $CommonDLLs)
|
||||
|
||||
# DLL's for 64 bit Windows
|
||||
$64bitDLLs = @{
|
||||
"Libeay" = "libeay32.dll"
|
||||
"SSLeay" = "ssleay32.dll"
|
||||
"OpenSSLLic" = "OpenSSL_License.txt"
|
||||
}
|
||||
$ini.Add("64bitDLLs", $64bitDLLs)
|
||||
|
||||
# DLL's for 32 bit Windows
|
||||
$32bitDLLs = @{
|
||||
"Libeay" = "libeay32.dll"
|
||||
"SSLeay" = "ssleay32.dll"
|
||||
"OpenSSLLic" = "OpenSSL_License.txt"
|
||||
}
|
||||
$ini.Add("32bitDLLs", $32bitDLLs)
|
||||
|
||||
Write-Verbose "$($MyInvocation.MyCommand.Name):: Finished Loading Settings"
|
||||
Return $ini
|
||||
}
|
||||
End
|
||||
{Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended"}
|
||||
}
|
12
pkg/windows/modules/uac-module.psm1
Normal file
12
pkg/windows/modules/uac-module.psm1
Normal file
@ -0,0 +1,12 @@
|
||||
function Get-IsAdministrator
|
||||
{
|
||||
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$Principal = New-Object System.Security.Principal.WindowsPrincipal($Identity)
|
||||
$Principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
}
|
||||
|
||||
|
||||
function Get-IsUacEnabled
|
||||
{
|
||||
(Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System).EnableLua -ne 0
|
||||
}
|
22
pkg/windows/modules/zip-module.psm1
Normal file
22
pkg/windows/modules/zip-module.psm1
Normal file
@ -0,0 +1,22 @@
|
||||
Function Expand-ZipFile($zipfile, $destination) {
|
||||
|
||||
# This function unzips a zip file
|
||||
# Code obtained from:
|
||||
# http://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/
|
||||
|
||||
# Create a new directory if it doesn't exist
|
||||
If (!(Test-Path -Path $destination)) {
|
||||
$p = New-Item -ItemType directory -Path $destination
|
||||
}
|
||||
|
||||
# Define Objects
|
||||
$objShell = New-Object -Com Shell.Application
|
||||
|
||||
# Open the zip file
|
||||
$objZip = $objShell.NameSpace($zipfile)
|
||||
|
||||
# Unzip each item in the zip file
|
||||
ForEach($item in $objZip.Items()) {
|
||||
$objShell.Namespace($destination).CopyHere($item, 0x14)
|
||||
}
|
||||
}
|
31
pkg/windows/req.txt
Normal file
31
pkg/windows/req.txt
Normal file
@ -0,0 +1,31 @@
|
||||
backports-abc==0.4
|
||||
backports.ssl-match-hostname==3.5.0.1
|
||||
certifi
|
||||
cffi==1.5.0
|
||||
CherryPy==5.0.1
|
||||
futures==3.0.4
|
||||
gitdb==0.6.4
|
||||
GitPython==1.0.1
|
||||
idna==2.0
|
||||
ioflo==1.5.0
|
||||
ioloop==0.1a0
|
||||
Jinja2==2.8
|
||||
libnacl==1.4.4
|
||||
Mako==1.0.3
|
||||
MarkupSafe==0.23
|
||||
msgpack-python==0.4.7
|
||||
psutil==3.4.2
|
||||
pycparser==2.14
|
||||
PyMySQL==0.7.1
|
||||
pypiwin32==219
|
||||
python-dateutil==2.4.2
|
||||
python-gnupg==0.3.8
|
||||
PyYAML==3.11
|
||||
pyzmq==15.2.0
|
||||
requests==2.9.1
|
||||
singledispatch==3.4.0.3
|
||||
six==1.10.0
|
||||
smmap==0.9.0
|
||||
tornado==4.3
|
||||
wheel==0.26.0
|
||||
WMI==1.4.9
|
2
pkg/windows/req_pip.txt
Normal file
2
pkg/windows/req_pip.txt
Normal file
@ -0,0 +1,2 @@
|
||||
pip==8.0.2
|
||||
setuptools==20.0
|
Loading…
Reference in New Issue
Block a user