Batch script for downloading MinGW

Batch script for downloading MinGW

The script allows for a specific version of MniGW to be downloaded.
This is useful for testing compilation of the project using MinGW on
Windows build servers

error: pathspec 'mingw.cmd' did not match any file(s) known to git

--- mingw.cmd
+++ mingw.cmd
@@ -0,0 +1,879 @@
+:: Make sure the extensions are enabled
+@verify other 2>nul
+@setlocal EnableExtensions EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :print_usage "Failed to enable extensions"
+  @exit /b 1
+)
+
+::Change the code page to unicode
+@chcp 65001 1>nul 2>nul
+@if errorlevel 1 (
+  @call :print_usage "Failed to change the code page to unicode"
+  @exit /b 1
+)
+
+:: Set up some global variables
+@set "script_name=%~nx0"
+@set "script_folder=%~dp0"
+@set "script_folder=%script_folder:~0,-1%"
+@set "dependency_path=%TEMP%\mingw-build-dependencies"
+
+:: Check the command line parameters
+@set logging_level=1
+:options_loop
+@if [%1] == [] goto :options_parsed
+@set "arg=%~1"
+@set one=%arg:~0,1%
+@set two=%arg:~0,2%
+@set three=%arg:~0,3%
+@if /i [%arg%] == [/?] (
+  @call :print_usage "Downloads a specific version of MinGW"
+  @exit /b 0
+)
+@if /i [%arg%] == [/q] set quiet=true
+@if /i [%two%] == [/v] @if /i not [%three%] == [/ve] @call :verbosity "!arg!"
+@if /i [%arg%] == [/version] set "version=%~2" & shift
+@if /i [%arg%] == [/arch] set "arch=%~2" & shift
+@if /i [%arg%] == [/exceptions] set "exceptions=%~2" & shift
+@if /i [%arg%] == [/threading] set "threading=%~2" & shift
+@if /i [%arg%] == [/revision] set "revision=%~2" & shift
+@if /i not [!one!] == [/] (
+  if not defined output_path (
+    set output_path=!arg!
+  ) else (
+    @call :print_usage "Too many output locations: !output_path! !arg!" ^
+                       "There should only be one output location"
+    @exit /b 1
+  )
+)
+@shift
+@goto :options_loop
+:options_parsed
+@if defined quiet set logging_level=0
+@if not defined output_path set "output_path=%script_folder%\mingw-builds"
+@set "output_path=%output_path:/=\%"
+
+:: Set up the logging
+@set "log_folder=%output_path%\logs"
+@call :iso8601 timestamp
+@set "log_path=%log_folder%\%timestamp%.log"
+@set log_keep=10
+
+:: Get default architecture
+@if not defined arch @call :architecture arch
+
+:: Only keep a certain amount of logs
+@set /a "log_keep=log_keep-1"
+@if not exist %log_folder% @mkdir %log_folder%
+@for /f "skip=%log_keep%" %%f in ('dir /b /o-D /tc %log_folder%') do @(
+  @call :log 4 "Removing old log file %log_folder%\%%f"
+  del %log_folder%\%%f
+)
+
+:: Set up some more global variables
+@call :windows_version win_ver win_ver_major win_ver_minor win_ver_rev
+@call :script_source script_source
+@if [%script_source%] == [explorer] (
+  set /a "logging_level=logging_level+1"
+)
+
+:: Execute the main function
+@call :main "%arch%" "%version%" "%threading%" "%exceptions%" "%revision%"
+@if errorlevel 1 (
+  @call :log 0 "Failed to download MinGW"
+  @call :log 0 "View the log at %log_path%"
+  @exit /b 1
+)
+
+:: Stop the script if the user double clicked
+@if [%script_source%] == [explorer] (
+  pause
+)
+
+@endlocal
+@goto :eof
+
+:: -------------------------- Functions start here ----------------------------
+
+:main - Main function that performs the download
+:: %1 - Target architecture
+:: %2 - Version of MinGW to get [optional]
+:: %3 - Threading model [optional]
+:: %4 - Exception model [optional]
+:: %5 - Package revision [optional]
+@setlocal
+@call :log 6
+@call :log 2 "Welcome to the MinGW download script"
+@call :log 6 "------------------------------------"
+@call :log 6
+@call :log 2 "This script downloads a specific version of MinGW"
+@set "arch=%~1"
+@if "%arch%" == "" @exit /b 1
+@set "version=%~2"
+@set "threading=%~3"
+@set "exceptions=%~4"
+@set "revision=%~5"
+@call :log 3 "arch       = %arch%"
+@call :log 3 "version    = %version%"
+@call :log 3 "exceptions = %exceptions%"
+@call :log 3 "threading  = %threading%"
+@call :log 3 "revision   = %revision%"
+@call :repository repo
+@if errorlevel 1 (
+  @call :log 0 "Failed to get the MinGW-builds repository information"
+  @exit /b 1
+)
+@call :resolve slug url "%repo%" "%arch%" "%version%" "%threading%" "%exceptions%" "%revision%"
+@if errorlevel 1 (
+  @call :log 0 "Failed to resolve the correct URL of MinGW"
+  @exit /b 1
+)
+@call :unpack compiler_path "%url%" "%output_path%\mingw\%slug%"
+@if errorlevel 1 (
+  @call :log 0 "Failed to unpack the MinGW archive"
+  @exit /b 1
+)
+@rmdir /s /q "%dependency_path%"
+@echo.%compiler_path%
+@endlocal
+@goto :eof
+
+:repository - Gets the MinGW-builds repository
+:: %1 - The return variable for the repository file path
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@call :log 7
+@call :log 2 "Getting MinGW repository information"
+@set "url=http://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Personal Builds/mingw-builds/installer/repository.txt"
+@call :log 6
+@call :log 1 "Downloading MinGW repository"
+@set "file_path=%dependency_path%\mingw-repository.txt"
+@call :download "%url%" "%file_path%"
+@if errorlevel 1 (
+  @call :log 0 "Failed to download the MinGW repository information"
+  @exit /b 1
+)
+@set "repository_path=%dependency_path%\repository.txt"
+@del "%repository_path%" 2>nul
+@for /f "delims=| tokens=1-6,*" %%a in (%file_path%) do @(
+  @set "version=%%~a"
+  @set "version=!version: =!"
+  @set "arch=%%~b"
+  @set "arch=!arch: =!"
+  @set "threading=%%~c"
+  @set "threading=!threading: =!"
+  @set "exceptions=%%~d"
+  @set "exceptions=!exceptions: =!"
+  @set "revision=%%~e"
+  @set "revision=!revision: =!"
+  @set "revision=!revision:rev=!"
+  @set "url=%%~f"
+  @set "url=!url:%%20= !"
+  @for /l %%a in (1,1,32) do @if "!url:~-1!" == " " set url=!url:~0,-1!
+  @echo !arch!^|!version!^|!threading!^|!exceptions!^|!revision!^|!url!>> "%repository_path%"
+)
+@del "%file_path%" 2>nul
+@endlocal & set "%var%=%repository_path%"
+@goto :eof
+
+:resolve - Gets the MinGW-builds repository
+:: %1 - The return variable for the MinGW slug
+:: %2 - The return variable for the MinGW URL
+:: %3 - The repository information to use
+:: %4 - Target architecture
+:: %5 - Version of MinGW to get [optional]
+:: %6 - Threading model [optional]
+:: %7 - Exception model [optional]
+:: %8 - Package revision [optional]
+@setlocal
+@set "slug_var=%~1"
+@if "%slug_var%" == "" @exit /b 1
+@set "url_var=%~2"
+@if "%url_var%" == "" @exit /b 1
+@set "repository=%~3"
+@if "%repository%" == "" @exit /b 1
+@set "arch=%~4"
+@if "%arch%" == "" @exit /b 1
+@call :resolve_version version "%repository%" "%arch%" "%~5"
+@if errorlevel 1 @exit /b 1
+@call :resolve_threading threading "%repository%" "%arch%" "%version%" "%~6"
+@if errorlevel 1 @exit /b 1
+@call :resolve_exceptions exceptions "%repository%" "%arch%" "%version%" "%threading%" "%~7"
+@if errorlevel 1 @exit /b 1
+@call :resolve_revision revision "%repository%" "%arch%" "%version%" "%threading%" "%exceptions%" "%~8"
+@if errorlevel 1 @exit /b 1
+@call :log 3 "Finding URL"
+@for /f "delims=| tokens=1-6" %%a in (%repository%) do @(
+  @if "%arch%" == "%%a" (
+    @if "%version%" == "%%b" (
+      @if "%threading%" == "%%c" (
+        @if "%exceptions%" == "%%d" (
+          @if "%revision%" == "%%e" (
+            @set "url=%%f"
+) ) ) ) ) )
+@if "%url%" == "" (
+  @call :log 0 "Failed to resolve URL"
+  @exit /b 1
+)
+@set slug=gcc-%version%-%arch%-%threading%-%exceptions%-rev%revision%
+@call :log 2 "Resolved slug: %slug%"
+@call :log 2 "Resolved url: %url%"
+@endlocal & set "%slug_var%=%slug%" & set "%url_var%=%url%"
+@goto :eof
+
+:unpack - Unpacks the MinGW archive
+:: %1 - The return variable name for the compiler path
+:: %2 - The filepath or URL of the archive
+:: %3 - The folder to unpack to
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "archive_path=%~2"
+@if "%archive_path%" == "" @exit /b 1
+@set "folder_path=%~3"
+@if "%folder_path%" == "" @exit /b 1
+@set "compiler_path=%folder_path%\bin"
+@if exist "%compiler_path%" goto :unpack_done
+@call :log 7
+@call :log 2 "Unpacking MinGW archive"
+@set "http=%archive_path:~0,4%"
+@if "%http%" == "http" (
+  @set "url=%archive_path%"
+  @for /f %%a in ("!url: =-!") do @set "file_name=%%~na"
+  @for /f %%a in ("!url: =-!") do @set "file_ext=%%~xa"
+  @set "archive_path=%dependency_path%\!file_name!!file_ext!"
+  @if not exist "!archive_path!" (
+    @call :log 6
+    @call :log 1 "Downloading MinGW archive"
+    @call :download "!url!" "!archive_path!"
+    @if errorlevel 1 (
+      @del "!archive_path!" 2>nul
+      @call :log 0 "Failed to download: !file_name!!file_ext!"
+      @exit /b 1
+    )
+  )
+)
+@if not exist "%archive_path%" (
+  @call :log 0 "The archive did not exist to unpack: %archive_path%"
+  @exit /b 1
+)
+@for /f %%a in ("%archive_path: =-%") do @set "file_name=%%~na"
+@for /f %%a in ("%archive_path: =-%") do @set "file_ext=%%~xa"
+@call :log 6
+@call :log 1 "Unpacking MinGW %file_name%%file_ext%"
+@call :find_sevenzip sevenzip_executable
+@if errorlevel 1 (
+  @call :log 0 "Need 7zip to unpack the MinGW archive"
+  @exit /b 1
+)
+@call :iso8601 iso8601
+@for /f %%a in ("%folder_path%") do @set "tmp_path=%%~dpatmp-%iso8601%"
+@"%sevenzip_executable%" x -y "-o%tmp_path%" "%archive_path%" > nul
+@if errorlevel 1 (
+  @rmdir /s /q "%folder_path%"
+  @call :log 0 "Failed to unpack the MinGW archive"
+  @exit /b 1
+)
+@set "expected_path=%tmp_path%\mingw64"
+@if not exist "%expected_path%" (
+  @set "expected_path=%tmp_path%\mingw32"
+)
+@move /y "%expected_path%" "%folder_path%" > nul
+@if errorlevel 1 (
+  @rmdir /s /q "%tmp_path%" 2>nul
+  @call :log 0 "Failed to move MinGW folder"
+  @call :log 0 "%expected_path%"
+  @call :log 0 "%folder_path%"
+  @exit /b 1
+)
+@rmdir /s /q %tmp_path%
+@set "compiler_path=%folder_path%\bin"
+:unpack_done
+@if not exist "%compiler_path%\gcc.exe" (
+  @call :log 0 "Failed to find gcc: %compiler_path%"
+  @exit /b 1
+)
+@endlocal & set "%var%=%compiler_path%"
+@goto :eof
+
+:find_sevenzip - Finds (or downloads) the 7zip executable
+:: %1 - The return variable for the 7zip executable path
+@setlocal
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@call :log 2 "Finding 7zip"
+@call :find_in_path sevenzip_executable 7z.exe
+@if not errorlevel 1 goto :find_sevenzip_done
+@call :find_in_path sevenzip_executable 7za.exe
+@if not errorlevel 1 goto :find_sevenzip_done
+@set checksum=2FAC454A90AE96021F4FFC607D4C00F8
+@set "url=http://7-zip.org/a/7za920.zip"
+@for /f %%a in ("%url: =-%") do @set "file_name=%%~na"
+@for /f %%a in ("%url: =-%") do @set "file_ext=%%~xa"
+@set "archive_path=%dependency_path%\%file_name%%file_ext%"
+@if not exist "%archive_path%" (
+  @call :log 6
+  @call :log 1 "Downloading 7zip archive"
+  @call :download "%url%" "%archive_path%" %checksum%
+  @if errorlevel 1 (
+    @del "%archive_path%" 2>nul
+    @call :log 0 "Failed to download: %file_name%%file_ext%"
+    @exit /b 1
+  )
+)
+@set "sevenzip_path=%dependency_path%\sevenzip"
+@if not exist "%sevenzip_path%" (
+  @call :unzip "%archive_path%" "%sevenzip_path%"
+  @if errorlevel 1 (
+    @call :log 0 "Failed to unzip the7zip archive"
+    @exit /b 1
+  )
+)
+@set "sevenzip_executable=%sevenzip_path%\7za.exe"
+@if not exist "%sevenzip_executable%" (
+  @call :log 0 "Failed to find unpacked 7zip: %sevenzip_executable%"
+  @exit /b 1
+)
+:find_sevenzip_done
+@call :log 2 "Found 7zip: %sevenzip_executable%"
+@endlocal & set "%var%=%sevenzip_executable%"
+@goto :eof
+
+:unzip - Unzips a .zip archive
+:: %1 - The archive to unzip
+:: %2 - The location to unzip to
+@setlocal
+@set "archive_path=%~1"
+@if "%archive_path%" == "" @exit /b 1
+@set "folder_path=%~2"
+@if "%folder_path%" == "" @exit /b 1
+@for /f %%a in ("%archive_path: =-%") do @set "file_name=%%~na"
+@for /f %%a in ("%archive_path: =-%") do @set "file_ext=%%~xa"
+@call :log 2 "Unzipping: %file_name%%file_ext%"
+@powershell ^
+  Add-Type -assembly "system.io.compression.filesystem"; ^
+  [io.compression.zipfile]::ExtractToDirectory(^
+    '%archive_path%', '%folder_path%') 2>nul
+@if errorlevel 1 (
+  @call :log 0 "Failed to unzip: %file_name%%file_ext%"
+  @exit /b 1
+)
+@endlocal
+@goto :eof
+
+:resolve_version - Gets the version of the MinGW compiler
+:: %1 - The return variable for the version
+:: %2 - The repository information to use
+:: %3 - The architecture of the compiler
+:: %4 - Version of MinGW to get [optional]
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "repository=%~2"
+@if "%repository%" == "" @exit /b 1
+@set "arch=%~3"
+@if "%arch%" == "" @exit /b 1
+@set "version=%~4"
+@if not "%version%" == "" goto :resolve_version_done
+:: Find the latest version
+@call :log 3 "Finding latest version"
+@set version=0.0.0
+@for /f "delims=| tokens=1-6" %%a in (%repository%) do @(
+  @if "%arch%" == "%%a" (
+    @call :version_compare result "%version%" "%%b"
+    @if errorlevel 1 (
+      @call :log 0 "Failed to compare versions: %version% %%a"
+      @exit /b 1
+    )
+    @if !result! lss 0 set version=%%b
+  )
+)
+:resolve_version_done
+@if "%version%" == "" (
+  @call :log 0 "Failed to resolve latest version number"
+  @exit /b 1
+)
+@call :log 2 "Resolved version: %version%"
+@endlocal & set "%var%=%version%"
+@goto :eof
+
+:resolve_threading - Gets the threading model of the MinGW compiler
+:: %1 - The return variable for the threading model
+:: %2 - The repository information to use
+:: %3 - The architecture of the compiler
+:: %4 - The version of the compiler
+:: %5 - threading model of MinGW to use [optional]
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "repository=%~2"
+@if "%repository%" == "" @exit /b 1
+@set "arch=%~3"
+@if "%arch%" == "" @exit /b 1
+@set "version=%~4"
+@if "%version%" == "" @exit /b 1
+@set "threading=%~5"
+@if not "%threading%" == "" goto :resolve_threading_done
+@call :log 3 "Finding best threading model"
+@for /f "delims=| tokens=1-6" %%a in (%repository%) do @(
+  @if "%arch%" == "%%a" (
+    @if "%version%" == "%%b" (
+      @if not defined threading (
+        @set "threading=%%c"
+      )
+      @if "%%c" == "posix" (
+        @set "threading=%%c"
+) ) ) )
+:resolve_threading_done
+@if "%threading%" == "" (
+  @call :log 0 "Failed to resolve the best threading model"
+  @exit /b 1
+)
+@call :log 2 "Resolved threading model: %threading%"
+@endlocal & set "%var%=%threading%"
+@goto :eof
+
+:resolve_exceptions - Gets the exception model of the MinGW compiler
+:: %1 - The return variable for the exception model
+:: %2 - The repository information to use
+:: %3 - The architecture of the compiler
+:: %4 - The version of the compiler
+:: %4 - The threading model of the compiler
+:: %5 - exception model of MinGW to use [optional]
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "repository=%~2"
+@if "%repository%" == "" @exit /b 1
+@set "arch=%~3"
+@if "%arch%" == "" @exit /b 1
+@set "version=%~4"
+@if "%version%" == "" @exit /b 1
+@set "threading=%~5"
+@if "%threading%" == "" @exit /b 1
+@set "exceptions=%~6"
+@if not "%exceptions%" == "" goto :resolve_exceptions_done
+@call :log 3 "Finding best exception model"
+@for /f "delims=| tokens=1-6" %%a in (%repository%) do @(
+  @if "%arch%" == "%%a" (
+    @if "%version%" == "%%b" (
+      @if "%threading%" == "%%c" (
+        @if not defined exceptions (
+          @set "exceptions=%%d"
+        )
+        @if "%%d" == "dwarf" (
+          @set "exceptions=%%d"
+        )
+        @if "%%d" == "seh" (
+          @set "exceptions=%%d"
+) ) ) ) )
+:resolve_exceptions_done
+@if "%exceptions%" == "" (
+  @call :log 0 "Failed to resolve the best exception model"
+  @exit /b 1
+)
+@call :log 2 "Resolved exception model: %exceptions%"
+@endlocal & set "%var%=%exceptions%"
+@goto :eof
+
+:resolve_revision - Gets the revision of the MinGW compiler
+:: %1 - The return variable for the revision
+:: %2 - The repository information to use
+:: %3 - The architecture of the compiler
+:: %4 - The version of the compiler
+:: %4 - The threading model of the compiler
+:: %4 - The exception model of the compiler
+:: %5 - revision of the MinGW package to use [optional]
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "repository=%~2"
+@if "%repository%" == "" @exit /b 1
+@set "arch=%~3"
+@if "%arch%" == "" @exit /b 1
+@set "version=%~4"
+@if "%version%" == "" @exit /b 1
+@set "threading=%~5"
+@if "%threading%" == "" @exit /b 1
+@set "exceptions=%~6"
+@if "%exceptions%" == "" @exit /b 1
+@set "revision=%~7"
+@if not "%revision%" == "" goto :resolve_revision_done
+@call :log 3 "Finding latest revision"
+@for /f "delims=| tokens=1-6" %%a in (%repository%) do @(
+  @if "%arch%" == "%%a" (
+    @if "%version%" == "%%b" (
+      @if "%threading%" == "%%c" (
+        @if "%exceptions%" == "%%d" (
+          @if "%%e" gtr "%revision%" (
+            @set "revision=%%e"
+) ) ) ) ) )
+:resolve_revision_done
+@if "%revision%" == "" (
+  @call :log 0 "Failed to resolve latest revision"
+  @exit /b 1
+)
+@call :log 2 "Resolved revision: %revision%"
+@endlocal & set "%var%=%revision%"
+@goto :eof
+
+:version_compare - Compares two semantic version numbers
+:: %1 - The return variable:
+::        - < 0 : if %2 < %3
+::        -   0 : if %2 == %3
+::        - > 0 : if %2 > %3
+:: %2 - The first version to compare
+:: %3 - The second version to compare
+@setlocal
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "lhs=%~2"
+@if "%lhs%" == "" @exit /b 1
+@set "rhs=%~3"
+@if "%lhs%" == "" @exit /b 1
+@set result=0
+@for /f "delims=. tokens=1-6" %%a in ("%lhs%.%rhs%") do @(
+  @if %%a lss %%d (
+    set result=-1
+    goto :version_compare_done
+  ) else (
+    @if %%a gtr %%d (
+      set result=1
+      goto :version_compare_done
+    ) else (
+      @if %%b lss %%e (
+        set result=-1
+        goto :version_compare_done
+      ) else (
+        @if %%b gtr %%e (
+          set result=1
+          goto :version_compare_done
+        ) else (
+          @if %%c lss %%f (
+            set result=-1
+            goto :version_compare_done
+          ) else (
+            @if %%c gtr %%f (
+              set result=1
+              goto :version_compare_done
+            )
+          )
+        )
+      )
+    )
+  )
+)
+:version_compare_done
+@endlocal & set "%var%=%result%"
+@goto :eof
+
+:print_usage - Prints the usage of the script
+:: %* - message to print, each argument on it's own line
+@setlocal
+@for %%a in (%*) do @echo.%%~a
+@echo.
+@echo.build [/?][/v[v...]^|/q][/version][/arch a][/threading t]
+@echo.      [/exceptions e][/revision r] location
+@echo.
+@echo.  /version v  The version of MinGW to download
+@echo.  /arch a     The target architecture [i686^|x86_64]
+@echo.  /threading t
+@echo.              Threading model to use [posix^|win32]
+@echo.  /exceptions e
+@echo.              Exception model to use [sjlj^|seh^|dwarf]
+@echo.  /revision e Revision of the release to use
+@echo.  /v          Sets the output to be more verbose
+@echo.  /v[v...]    Extra verbosity, /vv, /vvv, etc
+@echo.  /q          Quiets the output
+@echo.  /?          Shows this usage message
+@echo.
+@endlocal
+@goto :eof
+
+:script_source - Determines if the script was ran from the cli or explorer
+:: %1 - The return variable [cli|explorer]
+@verify other 2>nul
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :log 0 "Failed to enable extensions"
+  @exit /b 1
+)
+@call :log 3 "Attempting to detect the script source"
+@echo "The invocation command was: '%cmdcmdline%'" >> %log_path%
+@for /f "tokens=1-3,*" %%a in ("%cmdcmdline%") do @(
+  set cmd=%%~a
+  set arg1=%%~b
+  set arg2=%%~c
+  set rest=%%~d
+)
+@set quote="
+@if "!arg2:~0,1!" equ "!quote!" (
+  if "!arg2:~-1!" neq "!quote!" (
+    set "arg2=!arg2:~1!"
+  )
+)
+@call :log 4 "cmd  = %cmd%"
+@call :log 4 "arg1 = %arg1%"
+@call :log 4 "arg2 = %arg2%"
+@call :log 4 "rest = %rest%"
+@call :log 4 "src  = %~f0"
+@if /i "%arg2%" == "call" (
+  set script_source=cli
+) else (
+  @if /i "%arg1%" == "/c" (
+    set script_source=explorer
+  ) else (
+    set script_source=cli
+  )
+)
+@call :log 3 "The script was invoked from %script_source%"
+@endlocal & set "%~1=%script_source%"
+@goto :eof
+
+:architecture - Finds the system architecture
+:: %1 - The return variable [i686|x86_64]
+@setlocal
+@call :log 3 "Determining the processor architecture"
+@set "key=HKLM\System\CurrentControlSet\Control\Session Manager\Environment"
+@set "var=PROCESSOR_ARCHITECTURE"
+@for /f "skip=2 tokens=2,*" %%a in ('reg query "%key%" /v "%var%"') do @set "arch=%%b"
+@if "%arch%" == "AMD64" set arch=x86_64
+@if "%arch%" == "x64" set arch=i686
+@call :log 4 "arch = %arch%"
+@endlocal & set "%~1=%arch%"
+@goto :eof
+
+:md5 - Gets the MD5 checksum for a file
+:: %1 - The hash
+:: %2 - The file path
+@setlocal
+@set "var=%~1"
+@set "file_path=%~2"
+@if "%var%" == "" @exit /b 1
+@if "%file_path%" == "" @exit /b 1
+@if not exist "%file_path%" @exit /b 1
+@for /f "skip=3 tokens=1,*" %%a in ('powershell Get-FileHash -Algorithm MD5 "'%file_path%'"') do @set hash=%%b
+@if not defined hash (
+  @call :log 6
+  @call :log 0 "Failed to get MD5 hash for %file_path%"
+  @exit /b 1
+)
+@endlocal & set "%var%=%hash: =%"
+@goto :eof
+
+:windows_version - Checks the windows version
+:: %1 - The windows version
+:: %2 - The major version number return variable
+:: %3 - The minor version number return variable
+:: %4 - The revision version number return variable
+@setlocal
+@call :log 3 "Retrieving the Windows version"
+@for /f "tokens=2 delims=[]" %%x in ('ver') do @set win_ver=%%x
+@set win_ver=%win_ver:Version =%
+@set win_ver_major=%win_ver:~0,1%
+@set win_ver_minor=%win_ver:~2,1%
+@set win_ver_rev=%win_ver:~4%
+@call :log 4 "win_ver = %win_ver%"
+@endlocal & set "%~1=%win_ver%" ^
+          & set "%~2=%win_ver_major%" ^
+          & set "%~3=%win_ver_minor%" ^
+          & set "%~4=%win_ver_rev%"
+@goto :eof
+
+:find_in_path - Finds a program of file in the PATH
+:: %1 - return variable of the file path
+@setlocal
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "file=%~2"
+@if "%file%" == "" @exit /b 1
+@call :log 3 "Searching PATH for %file%"
+@for %%x in ("%file%") do @set "file_path=%%~f$PATH:x"
+@if not defined file_path @exit /b 1
+@endlocal & set "%var%=%file_path%"
+@goto :eof
+
+:log_append - Appends another file into the current logging file
+:: %1 - the file_path to the file to concatenate
+@setlocal
+@set "file_path=%~1"
+@if "%file_path%" == "" @exit /b 1
+@call :log 3 "Appending to log: %file_path%"
+@call :iso8601 iso8601
+@set temp_log=%temp%\append-%iso8601%.log
+@call :log 4 "Using temp file %temp_log%"
+@type "%log_path%" "%file_path%" > "%temp_log%" 2>nul
+@move /y "%temp_log%" "%log_path%" 1>nul
+@del "%file_path% 2>nul
+@del "%temp_log% 2>nul
+@endlocal
+@goto :eof
+
+:iso8601 - Returns the current time in ISO8601 format
+:: %1 - the return variable
+:: %2 - format [extended|basic*]
+:: iso8601 - contains the resulting timestamp
+@setlocal
+@wmic Alias /? >NUL 2>&1 || @exit /b 1
+@set "var=%~1"
+@if "%var%" == "" @exit /b 1
+@set "format=%~2"
+@if "%format%" == "" set format=basic
+@for /F "skip=1 tokens=1-6" %%g IN ('wmic Path Win32_UTCTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') do @(
+  @if "%%~l"=="" goto :iso8601_done
+  @set "yyyy=%%l"
+  @set "mm=00%%j"
+  @set "dd=00%%g"
+  @set "hour=00%%h"
+  @set "minute=00%%i"
+  @set "seconds=00%%k"
+)
+:iso8601_done
+@set mm=%mm:~-2%
+@set dd=%dd:~-2%
+@set hour=%hour:~-2%
+@set minute=%minute:~-2%
+@set seconds=%seconds:~-2%
+@if /i [%format%] == [extended] (
+  set iso8601=%yyyy%-%mm%-%dd%T%hour%:%minute%:%seconds%Z
+) else (
+  if /i [%format%] == [basic] (
+    set iso8601=%yyyy%%mm%%dd%T%hour%%minute%%seconds%Z
+  ) else (
+    @exit /b 1
+  )
+)
+@set iso8601=%iso8601: =0%
+@endlocal & set %var%=%iso8601%
+@goto :eof
+
+:verbosity - Processes the verbosity parameter '/v[v...]
+:: %1 - verbosity given on the command line
+:: logging_level - set to the number of v's
+@setlocal
+@set logging_level=0
+@set verbosity=%~1
+:verbosity_loop
+@set verbosity=%verbosity:~1%
+@if not [%verbosity%] == [] @(
+  set /a "logging_level=logging_level+1"
+  goto verbosity_loop
+)
+@endlocal & set logging_level=%logging_level%
+@goto :eof
+
+:log - Logs a message, depending on verbosity
+:: %1 - level
+::       [0-4] for CLI logging
+::       [5-9] for GUI logging
+:: %2 - message to print
+@setlocal
+@set "level=%~1"
+@set "msg=%~2"
+@if "%log_folder%" == "" (
+  echo Logging was used to early in the script, log_folder isn't set yet
+  goto :eof
+)
+@if "%log_path%" == "" (
+  echo Logging was used to early in the script, log_path isn't set yet
+  goto :eof
+)
+@if not exist "%log_folder%" mkdir "%log_folder%"
+@if not exist "%log_path%" echo. 1>nul 2>"%log_path%"
+@echo.%msg% >> "%log_path%"
+@if %level% geq 5 (
+  @if [%script_source%] == [explorer] (
+    set /a "level=level-5"
+  ) else (
+    @goto :eof
+  )
+)
+@if "%logging_level%" == "" (
+  echo Logging was used to early in the script, logging_level isn't set yet
+  goto :eof
+)
+@if %logging_level% geq %level% echo.%msg% 1>&2
+@endlocal
+@goto :eof
+
+:download - Downloads a file from the internet
+:: %1 - the url of the file to download
+:: %2 - the file to download to
+:: %3 - the MD5 checksum of the file (optional)
+@setlocal EnableDelayedExpansion
+@if errorlevel 1 (
+  @call :print_usage "Failed to enable extensions"
+  @exit /b 1
+)
+@set "url=%~1"
+@set "file_path=%~2"
+@set "checksum=%~3"
+@for %%a in (%file_path%) do @set dir_path=%%~dpa
+@for %%a in (%file_path%) do @set file_name=%%~nxa
+@if "%url%" == "" @exit /b 1
+@if "%file_path%" == "" @exit /b 1
+@if "%dir_path%" == "" @exit /b 1
+@if "%file_name%" == "" @exit /b 1
+@if not exist "%dir_path%" mkdir "%dir_path%"
+@call :log 2 "Downloading %url%"
+@call :iso8601 iso8601
+@set "temp_path=%temp%\download-%iso8601%-%file_name%"
+@call :log 4 "Using temp file %temp_path%"
+@powershell Invoke-WebRequest "'%url%'" ^
+  -OutFile "'%temp_path%'" ^
+  -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::IE ^
+  1> nul 2> nul
+@if errorlevel 1 (
+  @call :log 0 "Failed to download %url%"
+  @exit /b 1
+)
+@if [%checksum%] neq [] (
+  @call :log 4 "Checking %checksum% against %temp_path%"
+  @call :md5 hash "%temp_path%"
+  if "!hash!" neq "%checksum%" (
+    @call :log 0 "Failed to match checksum: %temp_path%"
+    @call :log 0 "Hash    : !hash!"
+    @call :log 0 "Checksum: %checksum%"
+    @exit /b 1
+  ) else (
+    @call :log 3 "Checksum matched: %temp_path%"
+    @call :log 3 "Hash    : !hash!"
+    @call :log 3 "Checksum: %checksum%"
+  )
+)
+@call :log 4 "Renaming %temp_path% to %file_path%"
+@move /y "%temp_path%" "%file_path%" 1>nul
+@endlocal
+@goto :eof


