salt/pkg/windows/build.bat

133 lines
3.7 KiB
Batchfile
Raw Normal View History

2016-08-09 19:53:55 +00:00
@echo off
@echo Salt Windows Build Script, which calls the other *.ps1 scripts.
2016-08-09 20:11:45 +00:00
@echo ---------------------------------------------------------------------
2016-08-09 19:53:55 +00:00
@echo.
:: To activate caching, set environment variables
:: SALTREPO_LOCAL_CACHE for resources from saltstack.com/...
:: SALT_REQ_LOCAL_CACHE for pip resources specified in req.txt
:: SALT_PIP_LOCAL_CACHE for pip resources specified in req_pip.txt
2016-02-12 18:37:49 +00:00
:: Make sure the script is run as Admin
2016-08-09 19:53:55 +00:00
@echo Administrative permissions required. Detecting permissions...
2016-08-09 20:11:45 +00:00
@echo ---------------------------------------------------------------------
2016-02-12 18:37:49 +00:00
net session >nul 2>&1
if %errorLevel%==0 (
echo ...Success: Administrative permissions confirmed.
2016-02-12 18:37:49 +00:00
) else (
echo ...Failure: This script must be run as Administrator
2016-02-12 18:37:49 +00:00
goto eof
)
@echo =====================================================================
2016-08-09 20:11:45 +00:00
@echo.
2016-02-12 18:37:49 +00:00
@echo Git required. Detecting git...
@echo ---------------------------------------------------------------------
where git >nul 2>&1
if %errorLevel%==0 (
echo ...Success: Git found.
) else (
echo ...Failure: This script needs to call git
goto eof
)
@echo =====================================================================
@echo.
2017-03-10 21:52:38 +00:00
:: 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.
2016-02-12 18:37:49 +00:00
:: Define Variables
2016-07-06 22:18:01 +00:00
@echo %0 :: Defining Variables...
2016-08-09 20:11:45 +00:00
@echo ---------------------------------------------------------------------
2017-03-10 21:52:38 +00:00
if %Python%==2 (
Set "PyDir=C:\Python27"
) else (
Set "PyDir=C:\Program Files\Python35"
)
Set "PATH=%PATH%;%PyDir%;%PyDir%\Scripts"
2016-02-12 18:37:49 +00:00
Set "CurDir=%~dp0"
for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"
@echo =====================================================================
2016-08-09 20:11:45 +00:00
@echo.
2016-02-12 18:37:49 +00:00
:: Create Build Environment
2016-08-09 20:11:45 +00:00
@echo %0 :: Create the Build Environment...
@echo ---------------------------------------------------------------------
2017-03-10 21:52:38 +00:00
PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env_%Python%.ps1" -Silent
2016-02-12 18:37:49 +00:00
2016-07-06 22:18:01 +00:00
if not %errorLevel%==0 (
2017-03-10 21:52:38 +00:00
echo "%CurDir%build_env_%Python%.ps1" returned errorlevel %errorLevel%. Aborting %0
2016-07-06 22:18:01 +00:00
goto eof
)
2016-08-09 20:11:45 +00:00
@echo.
2016-07-06 22:18:01 +00:00
2016-02-12 18:37:49 +00:00
:: Install Current Version of salt
2016-08-09 19:53:55 +00:00
@echo %0 :: Install Current Version of salt...
2016-08-09 20:11:45 +00:00
@echo ---------------------------------------------------------------------
"%PyDir%\python.exe" "%SrcDir%\setup.py" --quiet install --force
if not %errorLevel%==0 (
goto eof
)
2016-08-09 20:11:45 +00:00
@echo.
2016-02-12 18:37:49 +00:00
:: Build the Salt Package
2016-08-09 19:53:55 +00:00
@echo %0 :: Build the Salt Package...
2016-08-09 20:11:45 +00:00
@echo ---------------------------------------------------------------------
2017-03-10 21:52:38 +00:00
call "%CurDir%build_pkg.bat" "%Version%" %Python%
2016-08-09 20:11:45 +00:00
@echo.
2016-02-12 18:37:49 +00:00
:eof
2016-08-09 20:11:45 +00:00
@echo.
@echo =====================================================================
2016-08-09 19:53:55 +00:00
@echo End of %0
2016-08-09 20:11:45 +00:00
@echo =====================================================================