-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.bat
172 lines (127 loc) · 4.82 KB
/
install.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@Echo Off
Echo --------------------------------------------------------------------------
Echo Auto install cygwin
Echo --------------------------------------------------------------------------
SetLocal
For /F %%D In ("%CD%") Do Set DRIVE=%%~dD
Set DEFAULT_SITE=http://mirror.csclub.uwaterloo.ca/cygwin/
Set CUR_DIR=%CD:\=/%
Set DEFAULT_ROOT_DIR=%DRIVE%/.cygwin
Set DEFAULT_LOCAL_DIR=%DEFAULT_ROOT_DIR%/.tmp
Set SITE=-s "%DEFAULT_SITE%"
Set LOCAL_DIR=-l "%DEFAULT_LOCAL_DIR%"
Set ROOT_DIR=-R "%DEFAULT_ROOT_DIR%"
Set REMOTE_SETUP_FILE=http://www.cygwin.com/setup.exe
Set LOCAL_SETUP_FILE=%DEFAULT_LOCAL_DIR%/setup.exe
Set WGET=%CUR_DIR%/wget.exe
Set BASH=%DEFAULT_ROOT_DIR%/bin/bash.exe
Rem -------------------------------------
Rem Download cygwin setup.exe
Rem -------------------------------------
Echo [INFO] Downloading cygwin setup.exe
If Exist %DEFAULT_LOCAL_DIR% (
Rem %DEFAULT_LOCAL_DIR% already created.
) Else (
MkDir "%DEFAULT_LOCAL_DIR%"
)
If Exist %LOCAL_SETUP_FILE% (
Echo [INFO] Cygwin setup was downloaded
) Else (
%WGET% "%REMOTE_SETUP_FILE%" -O "%LOCAL_SETUP_FILE%"
If Exist %LOCAL_SETUP_FILE% (
Echo [INFO] Cygwin setup.exe was downloaded
) Else (
Echo [FATAL]: Cygwin setup.exe was not downloaded
GoTo end
)
)
Rem -------------------------------------
Rem Setup cygwin
Rem -------------------------------------
Echo [INFO] Install cygwin to %DEFAULT_ROOT_DIR%
Set PACKAGES=-P wget
Set PACKAGES=%PACKAGES%,bzip2
Set PACKAGES=%PACKAGES%,subversion
Set PACKAGES=%PACKAGES%,git
Set PACKAGES=%PACKAGES%,chere
Set PACKAGES=%PACKAGES%,vim
Set PACKAGES=%PACKAGES%,openssh
Set PACKAGES=%PACKAGES%,ca-certificates
Rem Do the actual cygwin install
Echo [INFO] "%LOCAL_SETUP_FILE%" -q -n -D -L %SITE% %LOCAL_DIR% %ROOT_DIR% %PACKAGES%
"%LOCAL_SETUP_FILE%" -q -n -D -L %SITE% %LOCAL_DIR% %ROOT_DIR% %PACKAGES%
Echo [INFO] Cygwin installation is complete
Rem -------------------------------------
Rem Setup environment variables
Rem -------------------------------------
Echo [INFO] Add environment variables.
Set LAST_CHAR=%PATH:~-1%
Set SEMI_COMMA=;
Set CYGWIN_HOME=%DEFAULT_ROOT_DIR:/=\%
Set USER_HOME=%CYGWIN_HOME%\home\%USERNAME%
Set CYGWIN_HOME_BIN_PATH=%CYGWIN_HOME%\bin;
Ver|Find "5.1" > nul
IF %ERRORLEVEL% == 0 GoTo env_xp
Ver|Find "6.1" > nul
IF %ERRORLEVEL% == 0 GoTo env_win7
:env_xp
Set SET_X=%CUR_DIR%/setx.exe
Echo %SET_X% CYGWIN_HOME %CYGWIN_HOME%" -m
%SET_X% CYGWIN_HOME %CYGWIN_HOME% -m
Echo %SET_X% HOME %USER_HOME%
%SET_X% HOME %USER_HOME%
SetLocal EnableDelayedExpansion
If "%LAST_CHAR%"=="%SEMI_COMMA%" (
Echo %SET_X% PATH !PATH:%CYGWIN_HOME_BIN_PATH%=!%CYGWIN_HOME_BIN_PATH% -m
%SET_X% PATH "!PATH:%CYGWIN_HOME_BIN_PATH%=!%CYGWIN_HOME_BIN_PATH% -m"
) Else (
Echo %SET_X% PATH !PATH:%CYGWIN_HOME_BIN_PATH%=!;%CYGWIN_HOME_BIN_PATH% -m
%SET_X% PATH "!PATH:%CYGWIN_HOME_BIN_PATH%=!;%CYGWIN_HOME_BIN_PATH% -m"
)
EndLocal
%SET_X% CYGWIN nodosfilewarning -m
GoTo env_end
:env_win7
Set SET_X=%windir%\system32\setx.exe
Echo %SET_X% /M CYGWIN_HOME %CYGWIN_HOME%"
%SET_X% /M CYGWIN_HOME %CYGWIN_HOME%
Echo %SET_X% HOME %USER_HOME%
%SET_X% HOME %USER_HOME%
SetLocal EnableDelayedExpansion
If "%LAST_CHAR%"=="%SEMI_COMMA%" (
Echo %SET_X% /M PATH !PATH:%CYGWIN_HOME_BIN_PATH%=!%CYGWIN_HOME_BIN_PATH%
%SET_X% /M PATH "!PATH:%CYGWIN_HOME_BIN_PATH%=!%CYGWIN_HOME_BIN_PATH%"
) Else (
Echo %SET_X% /M PATH !PATH:%CYGWIN_HOME_BIN_PATH%=!;%CYGWIN_HOME_BIN_PATH%%
%SET_X% /M PATH "!PATH:%CYGWIN_HOME_BIN_PATH%=!;%CYGWIN_HOME_BIN_PATH%"
)
EndLocal
%SET_X% /M CYGWIN nodosfilewarning
GoTo env_end
:env_end
Rem -------------------------------------
Rem Custom cygwin
Rem -------------------------------------
Echo [INFO] Cygwin custom configuration
If Exist %BASH% (
GoTo custom
) Else (
Echo "Cannot find %BASH%
GoTo end
)
:custom
Rem -------------------------------------
Rem Install apt-cyg
Rem -------------------------------------
Echo [INFO] Installing the apt-cyg stuff as it has to be installed seperatly
%BASH% --norc --noprofile -c "/usr/bin/svn --force export http://apt-cyg.googlecode.com/svn/trunk/ /bin/"
%BASH% --norc --noprofile -c "/usr/bin/chmod +x /bin/apt-cyg"
Rem -------------------------------------
Set START_BASH_HERE='Start bash here...'
Rem Add %START_BASH_HERE%
Rem -------------------------------------
Echo [INFO] Add %START_BASH_HERE% to contex menu
%BASH% --login -i -c "/usr/bin/chere -if -t mintty -s bash -e %START_BASH_HERE% -o '-w max'"
:end
EndLocal
Exit /B 0