Better GH_TOKEN support

Better GH_TOKEN support

--- script/install-zpm.bat
+++ script/install-zpm.bat
@@ -8,8 +8,12 @@

 if exist "premake5.zip" del /q "premake5.zip"

-powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip"
-dir
+if exists %GH_TOKEN% (
+    powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip -Headers @{'Authorization'='token %GH_TOKEN%'}"
+) else (
+    powershell -command "Invoke-WebRequest -Uri https://github.com/premake/premake-core/releases/download/v5.0.0-alpha11/premake-5.0.0-alpha11-windows.zip -OutFile premake5.zip"
+)
+
 powershell -command Add-Type -AssemblyName System.IO.Compression.FileSystem ^

 [System.IO.Compression.ZipFile]::ExtractToDirectory('premake5.zip', '.')"
@@ -19,9 +23,9 @@
 echo Finished cloning ZPM...

 if exists %GH_TOKEN% (
+    ./premake5 --github-token=%GH_TOKEN% --file=zpm/zpm.lua install-zpm;
+) else (
     ./premake5 --file=zpm/zpm.lua install-zpm;
-) else (
-    ./premake5 --github-token=$GH_TOKEN --file=zpm/zpm.lua install-zpm;
 )

 rmdir /s /q "%TEMP%/zpm-install"


