Honor quiet update mode in installers
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
This commit is contained in:
+23
-16
@@ -17,6 +17,13 @@ param(
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Quiet = $env:DOSH_UPDATE_QUIET -and $env:DOSH_UPDATE_QUIET -ne "0"
|
||||
|
||||
function Write-Info($Message) {
|
||||
if (-not $Quiet) {
|
||||
Write-Host $Message
|
||||
}
|
||||
}
|
||||
|
||||
function Require-Command($Name) {
|
||||
if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
|
||||
@@ -31,7 +38,7 @@ function Ensure-Cargo {
|
||||
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||
throw "cargo not found and winget is unavailable; install Rust from https://rustup.rs or set DOSH_USE_PREBUILT=1"
|
||||
}
|
||||
Write-Host "cargo not found; installing Rust toolchain with winget/rustup"
|
||||
Write-Info "cargo not found; installing Rust toolchain with winget/rustup"
|
||||
winget install --id Rustlang.Rustup -e --accept-package-agreements --accept-source-agreements
|
||||
$cargoBin = Join-Path $HOME ".cargo\bin"
|
||||
if (Test-Path $cargoBin) {
|
||||
@@ -358,7 +365,7 @@ function Install-Prebuilt {
|
||||
$extract = Join-Path $tmp "extract"
|
||||
try {
|
||||
New-Item -ItemType Directory -Force -Path $tmp, $extract | Out-Null
|
||||
Write-Host "Trying Dosh prebuilt $(Release-ArtifactName)"
|
||||
Write-Info "Trying Dosh prebuilt $(Release-ArtifactName)"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zip
|
||||
Verify-ArchiveChecksum $url $zip
|
||||
Expand-Archive -Force -Path $zip -DestinationPath $extract
|
||||
@@ -427,7 +434,7 @@ if ($UsePrebuilt) {
|
||||
if ($BinaryRequired) {
|
||||
throw "prebuilt install failed and DOSH_BINARY_REQUIRED=1"
|
||||
}
|
||||
Write-Host "Falling back to source build"
|
||||
Write-Info "Falling back to source build"
|
||||
Install-FromSource
|
||||
}
|
||||
} else {
|
||||
@@ -488,17 +495,17 @@ predict = true
|
||||
|
||||
Add-UserPath $bindir
|
||||
|
||||
Write-Host "Installed Dosh client to $bindir"
|
||||
Write-Host "Configured UDP port $Port"
|
||||
Write-Host ""
|
||||
Write-Info "Installed Dosh client to $bindir"
|
||||
Write-Info "Configured UDP port $Port"
|
||||
Write-Info ""
|
||||
$displayServer = if ($Server) { $Server } else { "user@host" }
|
||||
Write-Host "Client commands:"
|
||||
Write-Host " $bindir\dosh.exe $displayServer"
|
||||
Write-Host " $bindir\dosh.exe setup <ssh-alias>"
|
||||
Write-Host " $bindir\dosh.exe update --check"
|
||||
Write-Host ""
|
||||
Write-Host "Client config:"
|
||||
Write-Host " $configDir\client.toml"
|
||||
Write-Host " $configDir\hosts.toml"
|
||||
Write-Host ""
|
||||
Write-Host "Open a new terminal for PATH changes to apply."
|
||||
Write-Info "Client commands:"
|
||||
Write-Info " $bindir\dosh.exe $displayServer"
|
||||
Write-Info " $bindir\dosh.exe setup <ssh-alias>"
|
||||
Write-Info " $bindir\dosh.exe update --check"
|
||||
Write-Info ""
|
||||
Write-Info "Client config:"
|
||||
Write-Info " $configDir\client.toml"
|
||||
Write-Info " $configDir\hosts.toml"
|
||||
Write-Info ""
|
||||
Write-Info "Open a new terminal for PATH changes to apply."
|
||||
|
||||
+5
-5
@@ -457,7 +457,7 @@ try_install_prebuilt() {
|
||||
tmpdir="$(mktemp -d)"
|
||||
archive="$tmpdir/$(release_artifact_name)"
|
||||
checksum_file="$archive.sha256"
|
||||
[ "$quiet" = "1" ] && echo "Trying Dosh prebuilt $(release_artifact_name)"
|
||||
[ "$quiet" != "1" ] && echo "Trying Dosh prebuilt $(release_artifact_name)"
|
||||
need curl
|
||||
need tar
|
||||
if ! curl -fsL "$download_url" -o "$archive" 2>/dev/null; then
|
||||
@@ -501,7 +501,7 @@ install_from_source() {
|
||||
need git
|
||||
mkdir -p "$(dirname "$update_cache")"
|
||||
if [ -d "$update_cache/.git" ]; then
|
||||
[ "$quiet" = "1" ] && echo "Updating Dosh source"
|
||||
[ "$quiet" != "1" ] && echo "Updating Dosh source"
|
||||
git -C "$update_cache" remote set-url origin "$repo"
|
||||
if [ "$quiet" = "1" ]; then
|
||||
git -C "$update_cache" fetch -q --depth 1 origin main
|
||||
@@ -510,7 +510,7 @@ install_from_source() {
|
||||
fi
|
||||
git -C "$update_cache" checkout -q -B main FETCH_HEAD
|
||||
else
|
||||
[ "$quiet" = "1" ] && echo "Downloading Dosh source"
|
||||
[ "$quiet" != "1" ] && echo "Downloading Dosh source"
|
||||
rm -rf "$update_cache"
|
||||
if [ "$quiet" = "1" ]; then
|
||||
git clone -q --depth 1 --branch main "$repo" "$update_cache" >/dev/null
|
||||
@@ -522,7 +522,7 @@ install_from_source() {
|
||||
fi
|
||||
|
||||
cd "$src_dir"
|
||||
[ "$quiet" = "1" ] && echo "Building Dosh $role"
|
||||
[ "$quiet" != "1" ] && echo "Building Dosh $role"
|
||||
if [ "$role" = "client" ]; then
|
||||
if [ "$quiet" = "1" ]; then
|
||||
cargo build -q --release --bin dosh-client
|
||||
@@ -577,7 +577,7 @@ if [ "$use_prebuilt" != "0" ]; then
|
||||
if [ "$binary_required" = "1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
[ "$quiet" = "1" ] && echo "Falling back to source build"
|
||||
[ "$quiet" != "1" ] && echo "Falling back to source build"
|
||||
install_from_source
|
||||
fi
|
||||
else
|
||||
|
||||
@@ -6,6 +6,12 @@ fn quiet_update_keeps_prebuilt_enabled_by_default() {
|
||||
!install.contains("use_prebuilt=0"),
|
||||
"quiet updates must not force source builds"
|
||||
);
|
||||
assert!(install.contains("[ \"$quiet\" != \"1\" ] && echo \"Trying Dosh prebuilt"));
|
||||
assert!(install.contains("[ \"$quiet\" != \"1\" ] && echo \"Building Dosh $role\""));
|
||||
assert!(
|
||||
!install.contains("[ \"$quiet\" = \"1\" ] && echo"),
|
||||
"quiet updates must suppress informational installer output"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -159,6 +165,25 @@ fn windows_installer_bootstraps_rust_for_source_fallback_like_unix() {
|
||||
assert!(!ps1.contains("Require-Command cargo"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_installer_honors_quiet_update_mode() {
|
||||
let ps1 = include_str!("../install.ps1");
|
||||
assert!(ps1.contains("$Quiet = $env:DOSH_UPDATE_QUIET"));
|
||||
assert!(ps1.contains("function Write-Info($Message)"));
|
||||
assert!(ps1.contains("if (-not $Quiet)"));
|
||||
assert!(ps1.contains("Write-Info \"Trying Dosh prebuilt"));
|
||||
assert!(ps1.contains("Write-Info \"Falling back to source build\""));
|
||||
assert!(ps1.contains("Write-Info \"Installed Dosh client to $bindir\""));
|
||||
assert!(
|
||||
!ps1.contains("Write-Host \"Trying Dosh prebuilt"),
|
||||
"Windows quiet update must not print prebuilt progress directly"
|
||||
);
|
||||
assert!(
|
||||
!ps1.contains("Write-Host \"Installed Dosh client"),
|
||||
"Windows quiet update must not print install summary directly"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_installer_adds_user_path_idempotently() {
|
||||
let ps1 = include_str!("../install.ps1");
|
||||
|
||||
Reference in New Issue
Block a user