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 try to find if svn and python are accessible and it not, | 6 :: This script will try to find if svn and python are accessible and it not, |
7 :: it will try to download it and 'install' it in depot_tools. | 7 :: it will try to download it and 'install' it in depot_tools. |
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=http://src.chromium.org/svn/trunk/tools | 12 set WIN_TOOLS_ROOT_URL=http://src.chromium.org/svn/trunk/tools |
13 set GIT_BIN_DIR=git-1.8.0_bin | 13 set GIT_BIN_DIR=git-1.8.0_bin |
14 | 14 |
15 :: Get absolute root directory (.js scripts don't handle relative paths well). | 15 :: Get absolute root directory (.js scripts don't handle relative paths well). |
16 pushd %~dp0..\.. | 16 pushd %~dp0..\.. |
17 set WIN_TOOLS_ROOT_DIR=%CD% | 17 set WIN_TOOLS_ROOT_DIR=%CD% |
18 popd | 18 popd |
19 | 19 |
20 if "%1" == "force" ( | 20 if "%1" == "force" ( |
21 set WIN_TOOLS_FORCE=1 | 21 set WIN_TOOLS_FORCE=1 |
22 shift /1 | 22 shift /1 |
23 ) | 23 ) |
24 | 24 |
25 | 25 |
26 :GIT_CHECK | 26 :GIT_CHECK |
27 :: If the batch file exists, skip the git check. | 27 :: If the batch file exists, skip the git check. |
28 if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%" goto :SVN_CHECK | 28 if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%" goto :MSYS_TERM_CHECK |
29 if "%CHROME_HEADLESS%" == "1" goto :SVN_CHECK | 29 if "%CHROME_HEADLESS%" == "1" goto :MSYS_TERM_CHECK |
30 if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL | 30 if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL |
31 call git --version 2>nul 1>nul | 31 call git --version 2>nul 1>nul |
32 if errorlevel 1 goto :GIT_INSTALL | 32 if errorlevel 1 goto :GIT_INSTALL |
33 goto :SVN_CHECK | 33 goto :MSYS_TERM_CHECK |
34 | 34 |
35 | 35 |
36 :GIT_INSTALL | 36 :GIT_INSTALL |
37 echo Installing git (avg 1-2 min download) ... | 37 echo Installing git (avg 1-2 min download) ... |
38 :: git is not accessible; check it out and create 'proxy' files. | 38 :: git is not accessible; check it out and create 'proxy' files. |
39 if exist "%~dp0git.zip" del "%~dp0git.zip" | 39 if exist "%~dp0git.zip" del "%~dp0git.zip" |
40 cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party /git-1.8.0_bin.zip "%~dp0git.zip" | 40 cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party /git-1.8.0_bin.zip "%~dp0git.zip" |
41 if errorlevel 1 goto :GIT_FAIL | 41 if errorlevel 1 goto :GIT_FAIL |
42 :: Cleanup svn directory if it was existing. | 42 :: Cleanup svn directory if it was existing. |
43 if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\% GIT_BIN_DIR%" | 43 if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\% GIT_BIN_DIR%" |
44 :: Will create %GIT_BIN_DIR%\... | 44 :: Will create %GIT_BIN_DIR%\... |
45 cscript //nologo //e:jscript "%~dp0unzip.js" "%~dp0git.zip" "%WIN_TOOLS_ROOT_DIR %" | 45 cscript //nologo //e:jscript "%~dp0unzip.js" "%~dp0git.zip" "%WIN_TOOLS_ROOT_DIR %" |
46 if errorlevel 1 goto :GIT_FAIL | 46 if errorlevel 1 goto :GIT_FAIL |
47 if not exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." goto :GIT_FAIL | 47 if not exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." goto :GIT_FAIL |
48 del "%~dp0git.zip" | 48 del "%~dp0git.zip" |
49 :: Create the batch files. | 49 :: Create the batch files. |
50 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\git.bat" "%WIN_TOOLS_ROOT_DIR%\ git.bat" 1>nul | 50 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\git.bat" "%WIN_TOOLS_ROOT_DIR%\ git.bat" 1>nul |
51 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\gitk.bat" "%WIN_TOOLS_ROOT_DIR% \gitk.bat" 1>nul | 51 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\gitk.bat" "%WIN_TOOLS_ROOT_DIR% \gitk.bat" 1>nul |
52 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh.bat" "%WIN_TOOLS_ROOT_DIR%\ ssh.bat" 1>nul | 52 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh.bat" "%WIN_TOOLS_ROOT_DIR%\ ssh.bat" 1>nul |
53 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh-keygen.bat" "%WIN_TOOLS_ROO T_DIR%\ssh-keygen.bat" 1>nul | 53 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh-keygen.bat" "%WIN_TOOLS_ROO T_DIR%\ssh-keygen.bat" 1>nul |
54 :: Ensure autocrlf and filemode are set correctly. | 54 :: Ensure autocrlf and filemode are set correctly. |
55 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --global core.autocrlf false | 55 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --global core.autocrlf false |
56 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --global core.filemode false | 56 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --global core.filemode false |
57 goto :SVN_CHECK | 57 goto :MSYS_TERM_CHECK |
58 | 58 |
59 | 59 |
60 :GIT_FAIL | 60 :GIT_FAIL |
61 echo ... Failed to checkout git automatically. | 61 echo ... Failed to checkout git automatically. |
62 echo Please visit http://code.google.com/p/msysgit to download the latest git | 62 echo Please visit http://code.google.com/p/msysgit to download the latest git |
63 echo client before continuing. | 63 echo client before continuing. |
64 echo You can also get the "prebacked" version used at %WIN_TOOLS_ROOT_URL%/ | 64 echo You can also get the "prebacked" version used at %WIN_TOOLS_ROOT_URL%/ |
65 set ERRORLEVEL=1 | 65 set ERRORLEVEL=1 |
66 goto :END | 66 goto :END |
67 | 67 |
68 | 68 |
69 :MSYS_TERM_CHECK | |
70 :: Tweak git.bat to set TERM appropriately | |
71 call FIND "TERM" "%WIN_TOOLS_ROOT_DIR%\git.bat" 2>nul 1>nul | |
M-A Ruel
2012/11/07 01:34:07
personally I'd keep find, findstr and move lowerca
| |
72 IF errorlevel 1 ( | |
73 FINDSTR /V "git\.cmd" "%WIN_TOOLS_ROOT_DIR%\git.bat" > git.bat.new | |
74 echo set TERM=msys >> git.bat.new | |
75 FINDSTR "git\.cmd" "%WIN_TOOLS_ROOT_DIR%\git.bat" >> git.bat.new | |
76 MOVE /Y git.bat.new "%WIN_TOOLS_ROOT_DIR%\git.bat" >nul | |
77 ) | |
78 | |
79 | |
69 :SVN_CHECK | 80 :SVN_CHECK |
70 :: If the batch file exists, skip the svn check. | 81 :: If the batch file exists, skip the svn check. |
71 if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :PYTHON_CHECK | 82 if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :PYTHON_CHECK |
72 if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL | 83 if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL |
73 call svn --version 2>nul 1>nul | 84 call svn --version 2>nul 1>nul |
74 if errorlevel 1 goto :SVN_INSTALL | 85 if errorlevel 1 goto :SVN_INSTALL |
75 goto :PYTHON_CHECK | 86 goto :PYTHON_CHECK |
76 | 87 |
77 | 88 |
78 :SVN_INSTALL | 89 :SVN_INSTALL |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 goto :END | 150 goto :END |
140 | 151 |
141 | 152 |
142 :returncode | 153 :returncode |
143 set WIN_TOOLS_ROOT_URL= | 154 set WIN_TOOLS_ROOT_URL= |
144 set WIN_TOOLS_ROOT_DIR= | 155 set WIN_TOOLS_ROOT_DIR= |
145 exit /b %ERRORLEVEL% | 156 exit /b %ERRORLEVEL% |
146 | 157 |
147 :END | 158 :END |
148 call :returncode %ERRORLEVEL% | 159 call :returncode %ERRORLEVEL% |
OLD | NEW |