@ -1291,7 +1291,8 @@ basename=$(basename "$scriptpath") #e.g punk-runtime.bash
scriptroot=" ${basename % .*} " #e.g " punk-runtime "
scriptroot=" ${basename % .*} " #e.g " punk-runtime "
#artifact server base url - overridable for mirrors/testing
#artifact server base url - overridable for mirrors/testing
url_kitbase=" ${PUNKBIN_URL:-https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master} "
url_canonical=" https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
url_kitbase=" ${PUNKBIN_URL:-$url_canonical} "
#$OSTYPE varies in capitalization across for example zsh and bash
#$OSTYPE varies in capitalization across for example zsh and bash
#uname probably a more consistent bet
#uname probably a more consistent bet
arch=$(uname -m) #machine/architecture
arch=$(uname -m) #machine/architecture
@ -1387,6 +1388,11 @@ fi
action=" ${1:-} "
action=" ${1:-} "
[[ $# -gt 0 ]] && shift
[[ $# -gt 0 ]] && shift
platform_opt=" "
platform_opt=" "
#G-123 server-trust consent: -trust-server flag > PUNKBIN_TRUST_SERVER=1 env
#(unattended form) - acknowledgement for a NON-CANONICAL origin; see the fetch
#action's gate. Never an interactive prompt.
trust_server=0
[[ " ${PUNKBIN_TRUST_SERVER:-} " == " 1 " ]] && trust_server=1
case " $action " in
case " $action " in
fetch| list| use| info| platforms)
fetch| list| use| info| platforms)
newargs=()
newargs=()
@ -1398,6 +1404,8 @@ case "$action" in
exit 1
exit 1
fi
fi
platform_opt=" $1 "
platform_opt=" $1 "
elif [[ " $1 " == " -trust-server " ]]; then
trust_server=1
else
else
newargs+=(" $1 " )
newargs+=(" $1 " )
fi
fi
@ -1552,7 +1560,7 @@ metadata_summary() {
#Keep in sync with the ps1 payload's Show-PunkRuntimeHelp/Show-PunkRuntimeUsage.
#Keep in sync with the ps1 payload's Show-PunkRuntimeHelp/Show-PunkRuntimeUsage.
show_usage() {
show_usage() {
echo " Usage: $0 {fetch|list|use|run|info|platforms|help} "
echo " Usage: $0 {fetch|list|use|run|info|platforms|help} "
echo " fetch ?<name>? ?-platform <p>? download+verify a runtime from punkbin "
echo " fetch ?<name>? ?-platform <p>? ?-trust-server? download+verify a runtime from punkbin "
echo " list ?-remote? ?-platform <p>? installed (or server) runtimes + metadata "
echo " list ?-remote? ?-platform <p>? installed (or server) runtimes + metadata "
echo " use <name> ?-platform <p>? select active / materialize -r<N> artifact "
echo " use <name> ?-platform <p>? select active / materialize -r<N> artifact "
echo " run ?args...? launch the active local-platform runtime "
echo " run ?args...? launch the active local-platform runtime "
@ -1633,7 +1641,11 @@ show_help() {
echo " chmod on the receiving side). "
echo " chmod on the receiving side). "
echo " "
echo " "
echo " Env: PUNKBIN_URL (artifact server base url), PUNK_RUNTIME_PLATFORM, "
echo " Env: PUNKBIN_URL (artifact server base url), PUNK_RUNTIME_PLATFORM, "
echo " PUNK_ACTIVE_RUNTIME (run-time selection override) "
echo " PUNK_ACTIVE_RUNTIME (run-time selection override), "
echo " PUNKBIN_TRUST_SERVER=1 (unattended form of -trust-server: fetch from a "
echo " non-canonical PUNKBIN_URL origin requires one of them - consent keyed to "
echo " server trust, G-139/G-123; the canonical origin and the metadata-only "
echo " list/platforms -remote actions never gate) "
echo " "
echo " "
echo " Examples: "
echo " Examples: "
echo " $0 platforms -remote "
echo " $0 platforms -remote "
@ -1772,6 +1784,20 @@ case "$action" in
echo " (canonical names: 'help platforms' in the punk shell) "
echo " (canonical names: 'help platforms' in the punk shell) "
exit 1
exit 1
fi
fi
#G-123 server-trust consent gate (one vocabulary with make.tcl libfetch's
#-serverurl/-trust-server gate, G-139): FETCH retrieves runtime binaries,
#so a non-canonical origin (PUNKBIN_URL override) requires the explicit
#acknowledgement. The canonical punkbin origin gates nothing (existing
#unattended flows unchanged); metadata-only actions (list -remote,
#platforms -remote) never gate. Never an interactive prompt.
if [[ " $ u r l _ k i t b a s e " ! = " $ u r l _ c a n o n i c a l " & & " $ t r u s t _ s e r v e r " - n e 1 ] ] ; t h e n
echo " punk-runtime fetch: origin '$url_kitbase' is not the canonical punkbin origin " >& 2
echo " canonical: $url_canonical " >& 2
echo " fetching runtime binaries from a non-canonical server requires the explicit " >& 2
echo " -trust-server flag (or PUNKBIN_TRUST_SERVER=1 for unattended flows) " >& 2
echo " (consent keyed to server trust - G-139/G-123) " >& 2
exit 1
fi
runtime=" ${1:-} "
runtime=" ${1:-} "
fetch_default=" "
fetch_default=" "
if [[ - z " $ r u n t i m e " ] ] ; t h e n
if [[ - z " $ r u n t i m e " ] ] ; t h e n
@ -2388,6 +2414,7 @@ esac
#(512B spacer) byte-alignment padding so template labels beyond the payloads clear cmd's
#(512B spacer) byte-alignment padding so template labels beyond the payloads clear cmd's
#512-byte label-scan boundaries - resize this comment if scriptwrap checkfile reports a
#512-byte label-scan boundaries - resize this comment if scriptwrap checkfile reports a
#boundary-spanning label after a payload edit (see bin/AGENTS.md polyglot workflow)
#boundary-spanning label after a payload edit (see bin/AGENTS.md polyglot workflow)
#padding-512-ok
#< /shell-payload>
#< /shell-payload>
@ -2795,7 +2822,7 @@ function Get-PunkRuntimeCandidates {
#Keep in sync with the bash payload's show_help/show_usage.
#Keep in sync with the bash payload's show_help/show_usage.
function Show-PunkRuntimeUsage {
function Show-PunkRuntimeUsage {
write-host " Usage: punk-runtime.cmd {fetch|list|use|run|info|platforms|help} "
write-host " Usage: punk-runtime.cmd {fetch|list|use|run|info|platforms|help} "
write-host " fetch ?<name>? ?-platform <p>? download+verify a runtime from punkbin "
write-host " fetch ?<name>? ?-platform <p>? ?-trust-server? download+verify a runtime from punkbin "
write-host " list ?-remote? ?-platform <p>? installed (or server) runtimes + metadata "
write-host " list ?-remote? ?-platform <p>? installed (or server) runtimes + metadata "
write-host " use <name> ?-platform <p>? select active / materialize -r<N> artifact "
write-host " use <name> ?-platform <p>? select active / materialize -r<N> artifact "
write-host " run ?args...? launch the active local-platform runtime "
write-host " run ?args...? launch the active local-platform runtime "
@ -2875,7 +2902,11 @@ function Show-PunkRuntimeHelp {
write-host " chmod on the receiving side). "
write-host " chmod on the receiving side). "
write-host " "
write-host " "
write-host " Env: PUNKBIN_URL (artifact server base url), PUNK_RUNTIME_PLATFORM, "
write-host " Env: PUNKBIN_URL (artifact server base url), PUNK_RUNTIME_PLATFORM, "
write-host " PUNK_ACTIVE_RUNTIME (run-time selection override) "
write-host " PUNK_ACTIVE_RUNTIME (run-time selection override), "
write-host " PUNKBIN_TRUST_SERVER=1 (unattended form of -trust-server: fetch from a "
write-host " non-canonical PUNKBIN_URL origin requires one of them - consent keyed to "
write-host " server trust, G-139/G-123; the canonical origin and the metadata-only "
write-host " list/platforms -remote actions never gate) "
write-host " "
write-host " "
write-host " Examples: "
write-host " Examples: "
write-host " punk-runtime.cmd platforms -remote "
write-host " punk-runtime.cmd platforms -remote "
@ -3403,12 +3434,33 @@ function psmain {
$rtfolder = Join-Path -Path $outbase -ChildPath " runtime "
$rtfolder = Join-Path -Path $outbase -ChildPath " runtime "
#Binary artifact server url. (git is not ideal for this - but will do for now - todo - use artifact system within gitea?)
#Binary artifact server url. (git is not ideal for this - but will do for now - todo - use artifact system within gitea?)
#overridable for mirrors/testing - keep in sync with the bash payload
#overridable for mirrors/testing - keep in sync with the bash payload
$artifacturl = " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
$canonicalurl = " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
$artifacturl = $canonicalurl
if ($env:PUNKBIN_URL) {
if ($env:PUNKBIN_URL) {
$artifacturl = $env:PUNKBIN_URL
$artifacturl = $env:PUNKBIN_URL
}
}
switch ($action) {
switch ($action) {
'fetch' {
'fetch' {
#G-123 server-trust consent gate (one vocabulary with make.tcl
#libfetch's -serverurl/-trust-server gate, G-139): FETCH retrieves
#runtime binaries, so a non-canonical origin (PUNKBIN_URL override)
#needs the explicit acknowledgement (-trust-server flag,
#pre-scanned before parameter binding, or PUNKBIN_TRUST_SERVER=1
#for unattended flows). The canonical punkbin origin gates nothing;
#metadata-only actions (list -remote, platforms -remote) never
#gate. Never an interactive prompt. Keep in sync with the bash
#payload's gate. (A comment line must never BEGIN with the word
#'requires' - PowerShell parses '#requires ...' as the #Requires
#statement and fails the whole file.)
$trustok = $script:PunkTrustServer -or ($env:PUNKBIN_TRUST_SERVER -eq " 1 " )
if (($artifacturl - n e $ c a n o n i c a l u r l ) - a n d ( - n o t $ t r u s t o k ) ) {
write-host " punk-runtime fetch: origin '$artifacturl' is not the canonical punkbin origin "
write-host " canonical: $canonicalurl "
write-host " fetching runtime binaries from a non-canonical server requires the explicit "
write-host " -trust-server flag (or PUNKBIN_TRUST_SERVER=1 for unattended flows) "
write-host " (consent keyed to server trust - G-139/G-123) "
exit 1
}
$arch = Resolve-PunkRuntimePlatform $PSBoundParameters[" platform " ]
$arch = Resolve-PunkRuntimePlatform $PSBoundParameters[" platform " ]
$archfolder = Join-Path -Path $rtfolder -ChildPath " $arch "
$archfolder = Join-Path -Path $rtfolder -ChildPath " $arch "
$archurl = " $artifacturl/$arch "
$archurl = " $artifacturl/$arch "
@ -4192,7 +4244,16 @@ function psmain {
#$returnvalue = psmain @args
#$returnvalue = psmain @args
#Write-Host " Function Returned $returnvalue " -ForegroundColor Cyan
#Write-Host " Function Returned $returnvalue " -ForegroundColor Cyan
#return $returnvalue
#return $returnvalue
psmain @args | out-null
#G-123: -trust-server is pre-scanned here rather than declared as a dynamic
#parameter - a hyphenated parameter name is fragile under the PS 5.1 binder the
#windows wrap routes through, and the bash payload's manual option scan is the
#behavioural twin. Keep the flag spelling identical to make.tcl libfetch's.
$script:PunkTrustServer = $false
$punkargs_filtered = @()
foreach ($punkarg in $args) {
if ($punkarg - e q " - t r u s t - s e r v e r " ) { $ s c r i p t : P u n k T r u s t S e r v e r = $ t r u e } e l s e { $ p u n k a r g s _ f i l t e r e d + = $ p u n k a r g }
}
psmain @punkargs_filtered | out-null
exit 0
exit 0