Browse Source

[cipd] Add windows-arm64 support to CIPD client bootstrap.

This actually updates the CIPD client to a version that has
a windows-arm64 build, as well as modifies the bootstrap script
to support multiple possible Windows platforms (which is very
similar to what was done to support mac-arm64 on OSX).

By default windows-amd64 is still used everywhere, even on arm64 OS.
To opt-in into windows-arm64, create a file .cipd_client_platform
under depot_tools directory with a single line "windows-arm64".

The bootstrap script now recognizes this file (if it exists) and
rebootstraps the CIPD client if the platform changes. Since this
check needs to happen on every CIPD invocation, it is done in
the batch file, to avoid hitting relatively heavy Powershell on
the hot path.

Finally, do some minor style cleanup in the powershell script to
make it look more consistent.

CIPD client change log:
https://chromium.googlesource.com/infra/luci/luci-go.git/+log/9cc9fd49..5252f4fc7/cipd

R=bryner@google.com

Change-Id: I4fe5c4ea5e0b5cbb43e7b8c4702dc9fb0627c056
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4153336
Reviewed-by: Brian Ryner <bryner@google.com>
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
Vadim Shtayura 2 years ago
parent
commit
4f3b322a39
4 changed files with 68 additions and 27 deletions
  1. 19 9
      .cipd_impl.ps1
  2. 30 0
      cipd.bat
  3. 1 1
      cipd_client_version
  4. 18 17
      cipd_client_version.digests

+ 19 - 9
.cipd_impl.ps1

@@ -11,19 +11,29 @@
 #     -VersionFile ./cipd_client_version
 #     -VersionFile ./cipd_client_version
 # file _cipd.exe
 # file _cipd.exe
 
 
-Param(
-  # Path to download the CIPD binary to.
-  [parameter(Mandatory=$true)][string]$CipdBinary,
-  # E.g. "https://chrome-infra-packages.appspot.com".
-  [parameter(Mandatory=$true)][string]$BackendURL,
-  # Path to the cipd_client_version file with the client version.
-  [parameter(Mandatory=$true)][string]$VersionFile
+param(
+    # Path to download the CIPD binary to.
+    [Parameter(Mandatory = $true)]
+    [string]
+    $CipdBinary,
+    
+    # CIPD platform to download the client for.
+    [string]
+    $Platform = "windows-amd64",
+
+    # E.g. "https://chrome-infra-packages.appspot.com".
+    [Parameter(Mandatory = $true)]
+    [string]
+    $BackendURL,
+
+    # Path to the cipd_client_version file with the client version.
+    [Parameter(Mandatory = $true)]
+    [string]
+    $VersionFile
 )
 )
 
 
 $DepotToolsPath = Split-Path $MyInvocation.MyCommand.Path -Parent
 $DepotToolsPath = Split-Path $MyInvocation.MyCommand.Path -Parent
 
 