Add extra line

Add extra line

--- script/install-zpm.bat
+++ script/install-zpm.bat
@@ -17,6 +17,7 @@
 echo Finished downloading premake...

 powershell -command "Add-Type -AssemblyName System.IO.Compression.FileSystem^
+
 [System.IO.Compression.ZipFile]::ExtractToDirectory('premake5.zip', '.')"

 git clone https://github.com/Zefiros-Software/ZPM.git ./zpm


A  + scons.bat

A  + scons.bat

git-svn-id: e22621a84199d42b34715cdc089545aeedbbf23f@1268 050acbb0-2703-11df-ab0a-9f3f633ae91d

error: pathspec 'libraries/scons.bat' did not match any file(s) known to git

--- libraries/scons.bat
+++ libraries/scons.bat
@@ -0,0 +1,43 @@
+@echo off
+
+:: Copyright (c) 2011 The Native Client Authors. All rights reserved.
+:: Use of this source code is governed by a BSD-style license that can be
+:: found in the LICENSE file.
+
+setlocal
+
+:: NACL_SDK_ROOT must be set.
+if not defined NACL_SDK_ROOT (
+  echo Error: NACL_SDK_ROOT is not set.
+  echo Please set NACL_SDK_ROOT to the full path of the Native Client SDK.
+  echo For example:
+  echo set NACL_SDK_ROOT=D:\nacl_sdk
+  goto end
+)
+
+:: NACL_TARGET_PLATFORM is really the name of a folder with the base dir -
+:: usually NACL_SDK_ROOT - within which the toolchain for the target platform
+:: are found.
+:: Replace the platform with the name of your target platform.  For example, to
+:: build applications that target the pepper_16 API, set
+::   NACL_TARGET_PLATFORM=pepper_16
+if not defined NACL_TARGET_PLATFORM (
+  set NACL_TARGET_PLATFORM=pepper_16
+)
+
+set NACL_PLATFORM_DIR=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM%
+
+set SCONS_LIB_DIR=%NACL_PLATFORM_DIR%\third_party\scons-2.0.1\engine
+set PYTHONPATH=%NACL_PLATFORM_DIR%\third_party\scons-2.0.1\engine;%NACL_PLATFORM_DIR%\build_tools
+
+:: We have to do this because scons overrides PYTHONPATH and does not preserve
+:: what is provided by the OS.  The custom variable name won't be overwritten.
+set PYMOX=%NACL_PLATFORM_DIR%\third_party\pymox
+
+:: Run the included copy of scons.
+python -O -OO "%NACL_PLATFORM_DIR%\third_party\scons-2.0.1\script\scons" ^
+--warn no-visual-c-missing ^
+--file=build.scons ^
+--site-dir="%NACL_PLATFORM_DIR%\build_tools\nacl_sdk_scons" %*
+
+:end


