Chromium Code Reviews| 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. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 :GIT_CHECK | 60 :GIT_CHECK |
| 61 | 61 |
| 62 :: 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 |
| 63 :: msys versions. | 63 :: msys versions. |
| 64 set FIND_EXE=%SYSTEMROOT%\System32\find.exe | 64 set FIND_EXE=%SYSTEMROOT%\System32\find.exe |
| 65 | 65 |
| 66 :: 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 |
| 67 :: (parens) are necessary, otherwise batch puts an extra space after 32. | 67 :: (parens) are necessary, otherwise batch puts an extra space after 32. |
| 68 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) |
| 69 | 69 |
| 70 if not exist "%WIN_TOOLS_ROOT_DIR%\.git_bleeding_edge" ( | 70 "%WIN_TOOLS_ROOT_DIR%\python.bat" "%~dp0git_bootstrap.py" --bits "%OS_BITS%" |
|
tandrii(chromium)
2016/08/29 14:38:29
if it works, fine, though I thought these should b
tandrii(chromium)
2016/08/29 14:47:29
i take it back. This line runs bootstrap using pyt
| |
| 71 set /p GIT_VERSION= <"%~dp0git_version.txt" | |
| 72 ) else ( | |
| 73 set /p GIT_VERSION= <"%~dp0git_version_bleeding_edge.txt" | |
| 74 ) | |
| 75 set GIT_VERSION=%GIT_VERSION%-%OS_BITS% | |
| 76 | |
| 77 set GIT_FETCH_URL=%CHROME_INFRA_URL%PortableGit-%GIT_VERSION%-bit.7z.exe | |
| 78 set GIT_DOWNLOAD_PATH=%ZIP_DIR%\git.7z.exe | |
| 79 set GIT_BIN_DIR=git-%GIT_VERSION%_bin | |
| 80 set GIT_INST_DIR=%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR% | |
| 81 set GIT_EXE_PATH=%GIT_INST_DIR%\bin\git.exe | |
| 82 | |
| 83 :: Clean up any release which doesn't match the one we want. | |
| 84 for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do ( | |
| 85 if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" ( | |
| 86 echo Cleaning old git installation %%i | |
| 87 rmdir /s /q "%%i" > NUL | |
| 88 ) | |
| 89 ) | |
| 90 | |
| 91 if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL | |
| 92 | |
| 93 if not exist "%GIT_EXE_PATH%" goto :GIT_INSTALL | |
| 94 | |
| 95 call "%GIT_EXE_PATH%" --version 2>nul 1>nul | |
| 96 if errorlevel 1 goto :GIT_INSTALL | |
| 97 | |
| 98 :: Several git versions can live side-by-side; check the top-level | |
| 99 :: batch script to make sure it points to the desired version. | |
| 100 for %%f in (git.bat gitk.bat ssh.bat ssh-keygen.bat git-bash) do ( | |
| 101 %FIND_EXE% "%GIT_BIN_DIR%" "%WIN_TOOLS_ROOT_DIR%\%%f" 2>nul 1>nul | |
| 102 if errorlevel 1 goto :GIT_MAKE_BATCH_FILES | |
| 103 ) | |
| 104 if not exist %GIT_INST_DIR%\etc\profile.d\python.sh goto :GIT_MAKE_BATCH_FILES | |
| 105 goto :SYNC_GIT_HELP_FILES | |
| 106 | |
| 107 :GIT_INSTALL | |
| 108 echo Installing git %GIT_VERSION% (avg 1-2 min download) ... | |
| 109 | |
| 110 if exist "%GIT_DOWNLOAD_PATH%" del "%GIT_DOWNLOAD_PATH%" | |
| 111 echo Fetching from %GIT_FETCH_URL% | |
| 112 cscript //nologo //e:jscript "%~dp0get_file.js" %GIT_FETCH_URL% "%GIT_DOWNLOAD_P ATH%" | |
| 113 if errorlevel 1 goto :GIT_FAIL | |
| 114 :: Cleanup git directory if it already exists. | |
| 115 if exist "%GIT_INST_DIR%\." rd /q /s "%GIT_INST_DIR%" | |
| 116 | |
| 117 :: run PortableGit self-extractor | |
| 118 :: -y : Be Quiet ("yes") | |
| 119 :: -sd1 : Self delete SFX archive | |
| 120 :: -InstallPath : Where to put the files | |
| 121 :: -Directory : Run the post-extract program with this current-working-directory | |
| 122 :: | |
| 123 :: Path slashes must be escaped or the 7zip sfx treats e.g. path\to\dir as | |
| 124 :: path[tab]o\dir. | |
| 125 set GIT_INST_DIR_ESC=%GIT_INST_DIR:\=\\% | |
| 126 call "%GIT_DOWNLOAD_PATH%" -y -sd1 -InstallPath="%GIT_INST_DIR_ESC%" -Directory= "%GIT_INST_DIR_ESC%" | |
| 127 if errorlevel 1 goto :GIT_FAIL | |
| 128 | |
| 129 del "%GIT_DOWNLOAD_PATH%" | |
| 130 if not exist "%GIT_INST_DIR%\." goto :GIT_FAIL | |
| 131 | |
| 132 set DID_UPGRADE=1 | |
| 133 | |
| 134 :GIT_MAKE_BATCH_FILES | |
| 135 :: Create the batch files. | |
| 136 set GIT_TEMPL=%~dp0git.template.bat | |
| 137 set SED=%GIT_INST_DIR%\usr\bin\sed.exe | |
| 138 call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/cmd\\\\git.exe /g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\git.bat" | |
| 139 call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/cmd\\\\gitk.ex e/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\gitk.bat" | |
| 140 call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/usr\\\\bin\\\\ ssh.exe/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\ssh.bat" | |
| 141 call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/usr\\\\bin\\\\ ssh-keygen.exe/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\ssh-keygen.bat" | |
| 142 call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/PYTHON_BIN_DIR/python276_b in/g" -e "s/SVN_BIN_DIR/svn_bin/g" < %~dp0git-bash.template.sh > "%WIN_TOOLS_ROO T_DIR%\git-bash" | |
| 143 copy "%~dp0profile.d.python.sh" %GIT_INST_DIR%\etc\profile.d\python.sh > NUL | |
| 144 | |
| 145 :: Ensure various git configurations are set correctly at they system level. | |
| 146 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.autocrlf false | |
| 147 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.filemode false | |
| 148 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.preloadindex true | |
| 149 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.fscache true | |
| 150 | |
| 151 :SYNC_GIT_HELP_FILES | |
| 152 :: Copy all the depot_tools docs into the mingw{bits} git docs root. | |
| 153 :: /i : Make sure xcopy knows that the destination names a folder, not a file | |
| 154 :: /q : Make xcopy quiet (though it still prints a `X File(s) copied` message | |
| 155 :: which is why we have the > NUL) | |
| 156 :: /d : Copy source files that are newer than the corresponding destination | |
| 157 :: files only. This prevents excessive copying when none of the docs | |
| 158 :: actually changed. | |
| 159 :: /y : Don't prompt for overwrites (yes) | |
| 160 xcopy /i /q /d /y "%WIN_TOOLS_ROOT_DIR%\man\html\*" "%GIT_INST_DIR%\mingw%OS_BIT S%\share\doc\git-doc" > NUL | |
| 161 | |
| 162 :: MSYS users need to restart their shell. | |
| 163 if defined MSYSTEM if defined DID_UPGRADE ( | |
| 164 echo. | |
| 165 echo. | |
| 166 echo [1;31mIMPORTANT:[0m | |
| 167 echo depot_tools' git distribution has been updated while inside of a MinGW | |
| 168 echo shell. In order to complete the upgrade, please exit the shell and re-run | |
| 169 echo `git bash` from cmd. | |
| 170 exit 123 | |
| 171 ) | |
| 172 | |
| 173 goto :SVN_CHECK | |
| 174 | |
| 175 :GIT_FAIL | |
| 176 echo ... Failed to checkout git automatically. | |
| 177 echo You should get the "prebaked" version used at %GIT_FETCH_URL% | |
| 178 set ERRORLEVEL=1 | |
| 179 goto :END | 71 goto :END |
| 180 | 72 |
| 181 | |
| 182 :SVN_CHECK | |
| 183 :: If the batch file exists, skip the svn check. | |
| 184 if exist "%WIN_TOOLS_ROOT_DIR%\svn.bat" goto :END | |
| 185 if "%WIN_TOOLS_FORCE%" == "1" goto :SVN_INSTALL | |
| 186 call svn --version 2>nul 1>nul | |
| 187 if errorlevel 1 goto :SVN_INSTALL | |
| 188 goto :END | |
| 189 | |
| 190 | |
| 191 :SVN_INSTALL | |
| 192 echo Installing subversion ... | |
| 193 :: svn is not accessible; check it out and create 'proxy' files. | |
| 194 set SVN_URL=%CHROME_INFRA_URL%svn_bin.zip | |
| 195 if exist "%ZIP_DIR%\svn.zip" del "%ZIP_DIR%\svn.zip" | |
| 196 echo Fetching from %SVN_URL% | |
| 197 cscript //nologo //e:jscript "%~dp0get_file.js" %SVN_URL% "%ZIP_DIR%\svn.zip" | |
| 198 if errorlevel 1 goto :SVN_FAIL | |
| 199 :: Cleanup svn directory if it was existing. | |
| 200 if exist "%WIN_TOOLS_ROOT_DIR%\svn\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn" | |
| 201 if exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\svn_bin " | |
| 202 :: Will create svn_bin\... | |
| 203 cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\svn.zip" "%WIN_TOOLS_ROO T_DIR%" | |
| 204 if errorlevel 1 goto :SVN_FAIL | |
| 205 if not exist "%WIN_TOOLS_ROOT_DIR%\svn_bin\." goto :SVN_FAIL | |
| 206 del "%ZIP_DIR%\svn.zip" | |
| 207 :: Create the batch file. | |
| 208 call copy /y "%~dp0svn.new.bat" "%WIN_TOOLS_ROOT_DIR%\svn.bat" 1>nul | |
| 209 call copy /y "%~dp0svnversion.new.bat" "%WIN_TOOLS_ROOT_DIR%\svnversion.bat" 1>n ul | |
| 210 goto :END | |
| 211 | |
| 212 | |
| 213 :SVN_FAIL | |
| 214 echo ... Failed to checkout svn automatically. | |
| 215 echo You should get the "prebaked" version at %SVN_URL% | |
| 216 set ERRORLEVEL=1 | |
| 217 goto :END | |
| 218 | |
| 219 | |
| 220 :returncode | 73 :returncode |
| 221 set WIN_TOOLS_ROOT_DIR= | 74 set WIN_TOOLS_ROOT_DIR= |
| 222 exit /b %ERRORLEVEL% | 75 exit /b %ERRORLEVEL% |
| 223 | 76 |
| 224 :END | 77 :END |
| 225 call :returncode %ERRORLEVEL% | 78 call :returncode %ERRORLEVEL% |
| OLD | NEW |