OLD | NEW |
1 @echo off | 1 @echo off |
2 :: Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 :: Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 :: Use of this source code is governed by a BSD-style license that can be | 3 :: Use of this source code is governed by a BSD-style license that can be |
4 :: found in the LICENSE file. | 4 :: found in the LICENSE file. |
5 | 5 |
6 :: This script will determine if python, git, or svn binaries need updates. It | 6 :: This script will determine if python, git, or svn binaries need updates. It |
7 :: returns 123 if the user's shell must restart, otherwise !0 is failure | 7 :: returns 123 if the user's shell must restart, otherwise !0 is failure |
8 | 8 |
9 :: Sadly, we can't use SETLOCAL here otherwise it ERRORLEVEL is not correctly | 9 :: Sadly, we can't use SETLOCAL here otherwise it ERRORLEVEL is not correctly |
10 :: returned. | 10 :: returned. |
11 | 11 |
12 set WIN_TOOLS_ROOT_URL=https://src.chromium.org/svn/trunk/tools | 12 set CHROME_INFRA_URL=https://storage.googleapis.com/chrome-infra/ |
13 :: It used to be %~dp0 but ADODB.Stream may fail to write to this directory if | 13 :: It used to be %~dp0 but ADODB.Stream may fail to write to this directory if |
14 :: the directory DACL is set to elevated integrity level. | 14 :: the directory DACL is set to elevated integrity level. |
15 set ZIP_DIR=%TEMP% | 15 set ZIP_DIR=%TEMP% |
16 | 16 |
17 :: Get absolute root directory (.js scripts don't handle relative paths well). | 17 :: Get absolute root directory (.js scripts don't handle relative paths well). |
18 pushd %~dp0..\.. | 18 pushd %~dp0..\.. |
19 set WIN_TOOLS_ROOT_DIR=%CD% | 19 set WIN_TOOLS_ROOT_DIR=%CD% |
20 popd | 20 popd |
21 | 21 |
22 if "%1" == "force" ( | 22 if "%1" == "force" ( |
23 set WIN_TOOLS_FORCE=1 | 23 set WIN_TOOLS_FORCE=1 |
24 shift /1 | 24 shift /1 |
25 ) | 25 ) |
26 | 26 |
27 | 27 |
28 :PYTHON_CHECK | 28 :PYTHON_CHECK |
29 if not exist "%WIN_TOOLS_ROOT_DIR%\python276_bin" goto :PY27_INSTALL | 29 if not exist "%WIN_TOOLS_ROOT_DIR%\python276_bin" goto :PY27_INSTALL |
30 if not exist "%WIN_TOOLS_ROOT_DIR%\python.bat" goto :PY27_INSTALL | 30 if not exist "%WIN_TOOLS_ROOT_DIR%\python.bat" goto :PY27_INSTALL |
31 set ERRORLEVEL=0 | 31 set ERRORLEVEL=0 |
32 goto :GIT_CHECK | 32 goto :GIT_CHECK |
33 | 33 |
34 | 34 |
35 :PY27_INSTALL | 35 :PY27_INSTALL |
36 echo Installing python 2.7.6... | 36 echo Installing python 2.7.6... |
37 :: Cleanup python directory if it was existing. | 37 :: Cleanup python directory if it was existing. |
| 38 set PYTHON_URL=%CHROME_INFRA_URL%python276_bin.zip |
38 if exist "%WIN_TOOLS_ROOT_DIR%\python276_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\p
ython276_bin" | 39 if exist "%WIN_TOOLS_ROOT_DIR%\python276_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\p
ython276_bin" |
39 if exist "%ZIP_DIR%\python276.zip" del "%ZIP_DIR%\python276.zip" | 40 if exist "%ZIP_DIR%\python276.zip" del "%ZIP_DIR%\python276.zip" |
40 echo Fetching from %WIN_TOOLS_ROOT_URL%/third_party/python276_bin.zip | 41 echo Fetching from %PYTHON_URL% |
41 cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party
/python276_bin.zip "%ZIP_DIR%\python276_bin.zip" | 42 cscript //nologo //e:jscript "%~dp0get_file.js" %PYTHON_URL% "%ZIP_DIR%\python27
6_bin.zip" |
42 if errorlevel 1 goto :PYTHON_FAIL | 43 if errorlevel 1 goto :PYTHON_FAIL |
43 :: Will create python276_bin\... | 44 :: Will create python276_bin\... |
44 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\python276_bin.zip" "%WIN
_TOOLS_ROOT_DIR%" | 45 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\python276_bin.zip" "%WIN
_TOOLS_ROOT_DIR%" |
45 :: Create the batch files. | 46 :: Create the batch files. |
46 call copy /y "%~dp0python276.new.bat" "%WIN_TOOLS_ROOT_DIR%\python.bat" 1>nul | 47 call copy /y "%~dp0python276.new.bat" "%WIN_TOOLS_ROOT_DIR%\python.bat" 1>nul |
47 call copy /y "%~dp0pylint.new.bat" "%WIN_TOOLS_ROOT_DIR%\pylint.bat" 1>nul | 48 call copy /y "%~dp0pylint.new.bat" "%WIN_TOOLS_ROOT_DIR%\pylint.bat" 1>nul |
48 del "%ZIP_DIR%\python276_bin.zip" | 49 del "%ZIP_DIR%\python276_bin.zip" |
49 set ERRORLEVEL=0 | 50 set ERRORLEVEL=0 |
50 goto :GIT_CHECK | 51 goto :GIT_CHECK |
51 | 52 |
52 | 53 |
53 :PYTHON_FAIL | 54 :PYTHON_FAIL |
54 echo ... Failed to checkout python automatically. | 55 echo ... Failed to checkout python automatically. |
55 echo You should get the "prebaked" version at %WIN_TOOLS_ROOT_URL%/third_party/ | 56 echo You should get the "prebaked" version at %PYTHON_URL% |
56 set ERRORLEVEL=1 | 57 set ERRORLEVEL=1 |
57 goto :END | 58 goto :END |
58 | 59 |
59 :GIT_CHECK | 60 :GIT_CHECK |
60 | 61 |
61 :: must explicitly use FIND_EXE to prevent this from grabbing e.g. gnuwin32 or | 62 :: must explicitly use FIND_EXE to prevent this from grabbing e.g. gnuwin32 or |
62 :: msys versions. | 63 :: msys versions. |
63 set FIND_EXE=%SYSTEMROOT%\System32\find.exe | 64 set FIND_EXE=%SYSTEMROOT%\System32\find.exe |
64 | 65 |
65 :: Check to see if we're on a 32 or 64 bit system | 66 :: Check to see if we're on a 32 or 64 bit system |
66 :: (parens) are necessary, otherwise batch puts an extra space after 32. | 67 :: (parens) are necessary, otherwise batch puts an extra space after 32. |
67 reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | %FIND_EXE% /i
"x86" > NUL && (set OS_BITS=32) || (set OS_BITS=64) | 68 reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | %FIND_EXE% /i
"x86" > NUL && (set OS_BITS=32) || (set OS_BITS=64) |
68 | 69 |
69 if not exist "%WIN_TOOLS_ROOT_DIR%\.git_bleeding_edge" ( | 70 if not exist "%WIN_TOOLS_ROOT_DIR%\.git_bleeding_edge" ( |
70 set GIT_VERSION=2.7.4 | 71 set GIT_VERSION=2.7.4 |
71 ) else ( | 72 ) else ( |
72 set GIT_VERSION=2.8.1 | 73 set GIT_VERSION=2.8.1 |
73 ) | 74 ) |
74 set GIT_VERSION=%GIT_VERSION%-%OS_BITS% | 75 set GIT_VERSION=%GIT_VERSION%-%OS_BITS% |
75 | 76 |
76 set GIT_FETCH_URL=https://storage.googleapis.com/chrome-infra/PortableGit-%GIT_V
ERSION%-bit.7z.exe | 77 set GIT_FETCH_URL=%CHROME_INFRA_URL%PortableGit-%GIT_VERSION%-bit.7z.exe |
77 set GIT_DOWNLOAD_PATH=%ZIP_DIR%\git.7z.exe | 78 set GIT_DOWNLOAD_PATH=%ZIP_DIR%\git.7z.exe |
78 set GIT_BIN_DIR=git-%GIT_VERSION%_bin | 79 set GIT_BIN_DIR=git-%GIT_VERSION%_bin |
79 set GIT_INST_DIR=%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR% | 80 set GIT_INST_DIR=%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR% |
80 set GIT_EXE_PATH=%GIT_INST_DIR%\bin\git.exe | 81 set GIT_EXE_PATH=%GIT_INST_DIR%\bin\git.exe |
81 | 82 |
82 :: Clean up any release which doesn't match the one we want. | 83 :: Clean up any release which doesn't match the one we want. |
83 for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do ( | 84 for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do ( |
84 if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" ( | 85 if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" ( |
85 echo Cleaning old git installation %%i | 86 echo Cleaning old git installation %%i |
86 rmdir /s /q "%%i" > NUL | 87 rmdir /s /q "%%i" > NUL |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :END | 184 if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :END |
184 if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL | 185 if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL |
185 call svn --version 2>nul 1>nul | 186 call svn --version 2>nul 1>nul |
186 if errorlevel 1 goto :SVN_INSTALL | 187 if errorlevel 1 goto :SVN_INSTALL |
187 goto :END | 188 goto :END |
188 | 189 |
189 | 190 |
190 :SVN_INSTALL | 191 :SVN_INSTALL |
191 echo Installing subversion ... | 192 echo Installing subversion ... |
192 :: svn is not accessible; check it out and create 'proxy' files. | 193 :: svn is not accessible; check it out and create 'proxy' files. |
| 194 set SVN_URL=%CHROME_INFRA_URL%svn_bin.zip |
193 if exist "%ZIP_DIR%\svn.zip" del "%ZIP_DIR%\svn.zip" | 195 if exist "%ZIP_DIR%\svn.zip" del "%ZIP_DIR%\svn.zip" |
194 echo Fetching from %WIN_TOOLS_ROOT_URL%/third_party/svn_bin.zip | 196 echo Fetching from %SVN_URL% |
195 cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party
/svn_bin.zip "%ZIP_DIR%\svn.zip" | 197 cscript //nologo //e:jscript "%~dp0get_file.js" %SVN_URL% "%ZIP_DIR%\svn.zip" |
196 if errorlevel 1 goto :SVN_FAIL | 198 if errorlevel 1 goto :SVN_FAIL |
197 :: Cleanup svn directory if it was existing. | 199 :: Cleanup svn directory if it was existing. |
198 if exist "%WIN_TOOLS_ROOT_DIR%\svn\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn" | 200 if exist "%WIN_TOOLS_ROOT_DIR%\svn\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn" |
199 if exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn_bin
" | 201 if exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn_bin
" |
200 :: Will create svn_bin\... | 202 :: Will create svn_bin\... |
201 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\svn.zip" "%WIN_TOOLS_ROO
T_DIR%" | 203 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\svn.zip" "%WIN_TOOLS_ROO
T_DIR%" |
202 if errorlevel 1 goto :SVN_FAIL | 204 if errorlevel 1 goto :SVN_FAIL |
203 if not exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." goto :SVN_FAIL | 205 if not exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." goto :SVN_FAIL |
204 del "%ZIP_DIR%\svn.zip" | 206 del "%ZIP_DIR%\svn.zip" |
205 :: Create the batch file. | 207 :: Create the batch file. |
206 call copy /y "%~dp0svn.new.bat" "%WIN_TOOLS_ROOT_DIR%\svn.bat" 1>nul | 208 call copy /y "%~dp0svn.new.bat" "%WIN_TOOLS_ROOT_DIR%\svn.bat" 1>nul |
207 call copy /y "%~dp0svnversion.new.bat" "%WIN_TOOLS_ROOT_DIR%\svnversion.bat" 1>n
ul | 209 call copy /y "%~dp0svnversion.new.bat" "%WIN_TOOLS_ROOT_DIR%\svnversion.bat" 1>n
ul |
208 goto :END | 210 goto :END |
209 | 211 |
210 | 212 |
211 :SVN_FAIL | 213 :SVN_FAIL |
212 echo ... Failed to checkout svn automatically. | 214 echo ... Failed to checkout svn automatically. |
213 echo You should get the "prebaked" version at %WIN_TOOLS_ROOT_URL%/third_party/ | 215 echo You should get the "prebaked" version at %SVN_URL% |
214 set ERRORLEVEL=1 | 216 set ERRORLEVEL=1 |
215 goto :END | 217 goto :END |
216 | 218 |
217 | 219 |
218 :returncode | 220 :returncode |
219 set WIN_TOOLS_ROOT_URL= | |
220 set WIN_TOOLS_ROOT_DIR= | 221 set WIN_TOOLS_ROOT_DIR= |
221 exit /b %ERRORLEVEL% | 222 exit /b %ERRORLEVEL% |
222 | 223 |
223 :END | 224 :END |
224 call :returncode %ERRORLEVEL% | 225 call :returncode %ERRORLEVEL% |
OLD | NEW |