enable testing

enable testing

--- recipes/alps/bld.bat
+++ recipes/alps/bld.bat
@@ -45,7 +45,7 @@
       -DBUILD_STATIC_LIBS=1 ^
       -DBUILD_SHARED_LIBS=1 ^
       -DALPS_ENABLE_MPI=OFF ^
-      -DALPS_BUILD_TESTS=OFF ^
+      -DALPS_BUILD_TESTS=ON ^
       -DALPS_BUILD_APPLICATIONS=ON ^
       -DALPS_BUILD_EXAMPLES=OFF ^
       -DBOOST_ROOT="%PREFIX%" ^


remove if block for conda install and just doit

Signed-off-by: Stephen L Arnold <53d2d0260cf3c7874f881213827dabd293ca7ee7@gentoo.org>

--- recipes/cccc/bld.bat
+++ recipes/cccc/bld.bat
@@ -139,10 +139,10 @@
 endlocal

 REM install snippet for conda
-if "%CONDA_BUILD%"=="1" (
-   if not exist %PREFIX%\bin mkdir %PREFIX%\bin
-   copy cccc/cccc.exe %PREFIX%\bin\cccc.exe
-)
+REM if "%CONDA_BUILD%"=="1" generates syntax error
+if not exist %PREFIX%\bin mkdir %PREFIX%\bin
+copy cccc/cccc.exe %PREFIX%\bin\cccc.exe
+

 rem The visual C++ addin can't be built using MS Visual C++ Toolkit 2003
 rem because it doesn't provide MFC header files and libraries