-$Platform = "windows-amd64"
-
 # Put depot_tool's git revision into the user agent string.
 # Put depot_tool's git revision into the user agent string.
 try {
 try {
   $DepotToolsVersion = &git -C $DepotToolsPath rev-parse HEAD 2>&1
   $DepotToolsVersion = &git -C $DepotToolsPath rev-parse HEAD 2>&1

+ 30 - 0
cipd.bat

@@ -8,6 +8,35 @@ setlocal
 set CIPD_BACKEND=https://chrome-infra-packages.appspot.com
 set CIPD_BACKEND=https://chrome-infra-packages.appspot.com
 set VERSION_FILE=%~dp0cipd_client_version
 set VERSION_FILE=%~dp0cipd_client_version
 set CIPD_BINARY=%~dp0.cipd_client.exe
 set CIPD_BINARY=%~dp0.cipd_client.exe
+set CIPD_PLATFORM=windows-amd64
+set PLATFORM_OVERRIDE_FILE=%~dp0.cipd_client_platform
+
+:: Uncomment to recognize arm64 by default.
+:: if %PROCESSOR_ARCHITECTURE%==ARM64 (
+::   set CIPD_PLATFORM=windows-arm64
+:: )
+
+:: A value in .cipd_client_platform overrides the "guessed" platform.
+if exist "%PLATFORM_OVERRIDE_FILE%" (
+  for /F usebackq %%l in ("%PLATFORM_OVERRIDE_FILE%") do (
+    set CIPD_PLATFORM=%%l
+  )
+)
+
+:: Nuke the existing client if its platform doesn't match what we want now. We
+:: crudely search for a CIPD client package name in the .cipd_version JSON file.
+:: It has only "instance_id" as the other field (looking like a base64 string),
+:: so mismatches are very unlikely.
+set INSTALLED_VERSION_FILE=%~dp0.versions\.cipd_client.exe.cipd_version
+findstr /m "infra/tools/cipd/%CIPD_PLATFORM%" "%INSTALLED_VERSION_FILE%" 2>nul
+if %ERRORLEVEL% neq 0 (
+  if exist "%INSTALLED_VERSION_FILE%" (
+    echo Detected CIPD client platform change to %CIPD_PLATFORM%. 1>&2
+    echo Deleting the existing client to trigger the bootstrap... 1>&2
+    del "%CIPD_BINARY%"
+    del "%INSTALLED_VERSION_FILE%"
+  )
+)
 
 
 if not exist "%CIPD_BINARY%" (
 if not exist "%CIPD_BINARY%" (
   call :CLEAN_BOOTSTRAP
   call :CLEAN_BOOTSTRAP
@@ -50,6 +79,7 @@ echo.>"%~dp0.cipd_impl.ps1:Zone.Identifier"
 powershell -NoProfile -ExecutionPolicy RemoteSigned ^
 powershell -NoProfile -ExecutionPolicy RemoteSigned ^
     -File "%~dp0.cipd_impl.ps1" ^
     -File "%~dp0.cipd_impl.ps1" ^
     -CipdBinary "%CIPD_BINARY%" ^
     -CipdBinary "%CIPD_BINARY%" ^
+    -Platform "%CIPD_PLATFORM%" ^
     -BackendURL "%CIPD_BACKEND%" ^
     -BackendURL "%CIPD_BACKEND%" ^
     -VersionFile "%VERSION_FILE%" ^
     -VersionFile "%VERSION_FILE%" ^
   <nul
   <nul

+ 1 - 1
cipd_client_version

@@ -1 +1 @@
-git_revision:89ada246fcbf10f330011e4991d017332af2365b
+git_revision:81e5cdad29bb4c7aaad98c843637513db3155b0d

+ 18 - 17
cipd_client_version.digests

@@ -1,24 +1,25 @@
 # This file was generated by
 # This file was generated by
 #
 #
 #  cipd selfupdate-roll -version-file cipd_client_version \
 #  cipd selfupdate-roll -version-file cipd_client_version \
-#      -version git_revision:89ada246fcbf10f330011e4991d017332af2365b
+#      -version git_revision:81e5cdad29bb4c7aaad98c843637513db3155b0d
 #
 #
 # Do not modify manually. All changes will be overwritten.
 # Do not modify manually. All changes will be overwritten.
 # Use 'cipd selfupdate-roll ...' to modify.
 # Use 'cipd selfupdate-roll ...' to modify.
 
 
-aix-ppc64       sha256  bf60b679afae76b7d52f46453dc67af6938438c9c8543b40d49f62eb6edb7376
-linux-386       sha256  7f264198598af2ef9d8878349d33c1940f1f3739e46d986962c352ec4cce2690
-linux-amd64     sha256  2ada6b46ad1cd1350522c5c05899d273f5c894c7665e30104e7f57084a5aeeb9
-linux-arm64     sha256  96eca7e49f6732c50122b94b793c3a5e62ed77bce1686787a8334906791b4168
-linux-armv6l    sha256  06394601130652c5e1b055a7e4605c21fc7c6643af0b3b3cac8d2691491afa81
-linux-mips64    sha256  f3eda6542b381b7aa8f582698498b0e197972c894590ec35f18faa467c868f5c
-linux-mips64le  sha256  74229ada8e2afd9c8e7c58991126869b2880547780d4a197a27c1dfa96851622
-linux-mipsle    sha256  2f3c18ec0ad48cd44a9ff39bb60e9afded83ca43fb9c7a5ea9949f6fdd4e1394
-linux-ppc64     sha256  79425c0795fb8ba12b39a8856bf7ccb853e85def4317aa6413222f307d4c2dbd
-linux-ppc64le   sha256  f9b3d85dde70f1b78cd7a41d2477834c15ac713a59317490a4cdac9f8f092325
-linux-riscv64   sha256  bd695164563a66e8d3799e8835f90a398fbae9a4eec24e876c92d5f213943482
-linux-s390x     sha256  6f501af80541e733fda23b4208a21ea05919c95d236036a2121e6b6334a2792c
-mac-amd64       sha256  41d05580c0014912d6c32619c720646fd136e4557c9c7d7571ecc8c0462733a1
-mac-arm64       sha256  dc672bd16d9faf277dd562f1dc00644b10c03c5d838d3cc3d3ea29925d76d931
-windows-386     sha256  fa6ed0022a38ffc51ff8a927e3947fe7e59a64b2019dcddca9d3afacf7630444
-windows-amd64   sha256  b5423e4b4429837f7fe4d571ce99c068aa0ccb37ddbebc1978a423fd2b0086df
+aix-ppc64       sha256  94f91ea0510c321e05b2aeb91384aa0ef408502111eba3139f96233889830594
+linux-386       sha256  793e89413fbf76be97b5b40d96326e67cd8a52b807c450d0a0bf80eda841db9b
+linux-amd64     sha256  ee6be8d78509aafa583310548f08a4f3f63e7ee7aebffd1b139db4c9d07ab3ed
+linux-arm64     sha256  5ecf44dec64fdc90272096512fe1fc0e6df7472fad4a6ebc68041d4270e80882
+linux-armv6l    sha256  9acb7d3b96c85dbae3927a9b8228732d6b885ebbfeaa1e4d010dea7a3a74c7c6
+linux-mips64    sha256  ac678cca38e075ddf7629ff8bc97d7ff8a89962debd1f76d048ca33cbff2207e
+linux-mips64le  sha256  f90bcf95e4cf123f5465251beb53e137a1e9ba12a6636166e40137c62697e11b
+linux-mipsle    sha256  96a7a5e891b3fb38f0563a9d20a58b5bcda6a53f6fddf199083bd9f2cad9eec3
+linux-ppc64     sha256  a96529881650b24095b2147497a8e56aa24b4d7f3a27ec97d2f114731497f353
+linux-ppc64le   sha256  e90002d416080cc2f0e3cd9951c6c668836ca9f5e49fb67718146a782f66023b
+linux-riscv64   sha256  ab0598645341f5a9cf874918b382947fb4fc36c0d5f86c70477feb65d47f5d4d
+linux-s390x     sha256  e7e4fa8f1b60f9280f4b11a5a4be3acc7bbde923462bbd6f22400e0adb7892be
+mac-amd64       sha256  0707cb69e608d6b82b643ef898ac8b5c67abfa1cc244fe04f89cafd101d3c9c7
+mac-arm64       sha256  ee5983b13e382dde223edb6f395ae92df2d1744094a43d54bfbad26fc835cecb
+windows-386     sha256  9f6c95d71d71041df9254c6efa181f763e6589697c59489b76d72b1444eae57f
+windows-amd64   sha256  ddba94f29fe5281f4b9ef416effebd9f31e6910a12d66d8978d0aa0406a9c173
+windows-arm64   sha256  86da354a76a943c85146ee31f0f161518edada359b48179643bf3ad1aaad3bda