Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: bootstrap/win/win_tools.bat

Issue 1848353003: Make msys depot_tools upgrade process smoother. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: add comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gclient » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 determine if python, git, or svn binaries need updates. It
7 :: it will try to download it and 'install' it in depot_tools. 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 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 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).
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 set GIT_FETCH_URL=https://storage.googleapis.com/chrome-infra/PortableGit-%GIT_V ERSION%-bit.7z.exe 76 set GIT_FETCH_URL=https://storage.googleapis.com/chrome-infra/PortableGit-%GIT_V ERSION%-bit.7z.exe
77 set GIT_DOWNLOAD_PATH=%ZIP_DIR%\git.7z.exe 77 set GIT_DOWNLOAD_PATH=%ZIP_DIR%\git.7z.exe
78 set GIT_BIN_DIR=git-%GIT_VERSION%_bin 78 set GIT_BIN_DIR=git-%GIT_VERSION%_bin
79 set GIT_INST_DIR=%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR% 79 set GIT_INST_DIR=%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%
80 set GIT_EXE_PATH=%GIT_INST_DIR%\bin\git.exe 80 set GIT_EXE_PATH=%GIT_INST_DIR%\bin\git.exe
81 81
82 :: Clean up any release which doesn't match the one we want. 82 :: Clean up any release which doesn't match the one we want.
83 for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do ( 83 for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do (
84 if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" ( 84 if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" (
85 echo Cleaning old git installation %%i 85 echo Cleaning old git installation %%i
86 rmdir /s /q "%%i" 86 rmdir /s /q "%%i" > NUL
87 ) 87 )
88 ) 88 )
89 89
90 if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL 90 if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL
91 91
92 if not exist "%GIT_EXE_PATH%" goto :GIT_INSTALL 92 if not exist "%GIT_EXE_PATH%" goto :GIT_INSTALL
93 93
94 call "%GIT_EXE_PATH%" --version 2>nul 1>nul 94 call "%GIT_EXE_PATH%" --version 2>nul 1>nul
95 if errorlevel 1 goto :GIT_INSTALL 95 if errorlevel 1 goto :GIT_INSTALL
96 96
97 :: Several git versions can live side-by-side; check the top-level 97 :: Several git versions can live side-by-side; check the top-level
98 :: batch script to make sure it points to the desired version. 98 :: batch script to make sure it points to the desired version.
99 for %%f in (git.bat gitk.bat ssh.bat ssh-keygen.bat git-bash) do ( 99 for %%f in (git.bat gitk.bat ssh.bat ssh-keygen.bat git-bash) do (
100 find "%GIT_BIN_DIR%" "%WIN_TOOLS_ROOT_DIR%\%%f" 2>nul 1>nul 100 %FIND_EXE% "%GIT_BIN_DIR%" "%WIN_TOOLS_ROOT_DIR%\%%f" 2>nul 1>nul
101 if errorlevel 1 goto :GIT_MAKE_BATCH_FILES 101 if errorlevel 1 goto :GIT_MAKE_BATCH_FILES
102 ) 102 )
103 goto :SYNC_GIT_HELP_FILES 103 goto :SYNC_GIT_HELP_FILES
104 104
105 :GIT_INSTALL 105 :GIT_INSTALL
106 echo Installing git %GIT_VERSION% (avg 1-2 min download) ... 106 echo Installing git %GIT_VERSION% (avg 1-2 min download) ...
107 107
108 if exist "%GIT_DOWNLOAD_PATH%" del "%GIT_DOWNLOAD_PATH%" 108 if exist "%GIT_DOWNLOAD_PATH%" del "%GIT_DOWNLOAD_PATH%"
109 echo Fetching from %GIT_FETCH_URL% 109 echo Fetching from %GIT_FETCH_URL%
110 cscript //nologo //e:jscript "%~dp0get_file.js" %GIT_FETCH_URL% "%GIT_DOWNLOAD_P ATH%" 110 cscript //nologo //e:jscript "%~dp0get_file.js" %GIT_FETCH_URL% "%GIT_DOWNLOAD_P ATH%"
111 if errorlevel 1 goto :GIT_FAIL 111 if errorlevel 1 goto :GIT_FAIL
112 :: Cleanup git directory if it already exists. 112 :: Cleanup git directory if it already exists.
113 if exist "%GIT_INST_DIR%\." rd /q /s "%GIT_INST_DIR%" 113 if exist "%GIT_INST_DIR%\." rd /q /s "%GIT_INST_DIR%"
114 114
115 :: run PortableGit self-extractor 115 :: run PortableGit self-extractor
116 :: -y : Be Quiet ("yes") 116 :: -y : Be Quiet ("yes")
117 :: -sd1 : Self delete SFX archive 117 :: -sd1 : Self delete SFX archive
118 :: -InstallPath : Where to put the files 118 :: -InstallPath : Where to put the files
119 :: -Directory : Run the post-extract program with this current-working-directory 119 :: -Directory : Run the post-extract program with this current-working-directory
120 :: 120 ::
121 :: Path slashes must be escaped or the 7zip sfx treats e.g. path\to\dir as 121 :: Path slashes must be escaped or the 7zip sfx treats e.g. path\to\dir as
122 :: path[tab]o\dir. 122 :: path[tab]o\dir.
123 set GIT_INST_DIR_ESC=%GIT_INST_DIR:\=\\% 123 set GIT_INST_DIR_ESC=%GIT_INST_DIR:\=\\%
124 call "%GIT_DOWNLOAD_PATH%" -y -sd1 -InstallPath="%GIT_INST_DIR_ESC%" -Directory= "%GIT_INST_DIR_ESC%" 124 call "%GIT_DOWNLOAD_PATH%" -y -sd1 -InstallPath="%GIT_INST_DIR_ESC%" -Directory= "%GIT_INST_DIR_ESC%"
125 if errorlevel 1 goto :GIT_FAIL 125 if errorlevel 1 goto :GIT_FAIL
126 126
127 del "%GIT_DOWNLOAD_PATH%" 127 del "%GIT_DOWNLOAD_PATH%"
128 if not exist "%GIT_INST_DIR%\." goto :GIT_FAIL 128 if not exist "%GIT_INST_DIR%\." goto :GIT_FAIL
129 129
130 set DID_UPGRADE=1
131
130 :GIT_MAKE_BATCH_FILES 132 :GIT_MAKE_BATCH_FILES
131 :: Create the batch files. 133 :: Create the batch files.
132 set GIT_TEMPL=%~dp0git.template.bat 134 set GIT_TEMPL=%~dp0git.template.bat
133 set SED=%GIT_INST_DIR%\usr\bin\sed.exe 135 set SED=%GIT_INST_DIR%\usr\bin\sed.exe
134 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" 136 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"
135 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" 137 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"
136 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" 138 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"
137 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" 139 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"
138 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" 140 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"
139 141
140 :: Ensure various git configurations are set correctly at they system level. 142 :: Ensure various git configurations are set correctly at they system level.
141 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.autocrlf false 143 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.autocrlf false
142 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.filemode false 144 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.filemode false
143 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.preloadindex true 145 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.preloadindex true
144 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.fscache true 146 call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.fscache true
145 147
146 :SYNC_GIT_HELP_FILES 148 :SYNC_GIT_HELP_FILES
147 :: Copy all the depot_tools docs into the mingw64 git docs root. 149 :: Copy all the depot_tools docs into the mingw64 git docs root.
148 :: /i : Make sure xcopy knows that the destination names a folder, not a file 150 :: /i : Make sure xcopy knows that the destination names a folder, not a file
149 :: /q : Make xcopy quiet (though it still prints a `X File(s) copied` message 151 :: /q : Make xcopy quiet (though it still prints a `X File(s) copied` message
150 :: which is why we have the > NUL) 152 :: which is why we have the > NUL)
151 :: /d : Copy source files that are newer than the corresponding destination 153 :: /d : Copy source files that are newer than the corresponding destination
152 :: files only. This prevents excessive copying when none of the docs 154 :: files only. This prevents excessive copying when none of the docs
153 :: actually changed. 155 :: actually changed.
154 :: /y : Don't prompt for overwrites (yes) 156 :: /y : Don't prompt for overwrites (yes)
155 xcopy /i /q /d /y "%WIN_TOOLS_ROOT_DIR%\man\html\*" "%GIT_INST_DIR%\mingw64\shar e\doc\git-doc" > NUL 157 xcopy /i /q /d /y "%WIN_TOOLS_ROOT_DIR%\man\html\*" "%GIT_INST_DIR%\mingw64\shar e\doc\git-doc" > NUL
156 158
159 :: MSYS users need to restart their shell.
160 if defined MSYSTEM if defined DID_UPGRADE (
161 echo.
162 echo.
163 echo IMPORTANT:
164 echo depot_tools' git distribution has been updated while inside of a MinGW
165 echo shell. In order to complete the upgrade, please exit the shell and re-run
166 echo `git bash` from cmd.
167 exit 123
168 )
169
157 goto :SVN_CHECK 170 goto :SVN_CHECK
158 171
159 :GIT_FAIL 172 :GIT_FAIL
160 echo ... Failed to checkout git automatically. 173 echo ... Failed to checkout git automatically.
161 echo You should get the "prebaked" version used at %GIT_FETCH_URL% 174 echo You should get the "prebaked" version used at %GIT_FETCH_URL%
162 set ERRORLEVEL=1 175 set ERRORLEVEL=1
163 goto :END 176 goto :END
164 177
165 178
166 :SVN_CHECK 179 :SVN_CHECK
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 goto :END 213 goto :END
201 214
202 215
203 :returncode 216 :returncode
204 set WIN_TOOLS_ROOT_URL= 217 set WIN_TOOLS_ROOT_URL=
205 set WIN_TOOLS_ROOT_DIR= 218 set WIN_TOOLS_ROOT_DIR=
206 exit /b %ERRORLEVEL% 219 exit /b %ERRORLEVEL%
207 220
208 :END 221 :END
209 call :returncode %ERRORLEVEL% 222 call :returncode %ERRORLEVEL%
OLDNEW
« no previous file with comments | « no previous file | gclient » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698