Fix .cipd_impl.ps1 failure because of execution policy

The introduction of the `-File` parameter for invoking .cipd_impl.ps1
made its execution dependent on the system's PowerShell ExecutionPolicy,
causing failures in restricted environments.

This CL solves following problems:

1. Failures when the depot_tools path contains whitespace.

2. Make cipd.bat behave consistently with how it did before introducing
   '-File'

Bug: 428834916
Change-Id: Idf16bfeb5d5188dc4a13ab3200f692d99b3d33af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7257554
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Sam Lewis <samclewis@google.com>
Commit-Queue: Sam Lewis <samclewis@google.com>
This commit is contained in:
equinoxtian
2025-12-17 11:03:54 -08:00
committed by LUCI CQ
parent d3d038869a
commit 7b56ac47e6

View File

@@ -10,6 +10,7 @@ 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 CIPD_PLATFORM=windows-amd64
set PLATFORM_OVERRIDE_FILE=%~dp0.cipd_client_platform set PLATFORM_OVERRIDE_FILE=%~dp0.cipd_client_platform
set CIPD_IMPL=%~dp0.cipd_impl.ps1
:: Uncomment to recognize arm64 by default. :: Uncomment to recognize arm64 by default.
:: if %PROCESSOR_ARCHITECTURE%==ARM64 ( :: if %PROCESSOR_ARCHITECTURE%==ARM64 (
@@ -75,13 +76,13 @@ exit /b %EXPORT_ERRORLEVEL%
:: and unzipping the depot_tools.zip distribution, we clear the Zone.Identifier :: and unzipping the depot_tools.zip distribution, we clear the Zone.Identifier
:: alternate data stream. This is equivalent to clicking the "Unblock" button :: alternate data stream. This is equivalent to clicking the "Unblock" button
:: in the file's properties dialog. :: in the file's properties dialog.
echo.>"%~dp0.cipd_impl.ps1:Zone.Identifier" echo.>"%CIPD_IMPL%:Zone.Identifier"
powershell -NoProfile -ExecutionPolicy RemoteSigned ^ powershell -NoProfile -ExecutionPolicy RemoteSigned ^
-File "%~dp0.cipd_impl.ps1" ^ -Command "& \"%CIPD_IMPL%\"" ^
-CipdBinary "%CIPD_BINARY%" ^ "-CipdBinary \"%CIPD_BINARY%\"" ^
-Platform "%CIPD_PLATFORM%" ^ "-Platform \"%CIPD_PLATFORM%\"" ^
-BackendURL "%CIPD_BACKEND%" ^ "-BackendURL \"%CIPD_BACKEND%\"" ^
-VersionFile "%VERSION_FILE%" ^ "-VersionFile \"%VERSION_FILE%\"" ^
<nul <nul
if %ERRORLEVEL% equ 0 ( if %ERRORLEVEL% equ 0 (
:: Need to call SELF_UPDATE to setup .cipd_version file. :: Need to call SELF_UPDATE to setup .cipd_version file.