Add cipd bootstrap scripts to depot_tools.
This takes advantage of powershell on windows for a cleanish duplicate of the posix version. R=dnj@chromium.org, vadimsh@chromium.org BUG=663843 Change-Id: Ib23a044ff912e3239b58848a26143eb6575826d5 Reviewed-on: https://chromium-review.googlesource.com/414228 Commit-Queue: Robbie Iannucci <iannucci@chromium.org> Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>changes/28/414228/9
parent
cbec8efcee
commit
2188fe944f
@ -0,0 +1,6 @@
|
||||
@echo off
|
||||
:: Copyright (c) 2016 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.
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy RemoteSigned -File "%~dp0\cipd.ps1" %*
|
@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2016 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.
|
||||
|
||||
$myPath = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
|
||||
function GetEnvVar([string] $key, [scriptblock] $defaultFn) {
|
||||
if (Test-Path "Env:\$key") {
|
||||
return Get-ChildItem $Env $key
|
||||
}
|
||||
return $defaultFn.Invoke()
|
||||
}
|
||||
|
||||
$cipdClientVer = GetEnvVar "CIPD_CLIENT_VER" {
|
||||
Get-Content (Join-Path $myPath -ChildPath 'cipd_client_version') -First 1
|
||||
}
|
||||
$cipdClientSrv = GetEnvVar "CIPD_CLIENT_SRV" {
|
||||
"https://chrome-infra-packages.appspot.com"
|
||||
}
|
||||
|
||||
$plat="windows"
|
||||
if ([environment]::Is64BitOperatingSystem) {
|
||||
$arch="amd64"
|
||||
} else {
|
||||
$arch="386"
|
||||
}
|
||||
|
||||
$url = "$cipdClientSrv/client?platform=$plat-$arch&version=$cipdClientVer"
|
||||
$client = Join-Path $myPath -ChildPath ".cipd_client.exe"
|
||||
|
||||
$depot_tools_version = &git -C $myPath rev-parse HEAD 2>&1
|
||||
if ($LastExitCode -eq 0) {
|
||||
$user_agent = "depot_tools/$depot_tools_version"
|
||||
} else {
|
||||
$user_agent = "depot_tools/???"
|
||||
}
|
||||
|
||||
$Env:CIPD_HTTP_USER_AGENT_PREFIX = $user_agent
|
||||
if (!(Test-Path $client)) {
|
||||
echo "Bootstrapping cipd client for $plat-$arch..."
|
||||
echo "From $url"
|
||||
# TODO(iannucci): It would be really nice if there was a way to get this to
|
||||
# show progress without also completely destroying the download speed, but
|
||||
# I can't seem to find a way to do it. Patches welcome :)
|
||||
$wc = (New-Object System.Net.WebClient)
|
||||
$wc.Headers.add('User-Agent', $user_agent)
|
||||
$wc.DownloadFile($url, $client)
|
||||
}
|
||||
|
||||
$_ = & $client selfupdate -version "$cipdClientVer"
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Host "selfupdate failed: " -ForegroundColor Red -NoNewline
|
||||
Write-Host "run ``set CIPD_HTTP_USER_AGENT_PREFIX=$user_agent/manual && $client selfupdate -version $cipdClientVer`` to diagnose`n" -ForegroundColor White
|
||||
}
|
||||
|
||||
& $client @args
|
||||
exit $LastExitCode
|
@ -0,0 +1 @@
|
||||
git_revision:05844bd9d1200cba8449b936b76e25eb90eabe25
|
Loading…
Reference in New Issue