devops: fix "ensure-depot-tools" script (#13303)

The script should is supposed to be sourced and thus
should not change any env variables of parent script
besides `$PATH`.
This commit is contained in:
Andrey Lushnikov 2022-04-04 16:19:36 -06:00 коммит произвёл GitHub
Родитель 6ef8b63e5d
Коммит 786b4a55fc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 15 удалений

Просмотреть файл

@ -11,18 +11,22 @@ if [[ $sourced == 0 ]]; then
exit 1
fi
# Install depot_tools if they are not in system, and modify $PATH
# to include depot_tools
if ! command -v autoninja >/dev/null; then
if [[ $(uname) == "MINGW"* ]]; then
# NOTE: as of Feb 8, 2021, windows requires manual and separate
# installation of depot_tools.
echo "ERROR: cannot automatically install depot_tools on windows. Please, install manually"
exit 1
function ensure_depot_tools() {
# Install depot_tools if they are not in system, and modify $PATH
# to include depot_tools
if ! command -v autoninja >/dev/null; then
if [[ $(uname) == "MINGW"* ]]; then
# NOTE: as of Feb 8, 2021, windows requires manual and separate
# installation of depot_tools.
echo "ERROR: cannot automatically install depot_tools on windows. Please, install manually"
exit 1
fi
local SCRIPT_PATH=$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)
if [[ ! -d "${SCRIPT_PATH}/depot_tools" ]]; then
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${SCRIPT_PATH}/depot_tools"
fi
export PATH="${SCRIPT_PATH}/depot_tools:$PATH"
fi
SCRIPT_PATH=$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)
if [[ ! -d "${SCRIPT_PATH}/depot_tools" ]]; then
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "${SCRIPT_PATH}/depot_tools"
fi
export PATH="${SCRIPT_PATH}/depot_tools:$PATH"
fi
}
ensure_depot_tools

Просмотреть файл

@ -30,6 +30,7 @@ fi
function prepare_chromium_checkout {
cd "${SCRIPT_PATH}"
source "${SCRIPT_PATH}/chromium/UPSTREAM_CONFIG.sh"
source "${SCRIPT_PATH}/chromium/ensure_depot_tools.sh"
if [[ -z "${CR_CHECKOUT_PATH}" ]]; then
@ -55,7 +56,6 @@ function prepare_chromium_checkout {
exit 1
fi
source "${SCRIPT_PATH}/chromium/UPSTREAM_CONFIG.sh"
cd "${CR_CHECKOUT_PATH}/src"
gclient sync --with_branch_heads
git fetch origin