1
0

build.bat 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. @echo off
  2. @echo Salt Windows Build Script, which calls the other *.ps1 scripts.
  3. @echo ---------------------------------------------------------------------
  4. @echo.
  5. :: To activate caching, set environment variables
  6. :: SALTREPO_LOCAL_CACHE for resources from saltstack.com/...
  7. :: SALT_REQ_LOCAL_CACHE for pip resources specified in req.txt
  8. :: SALT_PIP_LOCAL_CACHE for pip resources specified in req_pip.txt
  9. :: Make sure the script is run as Admin
  10. @echo Administrative permissions required. Detecting permissions...
  11. @echo ---------------------------------------------------------------------
  12. net session >nul 2>&1
  13. if %errorLevel%==0 (
  14. echo ...Success: Administrative permissions confirmed.
  15. ) else (
  16. echo ...Failure: This script must be run as Administrator
  17. goto eof
  18. )
  19. @echo =====================================================================
  20. @echo.
  21. @echo Git required. Detecting git...
  22. @echo ---------------------------------------------------------------------
  23. where git >nul 2>&1
  24. if %errorLevel%==0 (
  25. echo ...Success: Git found.
  26. ) else (
  27. echo ...Failure: This script needs to call git
  28. goto eof
  29. )
  30. @echo =====================================================================
  31. @echo.
  32. :: Get Passed Parameters
  33. @echo %0 :: Get Passed Parameters...
  34. @echo ---------------------------------------------------------------------
  35. set "Version="
  36. :: First Parameter
  37. if not "%~1"=="" (
  38. echo.%1 | FIND /I "=" > nul && (
  39. :: Named Parameter
  40. echo Named Parameter
  41. set "%~1"
  42. ) || (
  43. :: Positional Parameter
  44. echo Positional Parameter
  45. set "Version=%~1"
  46. )
  47. )
  48. :: If Version not defined, Get the version from Git
  49. if "%Version%"=="" (
  50. for /f "delims=" %%a in ('git describe') do @set "Version=%%a"
  51. )
  52. @echo =====================================================================
  53. @echo.
  54. :: Define Variables
  55. @echo %0 :: Defining Variables...
  56. @echo ---------------------------------------------------------------------
  57. Set "PyDir=C:\Python37"
  58. Set "PATH=%PATH%;%PyDir%;%PyDir%\Scripts"
  59. Set "CurDir=%~dp0"
  60. for /f "delims=" %%a in ('git rev-parse --show-toplevel') do @set "SrcDir=%%a"
  61. @echo =====================================================================
  62. @echo.
  63. :: Create Build Environment
  64. @echo %0 :: Create the Build Environment...
  65. @echo ---------------------------------------------------------------------
  66. PowerShell.exe -ExecutionPolicy RemoteSigned -File "%CurDir%build_env.ps1" -Silent
  67. if not %errorLevel%==0 (
  68. echo "%CurDir%build_env.ps1" returned errorlevel %errorLevel%. Aborting %0
  69. goto eof
  70. )
  71. @echo.
  72. :: Remove build and dist directories
  73. @echo %0 :: Remove build and dist directories...
  74. @echo ---------------------------------------------------------------------
  75. "%PyDir%\python.exe" "%SrcDir%\setup.py" clean --all
  76. if not %errorLevel%==0 (
  77. goto eof
  78. )
  79. If Exist "%SrcDir%\dist" (
  80. @echo removing %SrcDir%\dist
  81. rd /S /Q "%SrcDir%\dist"
  82. )
  83. @echo.
  84. :: Install Current Version of salt
  85. @echo %0 :: Install Current Version of salt...
  86. @echo ---------------------------------------------------------------------
  87. "%PyDir%\python.exe" "%SrcDir%\setup.py" --quiet install --force
  88. if not %errorLevel%==0 (
  89. goto eof
  90. )
  91. @echo.
  92. :: Build the Salt Package
  93. @echo %0 :: Build the Salt Package...
  94. @echo ---------------------------------------------------------------------
  95. call "%CurDir%build_pkg.bat" "%Version%"
  96. @echo.
  97. :eof
  98. @echo.
  99. @echo =====================================================================
  100. @echo End of %0
  101. @echo =====================================================================