-
Notifications
You must be signed in to change notification settings - Fork 613
/
Copy pathsetup-git-sdk.bat
executable file
·145 lines (121 loc) · 4.9 KB
/
setup-git-sdk.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@REM Set up the Git SDK
@REM determine root directory
@REM https://technet.microsoft.com/en-us/library/bb490909.aspx says:
@REM <percent>~dpI Expands <percent>I to a drive letter and path only.
@REM <percent>~fI Expands <percent>I to a fully qualified path name.
@FOR /F "delims=" %%D in ("%~dp0") do @set cwd=%%~fD
@REM set PATH
@set PATH=%cwd%\usr\bin;%PATH%
@REM set MSYSTEM so that MSys2 starts up in the correct mode
@set MSYSTEM=MINGW@@BITNESS@@
@REM need to rebase just to make sure that it still works even with Windows 10
@SET initialrebase=false
@FOR /F "tokens=4 delims=.[XP " %%i IN ('ver') DO @SET ver=%%i
@IF 10 LEQ %ver @(
@SET initialrebase=false
)
@IF %initialrebase% == true @(
@REM we copy `rebase.exe` because it links to `msys-2.0.dll`.
@IF NOT EXIST "%cwd%"\bin\rebase.exe @(
@IF NOT EXIST "%cwd%"\bin @MKDIR "%cwd%"\bin
@COPY "%cwd%"\usr\bin\rebase.exe "%cwd%"\bin\rebase.exe
)
@IF NOT EXIST bin\msys-2.0.dll @(
@COPY usr\bin\msys-2.0.dll bin\msys-2.0.dll
)
@"%cwd%"\bin\rebase.exe -b 0x63000000 "%cwd%"\usr\bin\msys-2.0.dll
)
@SET /A counter=0
:INSTALL_RUNTIME
@SET /A counter+=1
@IF %counter% GEQ 5 @(
@ECHO Could not install msys2-runtime
@PAUSE
@EXIT 1
)
@REM Maybe we need a proxy?
@IF %counter% GEQ 2 @(
@ECHO.
@ECHO There was a problem accessing the MSys2 repositories
@ECHO If your setup requires an HTTP proxy to access the web,
@ECHO please specify it here, otherwise leave it empty.
@ECHO.
@SET /p proxy= "HTTP proxy: "
)
@REM Check the proxy variable here because of delayed expansion
@IF NOT "%proxy%" == "" @(
@SET http_proxy=%proxy%
@SET https_proxy=%proxy%
@IF %counter% EQU 2 @(
@COPY "%cwd%"\etc\pacman.conf.proxy "%cwd%"\etc\pacman.conf
)
)
@REM update the Pacman package indices first, then force-install msys2-runtime
@REM (we ship with a stripped-down msys2-runtime, gpg and pacman), so that
@REM pacman's post-install scripts run without complaining about heap problems
@"%cwd%"\usr\bin\pacman -Sy --needed --force --noconfirm msys2-runtime
@REM need to rebase just to make sure that it still works even with Windows 10
@IF %initialrebase% == true @(
@"%cwd%"\bin\rebase.exe -b 0x63000000 "%cwd%"\usr\bin\msys-2.0.dll
)
@IF ERRORLEVEL 1 GOTO INSTALL_RUNTIME
@SET /A counter=0
:INSTALL_PACMAN
@SET /A counter+=1
@IF %counter% GEQ 5 @(
@ECHO Could not install pacman
@PAUSE
@EXIT 1
)
@REM next, force update pacman, but first we need bash and info for that.
@"%cwd%"\usr\bin\pacman -S --needed --force --noconfirm bash info pacman
@IF ERRORLEVEL 1 GOTO INSTALL_PACMAN
@SET /A counter=0
:INSTALL_REST
@SET /A counter+=1
@IF %counter% GEQ 5 @(
@ECHO Could not install the remaining packages
@PAUSE
@EXIT 1
)
@REM now update the rest
@"%cwd%"\usr\bin\pacman -S --needed --force --noconfirm ^
base python less openssh patch make tar diffutils ca-certificates ^
git perl-Error perl perl-Authen-SASL perl-libwww perl-MIME-tools ^
perl-Net-SMTP-SSL perl-TermReadKey dos2unix asciidoc xmlto ^
subversion mintty vim git-extra p7zip markdown winpty ^
mingw-w64-@@ARCH@@-git-doc-html ^
mingw-w64-@@ARCH@@-git mingw-w64-@@ARCH@@-toolchain ^
mingw-w64-@@ARCH@@-curl mingw-w64-@@ARCH@@-expat ^
mingw-w64-@@ARCH@@-openssl mingw-w64-@@ARCH@@-tcl ^
mingw-w64-@@ARCH@@-pcre mingw-w64-@@ARCH@@-connect ^
git-flow
@IF ERRORLEVEL 1 GOTO INSTALL_REST
@REM Avoid overlapping address ranges
@IF MINGW32 == %MSYSTEM% @(
ECHO Auto-rebasing .dll files
CALL "%cwd%"\autorebase.bat
)
@REM If an HTTP proxy is required, configure it for Git Bash sessions,
@REM but only if the environment variable was not already set globally
@IF DEFINED proxy @(
@ECHO http_proxy=%proxy% > etc\profile.d\proxy.sh
@ECHO https_proxy=%proxy% >> etc\profile.d\proxy.sh
@ECHO export http_proxy https_proxy >> etc\profile.d\proxy.sh
@ECHO.
@ECHO Installed /etc/profile.d/proxy.sh to set proxy in Git Bash
)
@REM Before running a shell, let's prevent complaints about "permission denied"
@REM from MSys2's /etc/post-install/01-devices.post
@MKDIR "%cwd%"\dev\shm 2> NUL
@MKDIR "%cwd%"\dev\mqueue 2> NUL
@IF NOT DEFINED JENKINS_URL @(
@REM Install shortcut on the desktop
@ECHO.
@ECHO Installing the 'Git SDK @@BITNESS@@-bit' shortcut on the Desktop
@bash --login -c 'SHORTCUT="$HOME/Desktop/Git SDK @@BITNESS@@-bit.lnk"; test -f "$SHORTCUT" ^|^| create-shortcut.exe --icon-file /msys2.ico --work-dir / /git-bash.exe "$SHORTCUT"'
@REM now clone the Git sources, build it, and start an interactive shell
@bash --login -c "mkdir -p /usr/src && cd /usr/src && for project in MINGW-packages MSYS2-packages build-extra; do test ! -d $project && mkdir -p $project && (cd $project && git init && git config core.autocrlf false && git remote add origin https://github.com/git-for-windows/$project); done; if test ! -d git; then git clone -b @@GIT_BRANCH@@ -c core.autocrlf=false https://github.com/git-for-windows/git; fi && cd git && make install"
@IF ERRORLEVEL 1 PAUSE
@start mintty -i /msys2.ico -t "Git SDK @@BITNESS@@-bit" bash --login -i
)