|
|
|
@echo off
|
|
|
|
:: Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
:: Use of this source code is governed by a BSD-style license that can be
|
|
|
|
:: found in the LICENSE file.
|
|
|
|
|
|
|
|
:: This script will determine if python or git binaries need updates. It
|
|
|
|
:: returns 123 if the user's shell must restart, otherwise !0 is failure
|
|
|
|
|
|
|
|
:: Sadly, we can't use SETLOCAL here otherwise it ERRORLEVEL is not correctly
|
|
|
|
:: returned.
|
|
|
|
|
|
|
|
set CHROME_INFRA_URL=https://storage.googleapis.com/chrome-infra/
|
|
|
|
:: It used to be %~dp0 but ADODB.Stream may fail to write to this directory if
|
|
|
|
:: the directory DACL is set to elevated integrity level.
|
|
|
|
set ZIP_DIR=%TEMP%
|
|
|
|
|
|
|
|
:: Get absolute root directory (.js scripts don't handle relative paths well).
|
|
|
|
pushd %~dp0..\..
|
|
|
|
set WIN_TOOLS_ROOT_DIR=%CD%
|
|
|
|
popd
|
|
|
|
|
|
|
|
if "%1" == "force" (
|
|
|
|
set WIN_TOOLS_FORCE=1
|
|
|
|
shift /1
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
:PYTHON_CHECK
|
[bootstrap/win] Enable revert from upcoming patch.
The upcoming CL, https://chromium-review.googlesource.com/c/563036,
updates "bootstrap/win"'s mechanism. However, if that patch needs to be
reverted, its "python.bat" stub may still exist in the reverted
repository, and will continue to point to the reverted toolchain.
We don't have a good way to detect whether we should revert "python.bat".
Instead, we will look a file generated by the CL,
"//python_bin_reldir.txt". If we find it, we will assume that the updated
"python.bat" is in use, and reinstall.
Note that if that CL lands and does not require a revert, this logic
will be deleted. It's just there as a safety mechanism to allow a safe
revert.
BUG=chromium:740171
TEST=local
Change-Id: Ifc638cf0512d2a889c37fbf6b8e3f7a3269331b1
Reviewed-on: https://chromium-review.googlesource.com/566073
Commit-Queue: Daniel Jacques <dnj@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
8 years ago
|
|
|
:: Support revert from https://chromium-review.googlesource.com/c/563036
|
|
|
|
::
|
|
|
|
:: If the "python.bat" from that CL is installed, we will not know to
|
|
|
|
:: replace it if the CL is reverted. To support this, we will actively
|
|
|
|
:: destroy our "python.bat" if we detect a "python_bin_reldir.txt" file
|
|
|
|
:: present, causing us to reinstall Python.
|
|
|
|
if exist "%WIN_TOOLS_ROOT_DIR%\python_bin_reldir.txt" (
|
[bootstrap/win] Replace "python.bat" only on downgrade.
We're implementing a bootstrap downgrade for potential revert of
https://chromium-review.googlesource.com/c/563036
Currently, the downgrade sees the presence of the landed patch
as a sign to completely reinstall Python. However, this causes
the "python276_bin" directory to be deleted, which both ruins
any running process (notably "service manager" and BuildBot)
and fails due to those running processes, leaving the system in
a broken state.
Instead, we'll view the revert path as a signal to swap in the
old "python.bat" specifically, then fall through to standard
installation detection. Since the upgrade will not actually
delete "python276_bin", the expected revert case will leave it
alone, preserving existing execution environments.
BUG=chromium:740966, chromium:740171
TEST=local
- Ran simulation of revert path with this change, observed
better outcome.
Change-Id: I0dfa5924a27bcaba49134272a344f7b9f1d475c5
Reviewed-on: https://chromium-review.googlesource.com/567167
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Daniel Jacques <dnj@chromium.org>
8 years ago
|
|
|
call copy /y "%~dp0python276.new.bat" "%WIN_TOOLS_ROOT_DIR%\python.bat" 1>nul
|
[bootstrap/win] Enable revert from upcoming patch.
The upcoming CL, https://chromium-review.googlesource.com/c/563036,
updates "bootstrap/win"'s mechanism. However, if that patch needs to be
reverted, its "python.bat" stub may still exist in the reverted
repository, and will continue to point to the reverted toolchain.
We don't have a good way to detect whether we should revert "python.bat".
Instead, we will look a file generated by the CL,
"//python_bin_reldir.txt". If we find it, we will assume that the updated
"python.bat" is in use, and reinstall.
Note that if that CL lands and does not require a revert, this logic
will be deleted. It's just there as a safety mechanism to allow a safe
revert.
BUG=chromium:740171
TEST=local
Change-Id: Ifc638cf0512d2a889c37fbf6b8e3f7a3269331b1
Reviewed-on: https://chromium-review.googlesource.com/566073
Commit-Queue: Daniel Jacques <dnj@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
8 years ago
|
|
|
del "%WIN_TOOLS_ROOT_DIR%\python_bin_reldir.txt"
|
|
|
|
)
|
|
|
|
|
|
|
|
if not exist "%WIN_TOOLS_ROOT_DIR%\python276_bin" goto :PY27_INSTALL
|
|
|
|
if not exist "%WIN_TOOLS_ROOT_DIR%\python.bat" goto :PY27_INSTALL
|
|
|
|
set ERRORLEVEL=0
|
|
|
|
goto :GIT_CHECK
|
|
|
|
|
|
|
|
|
|
|
|
:PY27_INSTALL
|
|
|
|
echo Installing python 2.7.6...
|
|
|
|
:: Cleanup python directory if it was existing.
|
|
|
|
set PYTHON_URL=%CHROME_INFRA_URL%python276_bin.zip
|
|
|
|
if exist "%WIN_TOOLS_ROOT_DIR%\python276_bin\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\python276_bin"
|
|
|
|
if exist "%ZIP_DIR%\python276.zip" del "%ZIP_DIR%\python276.zip"
|
|
|
|
echo Fetching from %PYTHON_URL%
|
|
|
|
cscript //nologo //e:jscript "%~dp0get_file.js" %PYTHON_URL% "%ZIP_DIR%\python276_bin.zip"
|
|
|
|
if errorlevel 1 goto :PYTHON_FAIL
|
|
|
|
:: Will create python276_bin\...
|
|
|
|
cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\python276_bin.zip" "%WIN_TOOLS_ROOT_DIR%"
|
|
|
|
:: Create the batch files.
|
|
|
|
call copy /y "%~dp0python276.new.bat" "%WIN_TOOLS_ROOT_DIR%\python.bat" 1>nul
|
|
|
|
call copy /y "%~dp0pylint.new.bat" "%WIN_TOOLS_ROOT_DIR%\pylint.bat" 1>nul
|
|
|
|
del "%ZIP_DIR%\python276_bin.zip"
|
|
|
|
set ERRORLEVEL=0
|
|
|
|
goto :GIT_CHECK
|
|
|
|
|
|
|
|
|
|
|
|
:PYTHON_FAIL
|
|
|
|
echo ... Failed to checkout python automatically.
|
|
|
|
echo You should get the "prebaked" version at %PYTHON_URL%
|
|
|
|
set ERRORLEVEL=1
|
|
|
|
goto :END
|
|
|
|
|
|
|
|
:GIT_CHECK
|
|
|
|
"%WIN_TOOLS_ROOT_DIR%\python.bat" "%~dp0git_bootstrap.py"
|
|
|
|
goto :END
|
|
|
|
|
|
|
|
:returncode
|
|
|
|
set WIN_TOOLS_ROOT_DIR=
|
|
|
|
exit /b %ERRORLEVEL%
|
|
|
|
|
|
|
|
:END
|
|
|
|
call :returncode %ERRORLEVEL%
|