From f8793b308a2ddadb78d435538ec9132ecfdcefd3 Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Sat, 11 Jul 2026 01:25:47 +1000 Subject: [PATCH] runtime.cmd (ps1): cached sha1sums fallback backported to list -remote (punkshell 0.8.1) - list -remote against an unreachable artifact server now warns and compares using the previously fetched sha1sums.txt instead of dying on an unhandled Invoke-WebRequest error (parity with the bash payload); no cached copy -> clear error + return - the fetch path always fell through silently to a cached sha1sums.txt on download failure - it now announces "proceeding with cached copy" (behaviour unchanged, messaging explicit) - fixed latent undefined-variable bug: the list -remote branch created the runtime folder with $container (only defined in the fetch branch) - now $archfolder - bin/runtime.cmd regenerated (checkfile clean, roundtrip pin green 9 pass + 1 skip); verified live: unreachable PUNKBIN_URL -> cached-fallback table renders (tclsfe-x64 "Same version" against the punkbin pin), normal fetch path unchanged Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com --- CHANGELOG.md | 4 ++++ bin/runtime.cmd | 27 +++++++++++++++++++++++---- punkproject.toml | 2 +- src/scriptapps/bin/runtime.ps1 | 27 +++++++++++++++++++++++---- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3336dc67..32979e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The latest `## [X.Y.Z]` header must match the `version` field in `punkproject.to Entries are newest-first; one bullet per notable change. See the root `AGENTS.md` "Project Versioning" section for the bump policy. +## [0.8.1] - 2026-07-11 + +- untime.cmd powershell payload: cached sha1sums.txt fallback backported from the bash payload - list -remote against an unreachable server now warns and compares using the previously fetched copy instead of dying on an unhandled download error, and the etch path's pre-existing silent fall-through to a cached copy now announces itself. Also fixed a latent undefined-variable bug creating the runtime folder in the list -remote branch. + ## [0.8.0] - 2026-07-11 - `runtime.cmd list -remote` parity for the unix (bash/zsh) payload: local-vs-server comparison table (Same version / UPDATE AVAILABLE / not-listed, plus remote-only entries), falling back to a cached `sha1sums.txt` with a warning when the server is unreachable. Both payloads gain a `PUNKBIN_URL` env override of the artifact server base url (mirrors/testing). diff --git a/bin/runtime.cmd b/bin/runtime.cmd index 25232842..992543f2 100755 --- a/bin/runtime.cmd +++ b/bin/runtime.cmd @@ -2147,6 +2147,10 @@ function psmain { if ($_.Exception.Response) { Write-Host "HTTP Status code: $($_.Exception.Response.StatusCode)" } + if (Test-Path -Path $sha1local -PathType Leaf) { + #this path always fell through to the cached copy - now say so + Write-Host "WARNING: proceeding with cached copy at $sha1local" + } } if (Test-Path -Path $sha1local -PathType Leaf) { $sha1Content = Get-Content -Path $sha1local @@ -2341,12 +2345,27 @@ function psmain { $sha1url = "$archurl/sha1sums.txt" if ( $PSBoundParameters.ContainsKey('remote') ) { if (-not (test-path -Path $archfolder -Type Container)) { - new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present + new-item -Path $archfolder -ItemType Directory -force #create with intermediary folders if not already present } - write-host "Checking for available remote runtimes for" + write-host "Checking for available remote runtimes for $arch" Write-Host "Fetching $sha1url" - Invoke-WebRequest -Uri $sha1url -OutFile $sha1local -ErrorAction Stop - Write-Host "sha1 saved at $sha1local" + #cached fallback (parity with the bash payload): an unreachable server + #falls back to a previously fetched sha1sums.txt with a warning + try { + Invoke-WebRequest -Uri $sha1url -OutFile $sha1local -ErrorAction Stop + Write-Host "sha1 saved at $sha1local" + } catch { + if (Test-Path -Path $sha1local -PathType Leaf) { + Write-Host "WARNING: could not fetch ${sha1url}: $($_.Exception.Message)" + Write-Host "WARNING: using cached copy at $sha1local" + } else { + Write-Host "Unable to fetch $sha1url and no cached copy available: $($_.Exception.Message)" + if ($_.Exception.Response) { + Write-Host "HTTP Status code: $($_.Exception.Response.StatusCode)" + } + return + } + } $sha1Content = Get-Content -Path $sha1local $remotedict = @{} foreach ($line in $sha1Content) { diff --git a/punkproject.toml b/punkproject.toml index 89c8a0ec..669a890e 100644 --- a/punkproject.toml +++ b/punkproject.toml @@ -1,3 +1,3 @@ [project] name = "punkshell" -version = "0.8.0" +version = "0.8.1" diff --git a/src/scriptapps/bin/runtime.ps1 b/src/scriptapps/bin/runtime.ps1 index bd0ae85f..8f79c98e 100644 --- a/src/scriptapps/bin/runtime.ps1 +++ b/src/scriptapps/bin/runtime.ps1 @@ -211,6 +211,10 @@ function psmain { if ($_.Exception.Response) { Write-Host "HTTP Status code: $($_.Exception.Response.StatusCode)" } + if (Test-Path -Path $sha1local -PathType Leaf) { + #this path always fell through to the cached copy - now say so + Write-Host "WARNING: proceeding with cached copy at $sha1local" + } } if (Test-Path -Path $sha1local -PathType Leaf) { $sha1Content = Get-Content -Path $sha1local @@ -405,12 +409,27 @@ function psmain { $sha1url = "$archurl/sha1sums.txt" if ( $PSBoundParameters.ContainsKey('remote') ) { if (-not (test-path -Path $archfolder -Type Container)) { - new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present + new-item -Path $archfolder -ItemType Directory -force #create with intermediary folders if not already present } - write-host "Checking for available remote runtimes for" + write-host "Checking for available remote runtimes for $arch" Write-Host "Fetching $sha1url" - Invoke-WebRequest -Uri $sha1url -OutFile $sha1local -ErrorAction Stop - Write-Host "sha1 saved at $sha1local" + #cached fallback (parity with the bash payload): an unreachable server + #falls back to a previously fetched sha1sums.txt with a warning + try { + Invoke-WebRequest -Uri $sha1url -OutFile $sha1local -ErrorAction Stop + Write-Host "sha1 saved at $sha1local" + } catch { + if (Test-Path -Path $sha1local -PathType Leaf) { + Write-Host "WARNING: could not fetch ${sha1url}: $($_.Exception.Message)" + Write-Host "WARNING: using cached copy at $sha1local" + } else { + Write-Host "Unable to fetch $sha1url and no cached copy available: $($_.Exception.Message)" + if ($_.Exception.Response) { + Write-Host "HTTP Status code: $($_.Exception.Response.StatusCode)" + } + return + } + } $sha1Content = Get-Content -Path $sha1local $remotedict = @{} foreach ($line in $sha1Content) {