OLD | NEW |
| (Empty) |
1 @echo off | |
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 | |
4 :: found in the LICENSE file. | |
5 | |
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. | |
8 | |
9 :: Sadly, we can't use SETLOCAL here otherwise it ERRORLEVEL is not correctly | |
10 :: returned. | |
11 | |
12 set WIN_TOOLS_ROOT_URL=https://src.chromium.org/svn/trunk/tools | |
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. | |
15 set ZIP_DIR=%TEMP% | |
16 | |
17 :: Get absolute root directory (.js scripts don't handle relative paths well). | |
18 pushd %~dp0..\.. | |
19 set WIN_TOOLS_ROOT_DIR=%CD% | |
20 popd | |
21 | |
22 if "%1" == "force" ( | |
23 set WIN_TOOLS_FORCE=1 | |
24 shift /1 | |
25 ) | |
26 | |
27 | |
28 :PYTHON_CHECK | |
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 | |
31 set ERRORLEVEL=0 | |
32 goto :GIT_CHECK | |
33 | |
34 | |
35 :PY27_INSTALL | |
36 echo Installing python 2.7.6... | |
37 :: Cleanup python directory if it was existing. | |
38 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 echo Fetching from %WIN_TOOLS_ROOT_URL%/third_party/python276_bin.zip | |
41 cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party
/python276_bin.zip "%ZIP_DIR%\python276_bin.zip" | |
42 if errorlevel 1 goto :PYTHON_FAIL | |
43 :: Will create python276_bin\... | |
44 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\python276_bin.zip" "%WIN
_TOOLS_ROOT_DIR%" | |
45 :: Create the batch files. | |
46 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 del "%ZIP_DIR%\python276_bin.zip" | |
49 set ERRORLEVEL=0 | |
50 goto :GIT_CHECK | |
51 | |
52 | |
53 :PYTHON_FAIL | |
54 echo ... Failed to checkout python automatically. | |
55 echo You should get the "prebaked" version at %WIN_TOOLS_ROOT_URL%/third_party/ | |
56 set ERRORLEVEL=1 | |
57 goto :END | |
58 | |
59 :GIT_CHECK | |
60 if "%DEPOT_TOOLS_GIT_BLEEDING%" == "1" ( | |
61 set GIT_VERSION=1.9.5.chromium.6 | |
62 ) else ( | |
63 set GIT_VERSION=1.9.5.chromium.6 | |
64 ) | |
65 for /f "tokens=2 delims=[]" %%i in ('ver') do set VERSTR=%%i | |
66 for /f "tokens=2,3 delims=. " %%i in ("%VERSTR%") do (set VERMAJOR=%%i & set VER
MINOR=%%j) | |
67 if %VERMAJOR% lss 5 set GIT_VERSION=%GIT_VERSION%-xp | |
68 if %VERMAJOR% equ 5 if %VERMINOR% lss 2 set GIT_VERSION=%GIT_VERSION%-xp | |
69 | |
70 :: Clean up any release which doesn't match the one we want. | |
71 for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do ( | |
72 if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" ( | |
73 rmdir /s /q "%%i" | |
74 ) | |
75 ) | |
76 set GIT_BIN_DIR=git-%GIT_VERSION%_bin | |
77 set GIT_ZIP_FILE=%GIT_BIN_DIR%.zip | |
78 set GIT_ZIP_URL=https://commondatastorage.googleapis.com/chrome-infra/%GIT_ZIP_F
ILE% | |
79 | |
80 if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL | |
81 if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\cmd\git.cmd" ( | |
82 call "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\cmd\git.cmd" --version 2>nul 1>nul | |
83 if errorlevel 1 goto :GIT_INSTALL | |
84 rem Several git versions can live side-by-side; check the top-level | |
85 rem batch script to make sure it points to the desired version. | |
86 find "%GIT_BIN_DIR%" "%WIN_TOOLS_ROOT_DIR%\git.bat" 2>nul 1>nul | |
87 if errorlevel 1 goto :GIT_COPY_BATCH_FILES | |
88 goto :SVN_CHECK | |
89 ) | |
90 goto :GIT_INSTALL | |
91 | |
92 | |
93 :GIT_INSTALL | |
94 echo Installing git %GIT_VERSION% (avg 1-2 min download) ... | |
95 :: git is not accessible; check it out and create 'proxy' files. | |
96 if exist "%ZIP_DIR%\git.zip" del "%ZIP_DIR%\git.zip" | |
97 echo Fetching from %GIT_ZIP_URL% | |
98 cscript //nologo //e:jscript "%~dp0get_file.js" %GIT_ZIP_URL% "%ZIP_DIR%\git.zip
" | |
99 if errorlevel 1 goto :GIT_FAIL | |
100 :: Cleanup svn directory if it was existing. | |
101 if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\%
GIT_BIN_DIR%" | |
102 :: Will create %GIT_BIN_DIR%\... | |
103 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\git.zip" "%WIN_TOOLS_ROO
T_DIR%" | |
104 if errorlevel 1 goto :GIT_FAIL | |
105 if not exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." goto :GIT_FAIL | |
106 del "%ZIP_DIR%\git.zip" | |
107 goto :GIT_COPY_BATCH_FILES | |
108 | |
109 | |
110 :GIT_COPY_BATCH_FILES | |
111 :: Create the batch files. | |
112 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\git.bat" "%WIN_TOOLS_ROOT_DIR%\
git.bat" 1>nul | |
113 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\gitk.bat" "%WIN_TOOLS_ROOT_DIR%
\gitk.bat" 1>nul | |
114 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh.bat" "%WIN_TOOLS_ROOT_DIR%\
ssh.bat" 1>nul | |
115 call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh-keygen.bat" "%WIN_TOOLS_ROO
T_DIR%\ssh-keygen.bat" 1>nul | |
116 | |
117 :: Ensure autocrlf and filemode are set correctly. | |
118 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.autocrlf false | |
119 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.filemode false | |
120 goto :SVN_CHECK | |
121 | |
122 | |
123 :GIT_FAIL | |
124 echo ... Failed to checkout git automatically. | |
125 echo You should get the "prebaked" version used at %GIT_ZIP_URL% | |
126 set ERRORLEVEL=1 | |
127 goto :END | |
128 | |
129 | |
130 :SVN_CHECK | |
131 :: If the batch file exists, skip the svn check. | |
132 if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :END | |
133 if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL | |
134 call svn --version 2>nul 1>nul | |
135 if errorlevel 1 goto :SVN_INSTALL | |
136 goto :END | |
137 | |
138 | |
139 :SVN_INSTALL | |
140 echo Installing subversion ... | |
141 :: svn is not accessible; check it out and create 'proxy' files. | |
142 if exist "%ZIP_DIR%\svn.zip" del "%ZIP_DIR%\svn.zip" | |
143 echo Fetching from %WIN_TOOLS_ROOT_URL%/third_party/svn_bin.zip | |
144 cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party
/svn_bin.zip "%ZIP_DIR%\svn.zip" | |
145 if errorlevel 1 goto :SVN_FAIL | |
146 :: Cleanup svn directory if it was existing. | |
147 if exist "%WIN_TOOLS_ROOT_DIR%\svn\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn" | |
148 if exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn_bin
" | |
149 :: Will create svn_bin\... | |
150 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\svn.zip" "%WIN_TOOLS_ROO
T_DIR%" | |
151 if errorlevel 1 goto :SVN_FAIL | |
152 if not exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." goto :SVN_FAIL | |
153 del "%ZIP_DIR%\svn.zip" | |
154 :: Create the batch file. | |
155 call copy /y "%~dp0svn.new.bat" "%WIN_TOOLS_ROOT_DIR%\svn.bat" 1>nul | |
156 call copy /y "%~dp0svnversion.new.bat" "%WIN_TOOLS_ROOT_DIR%\svnversion.bat" 1>n
ul | |
157 goto :END | |
158 | |
159 | |
160 :SVN_FAIL | |
161 echo ... Failed to checkout svn automatically. | |
162 echo You should get the "prebaked" version at %WIN_TOOLS_ROOT_URL%/third_party/ | |
163 set ERRORLEVEL=1 | |
164 goto :END | |
165 | |
166 | |
167 :returncode | |
168 set WIN_TOOLS_ROOT_URL= | |
169 set WIN_TOOLS_ROOT_DIR= | |
170 exit /b %ERRORLEVEL% | |
171 | |
172 :END | |
173 call :returncode %ERRORLEVEL% | |
OLD | NEW |