diff --git a/bin/punk-getzig.cmd b/bin/punk-getzig.cmd index b7280d4d..42554918 100644 --- a/bin/punk-getzig.cmd +++ b/bin/punk-getzig.cmd @@ -1278,26 +1278,28 @@ fi #printf "start of bash or zsh code" # -#mkdir -p ./zig +#punk-getzig (bash side) - per-version zig fetch. UNIMPLEMENTED beyond messaging: +#the windows (powershell) side is the maintained implementation today; this stub +#keeps the same argument convention so the eventual implementation is a fill-in. +#Version may be supplied as $1; default matches the powershell side's suite pin. -#tarball="zig-x86_64-windows-0.15.2.zip" -#tarball="zig-x86_64-freebsd-0.15.2.tar.xz" -tarball="zig-x86_64-linux-0.16.0.tar.xz" +releaseversion="${1:-0.16.0}" +tarball="zig-x86_64-linux-${releaseversion}.tar.xz" +targetdir="./tools/zig-x86_64-linux-${releaseversion}" automation_name="punkshell+julian@precisium.com.au_target_by_latency" uristring="https://ziglang.org" -#releases -full_uristring="${uristring}/download/0.15.2/${tarball}?source=${automation_name}" -#pre-releases -#full_uristring="${uristring}/builds/${tarball}?source=${automation_name}" +#releases (/download//). dev builds (X.Y.Z-dev.N+hash) live under /builds/ +#and are not handled - host such zips on the punkbin mirror if one must be pinned. +full_uristring="${uristring}/download/${releaseversion}/${tarball}?source=${automation_name}" -echo "Unimplemented: Download from ${full_uristring} and extract manually" -#wget $full_uristring -O ./zig/zig-linux-x86_64-0.10.1.tar.xz -#tar -xf ./zig/zig-linux-x86_64-0.10.1.tar.xz -C ./zig --strip-components=1 -#rm ./zig/zig-linux-x86_64-0.10.1.tar.xz -#echo "Zig installed." -#./zig/zig version +echo "Unimplemented: Download from ${full_uristring}" +echo " and extract to ${targetdir} (the tarball's own root folder name) manually." +#wget "$full_uristring" -O "./tools/${tarball}" +#minisign verification as per the powershell side (zig minisign pubkey), then: +#tar -xf "./tools/${tarball}" -C ./tools +#"${targetdir}/zig" version # @@ -1607,19 +1609,28 @@ if (-not(Test-Path -Path $toolsfolder -PathType Container)) { #create folder - (can include missing intermediaries) New-Item -Path $toolsfolder -ItemType Directory } -$zigfolder = Join-Path $toolsfolder -ChildPath "zig" -$zigexe = Join-Path $zigfolder -ChildPath "zig.exe" -#$releasearchive = "zig-x86_64-windows-0.15.1.zip" ;#zip on windows, tarball on every other platform -#$releasearchive = "zig-x86_64-windows-0.16.0-dev.254+6dd0270a1.zip" -#$releasearchive = "zig-x86_64-windows-0.16.0-dev.2193+fc517bd01.zip" -$releasearchive = "zig-x86_64-windows-0.16.0.zip" -#single-source the pinned version from the archive name (used for ziglang.org release URLs) -if ($releasearchive -match 'zig-x86_64-windows-(.+)\.zip$') { - $releaseversion = $Matches[1] +#per-version fetch (G-096): the zig version may be supplied as the first argument; +#default is the suite_tcl90 pin. Each version installs into its OWN versioned dir +#tools/zig-x86_64-windows- (the zip's native root folder name) so multiple +#pinned toolchains coexist - recipes resolve the exact dir they were written for. +#Note: ziglang.org release urls (/download//) serve tagged releases; dev +#builds (X.Y.Z-dev.N+hash) live under /builds/ and are NOT handled here - host dev +#zips on the punkbin mirror (flat tools/ path) if one must be pinned. Also NOT +#handled: releases before 0.14.1, which used the old zig-- archive naming. +$releaseversion_default = "0.16.0" +if ($args.Count -ge 1 -and "$($args[0])" -ne "") { + $releaseversion = "$($args[0])" } else { - Write-Error "cannot derive zig version from releasearchive name '$releasearchive'" + $releaseversion = $releaseversion_default +} +if (-not ($releaseversion -match '^[0-9][0-9A-Za-z.+-]*$')) { + Write-Error "zig version argument '$releaseversion' does not look like a version (e.g 0.16.0)" exit 1 } +$releasearchive = "zig-x86_64-windows-${releaseversion}.zip" +$zigfolder = Join-Path $toolsfolder -ChildPath "zig-x86_64-windows-${releaseversion}" +$zigexe = Join-Path $zigfolder -ChildPath "zig.exe" +Write-Host "requested zig version: $releaseversion -> $zigfolder" Write-Output "powershell version: $($PSVersionTable.PSVersion)" if (Get-Command $zigexe -ErrorAction SilentlyContinue) { @@ -1633,6 +1644,9 @@ if (Get-Command $zigexe -ErrorAction SilentlyContinue) { Write-Host "Consider deleting $zigexe and re-downloading" } else { Write-Host "$zigexe version is: $stdout" + if ("$stdout".Trim() -ne $releaseversion) { + Write-Host "WARNING: reported version does not match the versioned folder name (requested $releaseversion) - consider deleting $zigfolder and re-running" + } } exit } @@ -1722,43 +1736,14 @@ function extractZip { } - $zigfolder = Join-Path $toolsfolder -ChildPath "zig" - $zigexe = Join-Path $zigfolder -ChildPath "zig.exe" - - $retries = 10 - $exe_missing = $true #missing until tested as a found leaf - $sleep_time = 2 - while (($retries -gt 0) -and $exe_missing) { - $retries -= 1 - #We *intermittently* get permission errors when trying to rename the resulting folder (possibly also if we try to delete the zip file immediately) - #There seems to be some sort of lock held after ExtractToDirectory (possibly AV related) - #https://stackoverflow.com/questions/74582293/file-lock-issues-on-zip-file-after-io-compression-zipfileextracttodirectory - - #In some cases just the GC was enough.. but in other cases even sleep 3 seconds + GC didn't work - #sleep of 5 seems more reliable - but the size of the required delay may depend on what is running on the system, - # and the size of the extracted folder etc. - #Rather than use a large sleep to cover all cases - we use a limited retry loop with a somewhat shorter sleep e.g 2 - Write-Host "waiting $sleep_time seconds and also running GC to allow locks to clear. Max remaining retries: $retries" - start-sleep -Seconds $sleep_time - - [GC]::Collect() - [GC]::WaitForPendingFinalizers() - # ------------------------------------- - #Remove-Item -Path "$outfile" - #write-host "zip_rootname: $zip_rootname" - write-host "Attempting to move $zip_extraction_folder to ${zigfolder}" - Rename-Item -Path $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) -NewName $zigfolder -ErrorAction SilentlyContinue - if (-not $?) { - write-host "Renaming extracted folder into place at $zigfolder failed" - write-host " - error message: $($error[0].Exception.Message)" - } - if (Test-Path -Path $zigexe -PathType leaf) { - $exe_missing = $false - } - } - + #G-096 per-version install: the zip's own root folder (zig-x86_64-windows-) + #IS the versioned install dir - no rename-into-place step is needed any more. + #(The old rename to tools/zig intermittently hit post-ExtractToDirectory lock + #errors - see https://stackoverflow.com/questions/74582293 - which the retry/GC + #loop existed to ride out; with the rename gone that whole dance goes too.) + $zigexe = Join-Path $zip_extraction_folder -ChildPath "zig.exe" if (Test-Path -Path $zigexe -PathType leaf) { - Write-Host "Zig installed in ${zigfolder}" + Write-Host "Zig installed in ${zip_extraction_folder}" return $true } else { Write-Host "Failed to install as $zigexe" diff --git a/goals/G-096-zig-buildsuite-piperepl.md b/goals/G-096-zig-buildsuite-piperepl.md index a1ba43ee..1434095a 100644 --- a/goals/G-096-zig-buildsuite-piperepl.md +++ b/goals/G-096-zig-buildsuite-piperepl.md @@ -345,3 +345,30 @@ Remaining for acceptance: tcl_interactive is LINKED before the startup script runs (stock links at repl entry), so scripts that WRITE ::tcl_interactive can influence prompting where stock ignores the write until repl entry; readers see identical values. + +### 2026-07-20 increment: punk-getzig per-version fetch into versioned dirs - all four paths verified + +- The scriptset (src/scriptapps/bin/punk-getzig.ps1/.bash) takes the zig version as + the first argument (default = the suite pin, 0.16.0) and installs into + tools/zig-x86_64-windows- - the zip's OWN root folder name, so the old + rename-into-place step (and its post-ExtractToDirectory lock retry/GC dance) is + gone entirely. Installed-check reports a mismatch warning if the exe's reported + version differs from its versioned folder. Documented limitations: dev builds + (/builds/ url space) and pre-0.14.1 releases (old zig-- archive naming) + are not handled - punkbin's flat tools/ mirror path serves those if one must be + pinned. The bash side remains an honest stub with the same argument convention. +- Rewrapped via punk::mix::commandset::scriptwrap::multishell (punk905_beta src + script) -> bin/punk-getzig.cmd regenerated + .ps1 twin byte-synced; no spacer + issues (template label-analysis warnings are the known pre-existing noise). +- VERIFIED all four paths through the polyglot wrapper: + (1) explicit present version: 'punk-getzig.cmd 0.16.0' -> versioned dir found, + reported version matches, early exit; + (2) no-arg default: resolves 0.16.0 identically; + (3) existing-zip path: 'punk-getzig.cmd 0.15.2' with the zip+minisig present but + no dir -> signature verified -> extracted to zig-x86_64-windows-0.15.2 -> + ZIG VERSION: 0.15.2; + (4) FULL NETWORK path: 0.15.2 zip/minisig/dir removed (backed up first) -> + mirror-latency selection picked the local punkbin dev mirror -> zip + + minisig downloaded -> signature verified -> versioned extract -> + ZIG VERSION: 0.15.2. +- Remaining for this goal: the final clean-checkout re-verification only. diff --git a/src/scriptapps/bin/punk-getzig.bash b/src/scriptapps/bin/punk-getzig.bash index f0c8d761..fa554847 100644 --- a/src/scriptapps/bin/punk-getzig.bash +++ b/src/scriptapps/bin/punk-getzig.bash @@ -1,20 +1,22 @@ -#mkdir -p ./zig +#punk-getzig (bash side) - per-version zig fetch. UNIMPLEMENTED beyond messaging: +#the windows (powershell) side is the maintained implementation today; this stub +#keeps the same argument convention so the eventual implementation is a fill-in. +#Version may be supplied as $1; default matches the powershell side's suite pin. -#tarball="zig-x86_64-windows-0.15.2.zip" -#tarball="zig-x86_64-freebsd-0.15.2.tar.xz" -tarball="zig-x86_64-linux-0.16.0.tar.xz" +releaseversion="${1:-0.16.0}" +tarball="zig-x86_64-linux-${releaseversion}.tar.xz" +targetdir="./tools/zig-x86_64-linux-${releaseversion}" automation_name="punkshell+julian@precisium.com.au_target_by_latency" uristring="https://ziglang.org" -#releases -full_uristring="${uristring}/download/0.15.2/${tarball}?source=${automation_name}" -#pre-releases -#full_uristring="${uristring}/builds/${tarball}?source=${automation_name}" +#releases (/download//). dev builds (X.Y.Z-dev.N+hash) live under /builds/ +#and are not handled - host such zips on the punkbin mirror if one must be pinned. +full_uristring="${uristring}/download/${releaseversion}/${tarball}?source=${automation_name}" -echo "Unimplemented: Download from ${full_uristring} and extract manually" -#wget $full_uristring -O ./zig/zig-linux-x86_64-0.10.1.tar.xz -#tar -xf ./zig/zig-linux-x86_64-0.10.1.tar.xz -C ./zig --strip-components=1 -#rm ./zig/zig-linux-x86_64-0.10.1.tar.xz -#echo "Zig installed." -#./zig/zig version +echo "Unimplemented: Download from ${full_uristring}" +echo " and extract to ${targetdir} (the tarball's own root folder name) manually." +#wget "$full_uristring" -O "./tools/${tarball}" +#minisign verification as per the powershell side (zig minisign pubkey), then: +#tar -xf "./tools/${tarball}" -C ./tools +#"${targetdir}/zig" version diff --git a/src/scriptapps/bin/punk-getzig.ps1 b/src/scriptapps/bin/punk-getzig.ps1 index c8251d23..454f863e 100644 --- a/src/scriptapps/bin/punk-getzig.ps1 +++ b/src/scriptapps/bin/punk-getzig.ps1 @@ -13,19 +13,28 @@ if (-not(Test-Path -Path $toolsfolder -PathType Container)) { #create folder - (can include missing intermediaries) New-Item -Path $toolsfolder -ItemType Directory } -$zigfolder = Join-Path $toolsfolder -ChildPath "zig" -$zigexe = Join-Path $zigfolder -ChildPath "zig.exe" -#$releasearchive = "zig-x86_64-windows-0.15.1.zip" ;#zip on windows, tarball on every other platform -#$releasearchive = "zig-x86_64-windows-0.16.0-dev.254+6dd0270a1.zip" -#$releasearchive = "zig-x86_64-windows-0.16.0-dev.2193+fc517bd01.zip" -$releasearchive = "zig-x86_64-windows-0.16.0.zip" -#single-source the pinned version from the archive name (used for ziglang.org release URLs) -if ($releasearchive -match 'zig-x86_64-windows-(.+)\.zip$') { - $releaseversion = $Matches[1] +#per-version fetch (G-096): the zig version may be supplied as the first argument; +#default is the suite_tcl90 pin. Each version installs into its OWN versioned dir +#tools/zig-x86_64-windows- (the zip's native root folder name) so multiple +#pinned toolchains coexist - recipes resolve the exact dir they were written for. +#Note: ziglang.org release urls (/download//) serve tagged releases; dev +#builds (X.Y.Z-dev.N+hash) live under /builds/ and are NOT handled here - host dev +#zips on the punkbin mirror (flat tools/ path) if one must be pinned. Also NOT +#handled: releases before 0.14.1, which used the old zig-- archive naming. +$releaseversion_default = "0.16.0" +if ($args.Count -ge 1 -and "$($args[0])" -ne "") { + $releaseversion = "$($args[0])" } else { - Write-Error "cannot derive zig version from releasearchive name '$releasearchive'" + $releaseversion = $releaseversion_default +} +if (-not ($releaseversion -match '^[0-9][0-9A-Za-z.+-]*$')) { + Write-Error "zig version argument '$releaseversion' does not look like a version (e.g 0.16.0)" exit 1 } +$releasearchive = "zig-x86_64-windows-${releaseversion}.zip" +$zigfolder = Join-Path $toolsfolder -ChildPath "zig-x86_64-windows-${releaseversion}" +$zigexe = Join-Path $zigfolder -ChildPath "zig.exe" +Write-Host "requested zig version: $releaseversion -> $zigfolder" Write-Output "powershell version: $($PSVersionTable.PSVersion)" if (Get-Command $zigexe -ErrorAction SilentlyContinue) { @@ -39,6 +48,9 @@ if (Get-Command $zigexe -ErrorAction SilentlyContinue) { Write-Host "Consider deleting $zigexe and re-downloading" } else { Write-Host "$zigexe version is: $stdout" + if ("$stdout".Trim() -ne $releaseversion) { + Write-Host "WARNING: reported version does not match the versioned folder name (requested $releaseversion) - consider deleting $zigfolder and re-running" + } } exit } @@ -128,43 +140,14 @@ function extractZip { } - $zigfolder = Join-Path $toolsfolder -ChildPath "zig" - $zigexe = Join-Path $zigfolder -ChildPath "zig.exe" - - $retries = 10 - $exe_missing = $true #missing until tested as a found leaf - $sleep_time = 2 - while (($retries -gt 0) -and $exe_missing) { - $retries -= 1 - #We *intermittently* get permission errors when trying to rename the resulting folder (possibly also if we try to delete the zip file immediately) - #There seems to be some sort of lock held after ExtractToDirectory (possibly AV related) - #https://stackoverflow.com/questions/74582293/file-lock-issues-on-zip-file-after-io-compression-zipfileextracttodirectory - - #In some cases just the GC was enough.. but in other cases even sleep 3 seconds + GC didn't work - #sleep of 5 seems more reliable - but the size of the required delay may depend on what is running on the system, - # and the size of the extracted folder etc. - #Rather than use a large sleep to cover all cases - we use a limited retry loop with a somewhat shorter sleep e.g 2 - Write-Host "waiting $sleep_time seconds and also running GC to allow locks to clear. Max remaining retries: $retries" - start-sleep -Seconds $sleep_time - - [GC]::Collect() - [GC]::WaitForPendingFinalizers() - # ------------------------------------- - #Remove-Item -Path "$outfile" - #write-host "zip_rootname: $zip_rootname" - write-host "Attempting to move $zip_extraction_folder to ${zigfolder}" - Rename-Item -Path $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) -NewName $zigfolder -ErrorAction SilentlyContinue - if (-not $?) { - write-host "Renaming extracted folder into place at $zigfolder failed" - write-host " - error message: $($error[0].Exception.Message)" - } - if (Test-Path -Path $zigexe -PathType leaf) { - $exe_missing = $false - } - } - + #G-096 per-version install: the zip's own root folder (zig-x86_64-windows-) + #IS the versioned install dir - no rename-into-place step is needed any more. + #(The old rename to tools/zig intermittently hit post-ExtractToDirectory lock + #errors - see https://stackoverflow.com/questions/74582293 - which the retry/GC + #loop existed to ride out; with the rename gone that whole dance goes too.) + $zigexe = Join-Path $zip_extraction_folder -ChildPath "zig.exe" if (Test-Path -Path $zigexe -PathType leaf) { - Write-Host "Zig installed in ${zigfolder}" + Write-Host "Zig installed in ${zip_extraction_folder}" return $true } else { Write-Host "Failed to install as $zigexe"