-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_Get_openssl.bat
104 lines (86 loc) · 2.33 KB
/
_Get_openssl.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
REM :: Marius Negrutiu (marius.negrutiu@protonmail.com)
@echo off
echo.
setlocal EnableDelayedExpansion
cd /d "%~dp0"
REM ------------------------------------
REM Name | Role
REM ---------------|--------------------
REM master | development branch
REM OpenSSL_x.y.z | release tags
REM ------------------------------------
set LIBNAME=openssl
set URL=git://git.openssl.org/openssl.git
title %LIBNAME%
:: Validate git
git --version 2> NUL
if %ERRORLEVEL% neq 0 echo ERROR: git not in PATH && pause && exit /B 2
if exist "%LIBNAME%\.git" (
goto :EXISTING
) else (
goto :NEW
)
:NEW
git clone --recurse-submodules --no-checkout --verbose --progress %URL% %LIBNAME%
if %ERRORLEVEL% neq 0 pause && exit /B %ERRORLEVEL%
:EXISTING
cd %LIBNAME%
REM :: git fetch
git fetch
if %ERRORLEVEL% neq 0 pause && exit /B %ERRORLEVEL%
REM :: Available branches
echo.
echo Branches:
set COUNT=0
for /f usebackq %%i in (`git branch -ar --sort=-committerdate`) do (
set /A COUNT = !COUNT! + 1
if !COUNT! leq 10 echo %%i
)
if !COUNT! gtr 10 (
set /A COUNT = !COUNT! - 10
echo !COUNT! more...
)
REM :: Available tags
echo.
echo Tags:
set COUNT=0
for /f usebackq %%i in (`git tag -l --sort=-creatordate`) do (
set /A COUNT = !COUNT! + 1
if !COUNT! leq 10 echo %%i
)
if !COUNT! gtr 10 (
set /A COUNT = !COUNT! - 10
echo !COUNT! more...
)
REM :: Switch to...
for /f usebackq %%i in (`git rev-parse --abbrev-ref HEAD`) do set CUR_TAG=%%i
if /i "%CUR_TAG%" equ "HEAD" (
for /f usebackq %%i in (`git describe --tags`) do set CUR_TAG=%%i
)
echo.
echo NOTE: Switching branches/tags will discard all local changes
set /p NEW_TAG=Switch to [%CUR_TAG%]:
if "%NEW_TAG%" equ "" set NEW_TAG=%CUR_TAG%
echo.
echo Checking out...
git checkout --force "%NEW_TAG%"
if %ERRORLEVEL% neq 0 pause && exit /B %ERRORLEVEL%
REM :: git pull
echo.
echo Pulling...
git pull origin "%NEW_TAG%"
if %ERRORLEVEL% neq 0 pause && exit /B %ERRORLEVEL%
:: Patch
echo.
set /p answer=Apply patch? ([yes]/no)
if /I "%answer%" equ "" goto :PATCH
if /I "%answer%" equ "yes" goto :PATCH
if /I "%answer%" equ "y" goto :PATCH
exit /B 1
:PATCH
cd /d "%~dp0"
set patches=
for /f "" %%f in ('dir /b _Patches\%LIBNAME%*.diff') do set patches=!patches! "_Patches\%%~f"
if "%patches%" neq "" git apply --verbose --whitespace=fix --directory=%LIBNAME% !patches! || echo -- patching failed
echo.
pause