Browse Source

templates modpod: build-synced punk-runtime.cmd (platforms/defaults/ordering work)

Output of the make.tcl project run that performed the G-103 kit-wrap
trial - the established template-payload sync channel carrying the
current punk-runtime.cmd into the punk::mix::templates source tree.

Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com
master
Julian Noble 1 week ago
parent
commit
7f88b2d244
  1. 147
      src/modules/punk/mix/#modpod-templates-999999.0a1.0/templates/project_layouts/vendor/punk/project-0.1/bin/punk-runtime.cmd

147
src/modules/punk/mix/#modpod-templates-999999.0a1.0/templates/project_layouts/vendor/punk/project-0.1/bin/punk-runtime.cmd vendored

@ -1453,9 +1453,11 @@ set_active() {
echo "active runtime for $archtail set to: $1 (recorded in $active_file)"
}
#installed runtime candidates - exclude directories, build copies and
#non-runtime files (ps1-payload parity: files only, same extension excludes)
#non-runtime files (ps1-payload parity: files only, same extension excludes).
#LC_ALL=C: glob expansion order is collation-dependent - C-locale byte order
#matches the ps1 payload's ordinal sorting, so listings agree everywhere.
list_candidates() {
local f
local f LC_ALL=C
if [[ -d "$archdir" ]]; then
for f in "$archdir"/*; do
[[ -f "$f" ]] || continue
@ -1532,7 +1534,11 @@ show_help() {
echo " (variant, tcl patchlevel, revision, piperepl policy, source"
echo " artifact of a materialized copy; a !TARGET-MISMATCH flag marks"
echo " a runtime filed under the wrong platform folder). -remote"
echo " compares local runtimes against the server's sha1sums."
echo " compares local runtimes against the server's sha1sums, marks"
echo " the locally ACTIVE runtime (*) and annotates the platform's"
echo " recommended runtime ((server default), per the server's"
echo " defaults.txt when available) - so active-vs-default is"
echo " visible at a glance."
echo " use <name> ?-platform <p>?"
echo " Select the runtime that 'run' launches (records active.toml in"
echo " the platform folder). An immutable -r<N> ARTIFACT name is"
@ -1721,12 +1727,32 @@ case "$action" in
echo "No sha1 tool found (tried sha1sum, shasum, sha1, openssl) - cannot compare local runtimes."
exit 1
fi
#server-default + local-active surfacing (G-103): the server's curated
#defaults.txt names the recommended runtime per platform - best-effort
#fetch (cached/absent both fine for a listing), then mark the matching
#row and the locally active one so "is my active the recommended
#default?" is answerable at a glance.
activename=$(get_active)
platform_default=""
defaultslocal="${scriptdir}/runtime/defaults.txt"
curl -fsL --silent --output "$defaultslocal" "${url_kitbase}/defaults.txt" 2>/dev/null || :
if [[ -f "$defaultslocal" ]]; then
platform_default=$(awk -v p="$archtail" '$1==p {print $2; exit}' "$defaultslocal")
fi
echo "-----------------------------------------------------------------------"
echo "Runtimes for $archtail"
echo "Local $archdir"
echo "Remote ${url_kitbase}/${archtail}"
if [[ -n "$platform_default" ]]; then
echo "server default for $archtail: $platform_default"
fi
if [[ -n "$activename" ]]; then
matchnote=""
[[ -n "$platform_default" && "$activename" == "$platform_default" ]] && matchnote=" (= server default)"
echo "active (local): $activename$matchnote"
fi
echo "-----------------------------------------------------------------------"
echo "Local Remote"
echo " Local Remote"
echo "-----------------------------------------------------------------------"
for f in $(list_candidates); do
local_sha1=$(lcase "$(sha1_of "$archdir/$f")")
@ -1738,16 +1764,25 @@ case "$action" in
else
rhs="UPDATE AVAILABLE"
fi
printf '%-35s %s\n' "$f" "$rhs"
mark=" "
[[ "$f" == "$activename" ]] && mark="* "
annot=""
[[ -n "$platform_default" && "$f" == "$platform_default" ]] && annot=" (server default)"
printf '%s%-35s %s%s\n' "$mark" "$f" "$rhs" "$annot"
done
#remote-only entries
while IFS= read -r line; do
rname=$(printf '%s' "$line" | sed -n 's/^[0-9a-fA-F]\{40\} \*\(.*\)$/\1/p')
#remote-only entries, sorted (ps1-payload parity - its dict enumeration
#is explicitly sorted). tr strips CRLF \r: msys grep strips it in text
#mode but bash read does not - without this a locally-present runtime
#also shows as a remote-only row (\r-suffixed name fails the -f test)
tr -d '\r' < "$sha1local" | sed -n 's/^[0-9a-fA-F]\{40\} \*\(.*\)$/\1/p' | LC_ALL=C sort | while IFS= read -r rname; do
if [[ -n "$rname" && ! -f "$archdir/$rname" ]]; then
printf '%-35s %s\n' "-" "$rname"
annot=""
[[ -n "$platform_default" && "$rname" == "$platform_default" ]] && annot=" (server default)"
printf ' %-35s %s%s\n' "-" "$rname" "$annot"
fi
done < "$sha1local"
done
echo "-----------------------------------------------------------------------"
echo "* = active (local selection)"
else
if [[ -d "$archdir" ]]; then
candidates=$(list_candidates)
@ -1886,7 +1921,7 @@ case "$action" in
rtroot="${scriptdir}/runtime"
localdirs=""
if [[ -d "$rtroot" ]]; then
localdirs=$(ls -1 "$rtroot" 2>/dev/null | while read -r d; do [[ -d "$rtroot/$d" ]] && echo "$d"; done)
localdirs=$(LC_ALL=C ls -1 "$rtroot" 2>/dev/null | while read -r d; do [[ -d "$rtroot/$d" ]] && echo "$d"; done)
fi
if [[ "${1:-}" == "-remote" ]]; then
manifesturl="${url_kitbase}/platforms.txt"
@ -2324,13 +2359,27 @@ function Set-PunkActiveRuntime {
[System.IO.File]::WriteAllText($activefile, "active = `"$name`"`n", [System.Text.UTF8Encoding]::new($false))
Write-Host "active runtime set to: $name (recorded in $activefile)"
}
#installed runtime candidates - exclude build copies and non-runtime files
#installed runtime candidates - exclude build copies and non-runtime files.
#ORDINAL name order: culture-sensitive Sort-Object collates differently between
#windows powershell (NLS) and pwsh (ICU) - both launch paths exist (the .ps1
#twin runs under the invoking shell) - and ordinal matches the bash payload's
#LC_ALL=C ordering, so listings agree byte-for-byte everywhere.
function Get-PunkRuntimeCandidates {
param([string] $archfolder)
if (-not (Test-Path -Path $archfolder -PathType Container)) {
return @()
}
return @(get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY*' | Where-object {-not ($(".txt",".toml",".tm",".tmp",".log") -contains $_.Extension) } | Sort-Object Name)
$files = @(get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY*' | Where-object {-not ($(".txt",".toml",".tm",".tmp",".log") -contains $_.Extension) })
if ($files.Count -le 1) {
return $files
}
$byname = @{}
foreach ($f in $files) { $byname[$f.Name] = $f }
$names = @($byname.Keys)
[array]::Sort($names, [System.StringComparer]::Ordinal)
$out = @()
foreach ($n in $names) { $out += $byname[$n] }
return $out
}
#operator help (the 'help' action; the no-args case shows the Usage block only).
#Keep in sync with the bash payload's show_help/show_usage.
@ -2363,7 +2412,11 @@ function Show-PunkRuntimeHelp {
write-host " (variant, tcl patchlevel, revision, piperepl policy, source"
write-host " artifact of a materialized copy; a !TARGET-MISMATCH flag marks"
write-host " a runtime filed under the wrong platform folder). -remote"
write-host " compares local runtimes against the server's sha1sums."
write-host " compares local runtimes against the server's sha1sums, marks"
write-host " the locally ACTIVE runtime (*) and annotates the platform's"
write-host " recommended runtime ((server default), per the server's"
write-host " defaults.txt when available) - so active-vs-default is"
write-host " visible at a glance."
write-host " use <name> ?-platform <p>?"
write-host " Select the runtime that 'run' launches (records active.toml in"
write-host " the platform folder). An immutable -r<N> ARTIFACT name is"
@ -2980,19 +3033,57 @@ function psmain {
}
}
#server-default + local-active surfacing (G-103): the server's
#curated defaults.txt names the recommended runtime per platform -
#best-effort fetch (cached/absent both fine for a listing), then
#mark the matching row and the locally active one so "is my
#active the recommended default?" is answerable at a glance.
$activename = Get-PunkActiveRuntime $archfolder
$platform_default = ""
$defaultslocal = Join-Path -Path $rtfolder -ChildPath "defaults.txt"
try {
Invoke-WebRequest -Uri "$artifacturl/defaults.txt" -OutFile $defaultslocal -ErrorAction Stop
} catch { }
if (Test-Path -Path $defaultslocal -PathType Leaf) {
foreach ($line in (Get-Content -Path $defaultslocal)) {
$line = $line.Trim()
if ($line -eq "" -or $line.StartsWith("#")) { continue }
$parts = -split $line
if ($parts.Count -ge 2 -and $parts[0] -eq $arch) {
$platform_default = $parts[1]
break
}
}
}
Write-host "-----------------------------------------------------------------------"
Write-host "Runtimes for $arch"
Write-host "Local $archfolder"
Write-host "Remote $archurl"
if ($platform_default -ne "") {
Write-host "server default for ${arch}: $platform_default"
}
if ($activename -ne "") {
$matchnote = ""
if ($platform_default -ne "" -and $activename -eq $platform_default) {
$matchnote = " (= server default)"
}
Write-host "active (local): $activename$matchnote"
}
Write-host "-----------------------------------------------------------------------"
Write-host "Local Remote"
Write-host " Local Remote"
Write-host "-----------------------------------------------------------------------"
# 12345678910234567892023456789302345
# 12345678910234567892023456789302345
$G = "`e[32m" #Green
$Y = "`e[33m" #Yellow
$R = "`e[31m" #Red
$RST = "`e[m"
foreach ($key in $localdict.Keys) {
#explicit ORDINAL sort: Hashtable key enumeration order is
#undefined (and differs between the powershell editions), and
#culture-sensitive Sort-Object collates differently too (NLS vs
#ICU) - ordinal agrees across editions and with bash LC_ALL=C
$localkeys = @($localdict.Keys)
[array]::Sort($localkeys, [System.StringComparer]::Ordinal)
foreach ($key in $localkeys) {
$local_sha1 = $($localdict[$key])
if ($remotedict.ContainsKey($key)) {
if ($local_sha1 -eq $remotedict[$key]) {
@ -3009,18 +3100,27 @@ function psmain {
#ansi problems from cmd.exe not in windows terminal - review
$C = ""
$RST = ""
$mark = " "
if ($key -eq $activename) { $mark = "* " }
$annot = ""
if ($platform_default -ne "" -and $key -eq $platform_default) { $annot = " (server default)" }
$lhs = "$key".PadRight(35, ' ')
write-host -nonewline "${C}${lhs}${RST}"
write-host $rhs
write-host -nonewline "${mark}${C}${lhs}${RST}"
write-host "$rhs$annot"
}
$lhs_missing = "-".PadRight(35, ' ')
foreach ($key in $remotedict.Keys) {
$remotekeys = @($remotedict.Keys)
[array]::Sort($remotekeys, [System.StringComparer]::Ordinal)
foreach ($key in $remotekeys) {
if (-not ($localdict.ContainsKey($key))) {
write-host -nonewline $lhs_missing
write-host $key
$annot = ""
if ($platform_default -ne "" -and $key -eq $platform_default) { $annot = " (server default)" }
write-host -nonewline " $lhs_missing"
write-host "$key$annot"
}
}
Write-host "-----------------------------------------------------------------------"
Write-host "* = active (local selection)"
} else {
if (test-path -Path $archfolder -Type Container) {
@ -3059,7 +3159,8 @@ function psmain {
#punkbin layout contract; third-party mirrors carry the same file)
$localdirs = @()
if (Test-Path -Path $rtfolder -PathType Container) {
$localdirs = @(Get-ChildItem -Path $rtfolder -Directory | Select-Object -ExpandProperty Name | Sort-Object)
$localdirs = @(Get-ChildItem -Path $rtfolder -Directory | Select-Object -ExpandProperty Name)
[array]::Sort($localdirs, [System.StringComparer]::Ordinal)
}
if ( $PSBoundParameters.ContainsKey('remote') ) {
$manifesturl = "$artifacturl/platforms.txt"

Loading…
Cancel
Save