Reuse Windows update source cache
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
This commit is contained in:
+36
-7
@@ -11,6 +11,7 @@ param(
|
|||||||
[string]$BinaryBase = $env:DOSH_BINARY_BASE,
|
[string]$BinaryBase = $env:DOSH_BINARY_BASE,
|
||||||
[string]$BinaryName = $env:DOSH_BINARY_NAME,
|
[string]$BinaryName = $env:DOSH_BINARY_NAME,
|
||||||
[string]$BinaryVersion = $(if ($env:DOSH_BINARY_VERSION) { $env:DOSH_BINARY_VERSION } else { "latest" }),
|
[string]$BinaryVersion = $(if ($env:DOSH_BINARY_VERSION) { $env:DOSH_BINARY_VERSION } else { "latest" }),
|
||||||
|
[string]$UpdateCache = $(if ($env:DOSH_UPDATE_CACHE) { $env:DOSH_UPDATE_CACHE } else { Join-Path $HOME ".cache\dosh\source" }),
|
||||||
[switch]$BinaryRequired = $($env:DOSH_BINARY_REQUIRED -and $env:DOSH_BINARY_REQUIRED -ne "0"),
|
[switch]$BinaryRequired = $($env:DOSH_BINARY_REQUIRED -and $env:DOSH_BINARY_REQUIRED -ne "0"),
|
||||||
[switch]$ForceConfig
|
[switch]$ForceConfig
|
||||||
)
|
)
|
||||||
@@ -268,6 +269,27 @@ function Install-Binary($Source, $Destination) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Normalize-PathForCompare($Path) {
|
||||||
|
[System.IO.Path]::GetFullPath($Path).TrimEnd(
|
||||||
|
[System.IO.Path]::DirectorySeparatorChar,
|
||||||
|
[System.IO.Path]::AltDirectorySeparatorChar
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Assert-SafeUpdateCache($Path) {
|
||||||
|
if (-not $Path) {
|
||||||
|
throw "refusing unsafe update cache path: $Path"
|
||||||
|
}
|
||||||
|
$full = Normalize-PathForCompare $Path
|
||||||
|
$root = Normalize-PathForCompare ([System.IO.Path]::GetPathRoot($full))
|
||||||
|
$homePath = Normalize-PathForCompare $HOME
|
||||||
|
$homeCache = Normalize-PathForCompare (Join-Path $HOME ".cache")
|
||||||
|
if ($full -eq $root -or $full -eq $homePath -or $full -eq $homeCache) {
|
||||||
|
throw "refusing unsafe update cache path: $Path"
|
||||||
|
}
|
||||||
|
$full
|
||||||
|
}
|
||||||
|
|
||||||
$bindir = Join-Path $Prefix "bin"
|
$bindir = Join-Path $Prefix "bin"
|
||||||
$configDir = Join-Path $HOME ".config\dosh"
|
$configDir = Join-Path $HOME ".config\dosh"
|
||||||
New-Item -ItemType Directory -Force -Path $bindir, $configDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $bindir, $configDir | Out-Null
|
||||||
@@ -316,7 +338,6 @@ function Install-Prebuilt {
|
|||||||
|
|
||||||
function Install-FromSource {
|
function Install-FromSource {
|
||||||
Require-Command cargo
|
Require-Command cargo
|
||||||
$tmp = $null
|
|
||||||
if (Test-Path "Cargo.toml") {
|
if (Test-Path "Cargo.toml") {
|
||||||
$src = (Get-Location).Path
|
$src = (Get-Location).Path
|
||||||
} else {
|
} else {
|
||||||
@@ -324,9 +345,20 @@ function Install-FromSource {
|
|||||||
throw "DOSH_REPO is required when running the installer from irm/iex"
|
throw "DOSH_REPO is required when running the installer from irm/iex"
|
||||||
}
|
}
|
||||||
Require-Command git
|
Require-Command git
|
||||||
$tmp = Join-Path ([System.IO.Path]::GetTempPath()) ("dosh-" + [guid]::NewGuid())
|
$sourceCache = Assert-SafeUpdateCache $UpdateCache
|
||||||
git clone --depth 1 $Repo $tmp | Out-Null
|
$parent = Split-Path -Parent $sourceCache
|
||||||
$src = $tmp
|
New-Item -ItemType Directory -Force -Path $parent | Out-Null
|
||||||
|
if (Test-Path (Join-Path $sourceCache ".git")) {
|
||||||
|
git -C $sourceCache remote set-url origin $Repo
|
||||||
|
git -C $sourceCache fetch --depth 1 origin main
|
||||||
|
git -C $sourceCache checkout -q -B main FETCH_HEAD
|
||||||
|
} else {
|
||||||
|
if (Test-Path $sourceCache) {
|
||||||
|
Remove-Item -Recurse -Force $sourceCache
|
||||||
|
}
|
||||||
|
git clone --depth 1 --branch main $Repo $sourceCache | Out-Null
|
||||||
|
}
|
||||||
|
$src = $sourceCache
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -338,9 +370,6 @@ function Install-FromSource {
|
|||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
if ($tmp) {
|
|
||||||
Remove-Item -Recurse -Force $tmp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,20 @@ fn installers_refuse_prebuilts_without_checksums() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn windows_installer_reuses_persistent_source_update_cache() {
|
||||||
|
let ps1 = include_str!("../install.ps1");
|
||||||
|
assert!(ps1.contains("DOSH_UPDATE_CACHE"));
|
||||||
|
assert!(ps1.contains("$sourceCache = Assert-SafeUpdateCache $UpdateCache"));
|
||||||
|
assert!(ps1.contains("git -C $sourceCache fetch --depth 1 origin main"));
|
||||||
|
assert!(ps1.contains("git -C $sourceCache checkout -q -B main FETCH_HEAD"));
|
||||||
|
assert!(ps1.contains("git clone --depth 1 --branch main $Repo $sourceCache"));
|
||||||
|
assert!(
|
||||||
|
!ps1.contains("git clone --depth 1 $Repo $tmp"),
|
||||||
|
"Windows source updates should reuse a persistent cache instead of recloning into temp"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn package_check_verifies_only_artifacts_it_builds() {
|
fn package_check_verifies_only_artifacts_it_builds() {
|
||||||
let makefile = include_str!("../Makefile");
|
let makefile = include_str!("../Makefile");
|
||||||
|
|||||||
Reference in New Issue
Block a user