Support salt on windows

Support salt on windows

--- recipes/salt/bld.bat
+++ recipes/salt/bld.bat
@@ -1,14 +1,14 @@
 %PYTHON% setup.py install
 if errorlevel 1 exit 1

-for %%DIR in (
-       etc/salt
-       var/cache/salt
-       var/run/salt
-       srv/salt
-       srv/pillar
-       var/log/salt
-       var/run
+for %%D in (
+       etc\salt
+       var\cache\salt
+       var\run\salt
+       srv\salt
+       srv\pillar
+       var\log\salt
+       var\run
 ) do (
-       mkdir %PREFIX%\%%DIR
+       if not exist  %PREFIX%\"%%D" mkdir %PREFIX%\"%%D"
 )


Update build.bat to allow building .net wrappers in all platforms

--- Lang/DotNet/build.bat
+++ Lang/DotNet/build.bat
@@ -1,8 +1,15 @@
 @echo off
 SET PLAT=x86
+SET BUILD_ALL=0
 if "%1" == "x64" SET PLAT=x64
+if "%1" == "all" SET BUILD_ALL=1
 if exist Bin rd /S /Q Bin
 del /F /Q Wrapper\*.cs
 rem swig -csharp -c++ -nodefaultctor -nodefaultdtor -namespace OSGeo.FDO -outdir "%CD%\Wrapper" -o "%CD%\FdoDotNet\fdo_wrap.cpp" -I"%CD%\..\..\Fdo\Inc" fdo.i
 ..\..\Tools\swigwin-3.0.2\swig.exe -csharp -c++ -nodefaultctor -nodefaultdtor -namespace OSGeo.FDO -outdir "%CD%\Wrapper" -o "%CD%\FdoDotNet\fdo_wrap.cpp" -I"%CD%\..\..\Fdo\Inc" fdo.i 1> swig_build.log 2>&1
-msbuild FdoDotNet.sln /p:Configuration=Release;Platform=%PLAT%+if "%BUILD_ALL%" == "1" (
+    msbuild FdoDotNet.sln /p:Configuration=Release;Platform=x86
+    msbuild FdoDotNet.sln /p:Configuration=Release;Platform=x64
+) else (
+    msbuild FdoDotNet.sln /p:Configuration=Release;Platform=%PLAT%
+)


SCHEDULING-1549
There should be an equivalent of the bin/unix/scheduler-start-gui.sh script for Windows

Fixed formatting in the jetty-launcher.bat

git-svn-id: 27916816d6cfa57849e9a885196bf7392b80e1ac@21608 28e8926c-6b08-0410-baaa-805c5e19b8d6

--- bin/windows/jetty-launcher.bat
+++ bin/windows/jetty-launcher.bat
@@ -1,236 +1,236 @@
-@echo off
-SETLOCAL
-
-set VERBOSE=true
-set VERBOSE_JETTY=false
-set PORT=8080
-set REST=
-set RM=
-set SCHED=
-set JVM_OPTS=
-set RM_URL=
-set SCHED_URL=
-
-:ParamParseLoop
-IF [%1]==[] goto :ParamParseEndLoop
-    IF %1 == -q (
-        set VERBOSE=false
-        goto :ParamParseShift
-    )
-    IF %1 == -v (
-        set VERBOSE=true
-        goto :ParamParseShift
-    )
-    IF %1 == -h (
-        call :print_help
-        goto :eof
-    )
-    IF %1 == -A (
-        IF NOT exist "%~2" (
-            echo -A must point to a Web App folder or .war file
-            goto :eof
-        )
-        set REST=%2
-        SHIFT
-        goto :ParamParseShift
-    )
-    IF %1 == -R (
-        IF NOT exist "%~2" (
-            echo -R must point to a Web App folder or .war file
-            goto :eof
-        )
-        set RM=%2
-        SHIFT
-        goto :ParamParseShift
-    )
-    IF %1 == -S (
-        IF NOT exist "%~2" (
-            echo -S must point to a Web App folder or .war file
-            goto :eof
-        )
-        set SCHED=%2
-        SHIFT
-        goto :ParamParseShift
-    )
-    IF %1 == -r (
-        IF [%2]==[] (
-            echo -r requires an argument
-            goto :eof
-        )
-        set RM_URL=%2
-        SHIFT
-        goto :ParamParseShift
-    )
-    IF %1 == -s (
-        IF [%2]==[] (
-            echo -s requires an argument
-            goto :eof
-        )
-        set SCHED_URL=%2
-        SHIFT
-        goto :ParamParseShift
-    )
-    IF %1 == -p (
-        IF [%2]==[] (
-            echo -p requires an argument
-            goto :eof
-        )
-        set PORT=%2
-        SHIFT
-        goto :ParamParseShift
-    )
-
-    set TMP_VAR=%~1
-    IF %TMP_VAR:~0,2% == -D (
-        set JAVA_OPTS=%TMP_VAR% %JAVA_OPTS%
-        goto :ParamParseShift
-    )
-
-    echo Unknown option %1
-    goto :eof
-
-:ParamParseShift
-    SHIFT
-goto :ParamParseLoop
-:ParamParseEndLoop
-
-IF [%REST%]==[] (
-    echo REST Server argument is mandatory
-    goto :eof
-)
-
-set REST_URL=http://localhost:%PORT%/rest/rest
-
-call :createTempDir scheduler_start_gui
-set BASE_TEMP_DIR=%_result%
-set REST_DIR="%BASE_TEMP_DIR%\rest"
-set RM_DIR="%BASE_TEMP_DIR%\rm"
-set LOGFILE="%BASE_TEMP_DIR%\jetty.log"
-set POL="%BASE_TEMP_DIR%\java.security.policy"
-
-set SCHED_DIR="%BASE_TEMP_DIR%\sched"
-
-mkdir %REST_DIR%
-IF %VERBOSE% == true (
-    echo Deploying REST Server in %REST_DIR%
-)
-
-IF /I %REST:~-4% == .war (
-    call :unzip %REST% %REST_DIR%
-) ELSE (
-    xcopy /E %REST%\* %REST_DIR%
-)
-
-COPY ..\..\config\proactive\ProActiveConfiguration.xml %REST_DIR%\WEB-INF\
-
-IF NOT [%RM_URL%]==[] (
-    call :set_property "%REST_DIR%\WEB-INF\portal.properties" rm.url %RM_URL%
-)
-IF NOT [%SCHED_URL%]==[] (
-    call :set_property "%REST_DIR%\WEB-INF\portal.properties" scheduler.url %SCHED_URL%
-)
-
-set APPS=%REST_DIR%
-
-IF NOT [%RM%]==[] (
-    mkdir "%RM_DIR%"
-    IF %VERBOSE% == true (
-        echo Deploying RM UI in %RM_DIR%
-    )
-    IF /I %RM:~-4% == .war (
-        call :unzip %RM% %RM_DIR%
-    ) ELSE (
-        xcopy /E %RM%\* %RM_DIR%
-    )
-    call :set_property "%RM_DIR%\rm.conf" rm.rest.url %REST_URL%
-
-    set APPS=%APPS% %RM_DIR%
-)
-
-IF NOT [%SCHED%]==[] (
-    mkdir "%SCHED_DIR%"
-    IF %VERBOSE% == true (
-        echo Deploying Scheduling UI in %RM_DIR%
-    )
-    IF /I %SCHED:~-4% == .war (
-        call :unzip %SCHED% %SCHED_DIR%
-    ) ELSE (
-        xcopy /E %SCHED%\* %SCHED_DIR%
-    )
-    call :set_property "%SCHED_DIR%\scheduler.conf" sched.rest.url %REST_URL%
-
-    set APPS=%APPS% %SCHED_DIR%
-)
-
-set JAVA="%JAVA_HOME%\bin\java"
-
-set LIB_DIR=%CD%\..\..\lib
-set CP=%LIB_DIR%\ProActive\jetty-6.1.18.jar
-set CP=%CP%;%LIB_DIR%\ProActive\jetty-util-6.1.18.jar
-set CP=%CP%;%LIB_DIR%\ProActive\servlet-api-2.5-6.1.11.jar
-set CP=%CP%;%CD%\..\..\dist\lib\ProActive_SRM-common.jar
-
-set CLASS=org.ow2.proactive.utils.JettyLauncher
-
-set LOG=
-IF %VERBOSE_JETTY% == false (
-    IF %VERBOSE% == true (
-        echo Jetty Launcher logs to %LOGFILE%
-    )
-    set LOG=-l %LOGFILE%
-)
-
-echo grant { permission java.security.AllPermission; }; > %POL%
-set JVM_OPTS=%JVM_OPTS% -Djava.security.manager -Djava.security.policy=%POL%
-
-set CLASSPATH=%CP%
-%JAVA% %JVM_OPTS% %CLASS% -p %PORT% %LOG% %APPS%
-
-goto :eof
-
-:unzip
-    SETLOCAL
-    set CLASSPATH=..\..\compile\lib\ant-launcher.jar;%CLASSPATH%
-    "%JAVA_HOME%\bin\java" "-Dant.home=../../compile" "-Dant.library.dir=../../compile/lib" org.apache.tools.ant.launch.Launcher -buildfile utils.xml -Dzip_src=%1 -Dzip_dest=%2 unzip
-    ENDLOCAL
-    goto :eof
-
-:set_property
-    SETLOCAL
-    set CLASSPATH=..\..\compile\lib\ant-launcher.jar;%CLASSPATH%
-    "%JAVA_HOME%\bin\java" "-Dant.home=../../compile" "-Dant.library.dir=../../compile/lib" org.apache.tools.ant.launch.Launcher -buildfile utils.xml -Dfile=%1 -Dproperty=%2 -Dvalue=%3 set_property
-    ENDLOCAL
-    goto :eof
-
-:createTempDir
-    SETLOCAL
-    set TMPFILE=%TMP%\%1\%RANDOM%_%TIME:~-2%_%TIME:~0,2%
-    if exist "%TMPFILE%" GOTO :GETTEMPNAME
-    MKDIR %TMPFILE%
-    ENDLOCAL & SET _result=%TMPFILE%
-    goto :eof
-
-:print_help
-    echo jetty-launcher.bat ^<arguments^> [options]
-    echo.
-    echo Paths for Web Applications (REST Server and both UI) point to either
-    echo a valid .war file, or the extraction directory of a valid .war file.
-    echo.
-    echo Arguments:
-    echo -A PATH   REST Server
-    echo.
-    echo Options:
-    echo -R PATH   RM Web UI
-    echo -S PATH   Scheduler Web UI
-    echo -r URL    RM Server URL
-    echo -s URL    Scheduler Server URL
-    echo -p PORT   HTTP server port
-    echo -q        quiet output
-    echo -v        Output jetty logs on stdout instead of tmp file
-    echo -Dxxx     JVM option
-    echo -h        print this message
-    echo.
-    goto :eof
-
-:eof
+@echo off
+SETLOCAL
+
+set VERBOSE=true
+set VERBOSE_JETTY=false
+set PORT=8080
+set REST=
+set RM=
+set SCHED=
+set JVM_OPTS=
+set RM_URL=
+set SCHED_URL=
+
+:ParamParseLoop
+IF [%1]==[] goto :ParamParseEndLoop
+    IF %1 == -q (
+        set VERBOSE=false
+        goto :ParamParseShift
+    )
+    IF %1 == -v (
+        set VERBOSE=true
+        goto :ParamParseShift
+    )
+    IF %1 == -h (
+        call :print_help
+        goto :eof
+    )
+    IF %1 == -A (
+        IF NOT exist "%~2" (
+            echo -A must point to a Web App folder or .war file
+            goto :eof
+        )
+        set REST=%2
+        SHIFT
+        goto :ParamParseShift
+    )
+    IF %1 == -R (
+        IF NOT exist "%~2" (
+            echo -R must point to a Web App folder or .war file
+            goto :eof
+        )
+        set RM=%2
+        SHIFT
+        goto :ParamParseShift
+    )
+    IF %1 == -S (
+        IF NOT exist "%~2" (
+            echo -S must point to a Web App folder or .war file
+            goto :eof
+        )
+        set SCHED=%2
+        SHIFT
+        goto :ParamParseShift
+    )
+    IF %1 == -r (
+        IF [%2]==[] (
+            echo -r requires an argument
+            goto :eof
+        )
+        set RM_URL=%2
+        SHIFT
+        goto :ParamParseShift
+    )
+    IF %1 == -s (
+        IF [%2]==[] (
+            echo -s requires an argument
+            goto :eof
+        )
+        set SCHED_URL=%2
+        SHIFT
+        goto :ParamParseShift
+    )
+    IF %1 == -p (
+        IF [%2]==[] (
+            echo -p requires an argument
+            goto :eof
+        )
+        set PORT=%2
+        SHIFT
+        goto :ParamParseShift
+    )
+
+    set TMP_VAR=%~1
+    IF %TMP_VAR:~0,2% == -D (
+        set JAVA_OPTS=%TMP_VAR% %JAVA_OPTS%
+        goto :ParamParseShift
+    )
+
+    echo Unknown option %1
+    goto :eof
+
+:ParamParseShift
+    SHIFT
+goto :ParamParseLoop
+:ParamParseEndLoop
+
+IF [%REST%]==[] (
+    echo REST Server argument is mandatory
+    goto :eof
+)
+
+set REST_URL=http://localhost:%PORT%/rest/rest
+
+call :createTempDir scheduler_start_gui
+set BASE_TEMP_DIR=%_result%
+set REST_DIR="%BASE_TEMP_DIR%\rest"
+set RM_DIR="%BASE_TEMP_DIR%\rm"
+set LOGFILE="%BASE_TEMP_DIR%\jetty.log"
+set POL="%BASE_TEMP_DIR%\java.security.policy"
+
+set SCHED_DIR="%BASE_TEMP_DIR%\sched"
+
+mkdir %REST_DIR%
+IF %VERBOSE% == true (
+    echo Deploying REST Server in %REST_DIR%
+)
+
+IF /I %REST:~-4% == .war (
+    call :unzip %REST% %REST_DIR%
+) ELSE (
+    xcopy /E %REST%\* %REST_DIR%
+)
+
+COPY ..\..\config\proactive\ProActiveConfiguration.xml %REST_DIR%\WEB-INF\
+
+IF NOT [%RM_URL%]==[] (
+    call :set_property "%REST_DIR%\WEB-INF\portal.properties" rm.url %RM_URL%
+)
+IF NOT [%SCHED_URL%]==[] (
+    call :set_property "%REST_DIR%\WEB-INF\portal.properties" scheduler.url %SCHED_URL%
+)
+
+set APPS=%REST_DIR%
+
+IF NOT [%RM%]==[] (
+    mkdir "%RM_DIR%"
+    IF %VERBOSE% == true (
+        echo Deploying RM UI in %RM_DIR%
+    )
+    IF /I %RM:~-4% == .war (
+        call :unzip %RM% %RM_DIR%
+    ) ELSE (
+        xcopy /E %RM%\* %RM_DIR%
+    )
+    call :set_property "%RM_DIR%\rm.conf" rm.rest.url %REST_URL%
+
+    set APPS=%APPS% %RM_DIR%
+)
+
+IF NOT [%SCHED%]==[] (
+    mkdir "%SCHED_DIR%"
+    IF %VERBOSE% == true (
+        echo Deploying Scheduling UI in %RM_DIR%
+    )
+    IF /I %SCHED:~-4% == .war (
+        call :unzip %SCHED% %SCHED_DIR%
+    ) ELSE (
+        xcopy /E %SCHED%\* %SCHED_DIR%
+    )
+    call :set_property "%SCHED_DIR%\scheduler.conf" sched.rest.url %REST_URL%
+
+    set APPS=%APPS% %SCHED_DIR%
+)
+
+set JAVA="%JAVA_HOME%\bin\java"
+
+set LIB_DIR=%CD%\..\..\lib
+set CP=%LIB_DIR%\ProActive\jetty-6.1.18.jar
+set CP=%CP%;%LIB_DIR%\ProActive\jetty-util-6.1.18.jar
+set CP=%CP%;%LIB_DIR%\ProActive\servlet-api-2.5-6.1.11.jar
+set CP=%CP%;%CD%\..\..\dist\lib\ProActive_SRM-common.jar
+
+set CLASS=org.ow2.proactive.utils.JettyLauncher
+
+set LOG=
+IF %VERBOSE_JETTY% == false (
+    IF %VERBOSE% == true (
+        echo Jetty Launcher logs to %LOGFILE%
+    )
+    set LOG=-l %LOGFILE%
+)
+
+echo grant { permission java.security.AllPermission; }; > %POL%
+set JVM_OPTS=%JVM_OPTS% -Djava.security.manager -Djava.security.policy=%POL%
+
+set CLASSPATH=%CP%
+%JAVA% %JVM_OPTS% %CLASS% -p %PORT% %LOG% %APPS%
+
+goto :eof
+
+:unzip
+    SETLOCAL
+    set CLASSPATH=..\..\compile\lib\ant-launcher.jar;%CLASSPATH%
+    "%JAVA_HOME%\bin\java" "-Dant.home=../../compile" "-Dant.library.dir=../../compile/lib" org.apache.tools.ant.launch.Launcher -buildfile utils.xml -Dzip_src=%1 -Dzip_dest=%2 unzip
+    ENDLOCAL
+    goto :eof
+
+:set_property
+    SETLOCAL
+    set CLASSPATH=..\..\compile\lib\ant-launcher.jar;%CLASSPATH%
+    "%JAVA_HOME%\bin\java" "-Dant.home=../../compile" "-Dant.library.dir=../../compile/lib" org.apache.tools.ant.launch.Launcher -buildfile utils.xml -Dfile=%1 -Dproperty=%2 -Dvalue=%3 set_property
+    ENDLOCAL
+    goto :eof
+
+:createTempDir
+    SETLOCAL
+    set TMPFILE=%TMP%\%1\%RANDOM%_%TIME:~-2%_%TIME:~0,2%
+    if exist "%TMPFILE%" GOTO :GETTEMPNAME
+    MKDIR %TMPFILE%
+    ENDLOCAL & SET _result=%TMPFILE%
+    goto :eof
+
+:print_help
+    echo jetty-launcher.bat ^<arguments^> [options]
+    echo.
+    echo Paths for Web Applications (REST Server and both UI) point to either
+    echo a valid .war file, or the extraction directory of a valid .war file.
+    echo.
+    echo Arguments:
+    echo -A PATH   REST Server
+    echo.
+    echo Options:
+    echo -R PATH   RM Web UI
+    echo -S PATH   Scheduler Web UI
+    echo -r URL    RM Server URL
+    echo -s URL    Scheduler Server URL
+    echo -p PORT   HTTP server port
+    echo -q        quiet output
+    echo -v        Output jetty logs on stdout instead of tmp file
+    echo -Dxxx     JVM option
+    echo -h        print this message
+    echo.
+    goto :eof
+
+:eof
 ENDLOCAL


add .bat

add .bat

error: pathspec 'release_to_maven.bat' did not match any file(s) known to git

--- release_to_maven.bat
+++ release_to_maven.bat
@@ -0,0 +1,7 @@
+call mvn -U -DfailIfNoTests=false -Denv=online -Dmaven.test.skip=true clean install package deploy
+
+
+echo ------------------------------
+
+
+pause


NuGet deployment batch file

NuGet deployment batch file

error: pathspec 'NuGet/PackAndPush.bat' did not match any file(s) known to git

--- NuGet/PackAndPush.bat
+++ NuGet/PackAndPush.bat
@@ -0,0 +1,9 @@
+nuget pack Spark\Spark.nuspec
+nuget pack Spark.Web.Mvc2\Spark.Web.Mvc2.nuspec
+nuget pack Spark.Web.Mvc3\Spark.Web.Mvc3.nuspec
+
+nuget push Spark.1.5.1.6.nupkg
+nuget push Spark.Web.Mvc2.1.5.1.6.nupkg
+nuget push Spark.Web.Mvc3.1.5.1.6.nupkg
+
+pause


Adding ciphertool.bat file

Adding ciphertool.bat file

error: pathspec 'features/org.wso2.carbon.kernel.feature/resources/bin/ciphertool.bat' did not match any file(s) known to git

--- features/org.wso2.carbon.kernel.feature/resources/bin/ciphertool.bat
+++ features/org.wso2.carbon.kernel.feature/resources/bin/ciphertool.bat
@@ -0,0 +1,78 @@
+@echo off
+
+REM ---------------------------------------------------------------------------
+REM   Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+REM
+REM   Licensed under the Apache License, Version 2.0 (the "License");
+REM   you may not use this file except in compliance with the License.
+REM   You may obtain a copy of the License at
+REM
+REM   http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM   Unless required by applicable law or agreed to in writing, software
+REM   distributed under the License is distributed on an "AS IS" BASIS,
+REM   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM   See the License for the specific language governing permissions and
+REM   limitations under the License.
+
+rem ----- if JAVA_HOME is not set we're not happy ------------------------------
+:checkJava
+
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+goto checkServer
+
+:noJavaHome
+echo "You must set the JAVA_HOME variable before running CARBON."
+goto end
+
+rem ----- Only set CARBON_HOME if not already set ----------------------------
+:checkServer
+rem %~sdp0 is expanded pathname of the current script under NT with spaces in the path removed
+if "%CARBON_HOME%"=="" set CARBON_HOME=%~sdp0..
+SET curDrive=%cd:~0,1%
+SET wsasDrive=%CARBON_HOME:~0,1%
+if not "%curDrive%" == "%wsasDrive%" %wsasDrive%:
+
+rem find CARBON_HOME if it does not exist due to either an invalid value passed
+rem by the user or the %0 problem on Windows 9x
+if not exist "%CARBON_HOME%\bin\kernel-version.txt" goto noServerHome
+
+goto commandLifecycle
+
+:noServerHome
+echo CARBON_HOME is set incorrectly or CARBON could not be located. Please set CARBON_HOME.
+goto end
+
+:commandLifecycle
+goto findJdk
+
+:findJdk
+
+set CMD=RUN %*
+
+:checkJdk16
+"%JAVA_HOME%\bin\java" -version 2>&1 | findstr /r "1.[8]" >NUL
+IF ERRORLEVEL 1 goto unknownJdk
+goto jdk16
+
+:unknownJdk
+echo Starting WSO2 Carbon (in unsupported JDK)
+echo [ERROR] CARBON is supported only on JDK 1.8
+goto jdk16
+
+:jdk16
+goto runTool
+
+:runTool
+cd %CARBON_HOME%\bin
+echo JAVA_HOME environment variable is set to %JAVA_HOME%
+echo CARBON_HOME environment variable is set to %CARBON_HOME%
+java -cp ".\*;..\bin\bootstrap\tools\*" -Dcarbon.home="%CARBON_HOME%" -Dwso2.carbon.tool="secure-vault" org.wso2.carbon.tools.CarbonToolExecutor %*
+
+:end
+goto endlocal
+
+:endlocal
+
+:END


Explain comments

Explain comments

--- buildscripts/jenkins-build.bat
+++ buildscripts/jenkins-build.bat
@@ -37,7 +37,7 @@
 mkdir %dbpath%
 mkdir %logpath%

-REM start in the background
+REM /b -> start without creating a new window. disables ^C handling
 start /b mongod.exe --dbpath %dbpath% --logpath %logpath%\mongod.log || exit /b 1

 echo on
@@ -64,6 +64,7 @@

 call py.test --doctest-modules -vv --pyargs blaze --junitxml=test_results.xml

+REM /im -> process name, /f -> force kill
 taskkill /im mongod.exe /f || exit /b 1

 IF %ERRORLEVEL% NEQ 0 exit /b 1


fix quoting to work with windows screwed up standards

--- setup.bat
+++ setup.bat
@@ -21,7 +21,7 @@

 :DIRNOTEXISTS

-IF "%1" == "" GOTO DEFAULTPY
+IF %1 == "" GOTO DEFAULTPY
 set PYTHON=%1
 GOTO VIRTUALENV

@@ -29,7 +29,7 @@
 set PYTHON=python

 :VIRTUALENV
-"%PYTHON%" virtualenv.py --extra-search-dir=submodule/conveyor_bins/python --never-download virtualenv
+%PYTHON% virtualenv.py --extra-search-dir=submodule/conveyor_bins/python --never-download virtualenv
 GOTO DIREXISTS

 :DONE


Follow redirect for downloading luarocks zip

--- .ci/install.bat
+++ .ci/install.bat
@@ -25,7 +25,7 @@
 :: Now we declare a scope
 Setlocal EnableDelayedExpansion EnableExtensions

-if not defined LUAROCKS_URL set LUAROCKS_URL=http://keplerproject.github.io/luarocks/releases
+if not defined LUAROCKS_URL set LUAROCKS_URL=https://keplerproject.github.io/luarocks/releases
 if not defined LUAROCKS_REPO set LUAROCKS_REPO=https://luarocks.org
 if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
 if defined NOCOMPAT (
@@ -43,7 +43,7 @@
 :: LuaRocks <= 2.2.2 used a versioned directory
 :: HEAD and newer versions do not, so act accordingly.
 if defined LR_ROOT goto :skiplrver
-
+
 if "%LUAROCKS_VER%" EQU "HEAD" (
 	set LR_ROOT=%LUAROCKS_INSTALL%
 	goto :skiplrver
@@ -157,7 +157,7 @@
 	) else (
 		if not exist downloads\luarocks-%LUAROCKS_VER%-win32.zip (
 			echo Downloading LuaRocks...
-			curl --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
+			curl -L --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
 			%SEVENZIP% x -aoa -odownloads downloads\luarocks-%LUAROCKS_VER%-win32.zip
 		)
 	)


Techie Inc. Autos:- Thu 07/20/2017.

Techie Inc. Autos:- Thu 07/20/2017.

--- Techie.bat
+++ Techie.bat
@@ -1,7 +1,7 @@
 @ECHO OFF
 SET COMMITMESSAGE="Techie Inc. Autos:- %Date%".
 SET LOCALDIR=C:\WEB\WEBFILES\IYKEDAIRO\PTNigeria
-xcopy C:\Web\WEBFILES\config %LOCALDIR%\.git\config /G /Y
+REM xcopy C:\Web\WEBFILES\config %LOCALDIR%\.git\config /G /Y
 CD %LOCALDIR%


Create WhosOn.bat

Create WhosOn.bat

error: pathspec 'WhosOn.bat' did not match any file(s) known to git

--- WhosOn.bat
+++ WhosOn.bat
@@ -0,0 +1,108 @@
+:: Purpose:         Checks who's logged-on to a remote computer
+::                  Pings first to create an ARP entry, seems to lessen the chance of a timeout error.
+:: Requirements:    Run this script with a network admin account
+:: Author:          vocatus on reddit.com/r/sysadmin ( vocatus.gate@gmail.com ) // PGP key ID: 0x82A211A2
+:: History:         1.7.1 / Minor header cleanup; Variables section now above prep and checks
+::                  1.7   * Overhauled Date/Time conversion so we can handle ALL versions of Windows using ANY local date-time format
+::                  1.6   + Added "SCRIPT_UPDATED" variable to note when the script was last updated
+::                        / Structure cleanup
+::                  1.5   / Comment cleanup
+::                        / Structure cleanup
+::                  1.4   + Added missing quotes around %TARGET% variable
+::                  1.3   + Added /FAILFAST:on to WMIC method to allow faster time-outs if the machine isn't responding
+::                  1.2   + Added "WMIC /NODE:%TARGET% csproduct get vendor,name,identifyingnumber" to WMIC section
+::                  1.1   + Added two additional methods for checking which can be activated by uncommenting
+::                        + Added METHOD variable to reflect which method we're trying
+::                        / Capped variables properly
+::                  1.0   Initial write
+SETLOCAL
+
+
+:::::::::::::::
+:: VARIABLES :: -------------- These are the defaults. Change them if you so desire. --------- ::
+:::::::::::::::
+
+:: Set method of querying remote system. Valid methods are:
+::  - WMIC                (most reliable, however provides the least information)
+::  - Windows_query_user  (requires Windows Vista and up; doesn't work on XP)
+::  - PsLoggedon          (requires PsLoggedon.exe from sysinternals)
+set METHOD=WMIC
+
+:: --------------------------- Don't edit anything below this line --------------------------- ::
+
+
+
+:::::::::::::::::::::
+:: PREP AND CHECKS ::
+:::::::::::::::::::::
+@echo off
+title Who's Logged On?
+set TARGET=%1%
+set SCRIPT_VERSION=1.7.1
+set SCRIPT_UPDATED=2014-09-08
+set RUNONCE=NO
+:: Get the date into ISO 8601 standard date format (yyyy-mm-dd) so we can use it
+FOR /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') DO set DTS=%%a
+set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%
+
+
+:::::::::::::::
+:: EXECUTION ::
+:::::::::::::::
+if not '%1%'=='' set RUNONCE=YES && goto run_once
+cls
+echo.
+echo  Check who's logged on to a remote computer.
+echo.
+echo  Available methods, from most reliable to least:
+echo   - WMIC                Uses WMIC to query the remote system
+echo   - Windows_query_user  Uses Windows' built-in "query user /SERVER:%TARGET%" command
+echo                        (Your local PC must be running Windows Vista or 7 to use this)
+echo   - PsLoggedon          Uses SysInternal's PsLoggedon.exe to query the remote system
+echo.
+echo  Currently set to use the '%METHOD%' method.
+echo.
+:loop
+set /P TARGET= Check:
+	if %TARGET%==exit goto end
+:go
+echo.
+echo Checking %TARGET% using %METHOD%...
+echo.
+ping -n 1 %TARGET% >NUL
+goto %METHOD%
+
+
+::
+:: Method #1: WMIC. Most accurate, usually works. Valid on XP and up.
+::
+:WMIC
+WMIC /FAILFAST:on /NODE:"%TARGET%" computersystem GET name, username
+::WMIC /FAILFAST:on /NODE:"%TARGET%" csproduct get vendor,name,identifyingnumber
+if %ERRORLEVEL%==1 echo. && echo WMIC method failed. Trying Windows_query_user method... && echo. && goto Windows_query_user
+if %RUNONCE%==YES (goto end) ELSE (goto loop)
+
+::
+:: Method #2: Windows built-in. Only available on Vista/7 to my knowledge. Provides the most information.
+::
+:Windows_query_user
+query user /SERVER:%TARGET%
+if %RUNONCE%==YES (goto end) ELSE (goto loop)
+
+::
+:: Method #3: SysInternals utility. Works most of the time. the PsLoggedon.exe file is required.
+::
+:PsLoggedon
+PsLoggedon.exe -l \\%TARGET%
+if %RUNONCE%==YES goto end
+
+
+:run_once
+echo.
+echo Checking %TARGET% using %METHOD% method...
+echo.
+goto %METHOD%
+
+
+:end
+title %USERNAME%


startFresh windows cmd file added

startFresh windows cmd file added

error: pathspec 'startFresh.cmd' did not match any file(s) known to git

--- startFresh.cmd
+++ startFresh.cmd
@@ -0,0 +1,6 @@
+gradle clean
+gradle generate
+gradle downloadKddDatasetFiles
+gradle unzipKddDatasetFiles
+gradle createChecksumForKddDatasetFiles
+gradle tableImportKddTrainDataFromCommandLine