|
|
|
|
@ -40,8 +40,9 @@
|
|
|
|
|
#core also boots a kit when sourced directly as its main.tcl. |
|
|
|
|
# ------------------------------------------------------------------------------ |
|
|
|
|
namespace eval ::punkboot { |
|
|
|
|
#boot-core identity (G-031; G-025 stamping is the planned reporting vehicle) |
|
|
|
|
variable core_version 0.1.0 |
|
|
|
|
#boot-core identity (G-031; stamped into kits + reported by the G-025 |
|
|
|
|
#buildinfo surfaces) |
|
|
|
|
variable core_version 0.2.1 |
|
|
|
|
} |
|
|
|
|
if {![info exists ::punkboot::launch_args]} { |
|
|
|
|
namespace eval ::punkboot [list variable launch_args $::argv] |
|
|
|
|
@ -1479,6 +1480,35 @@ if {![info exists ::punkboot::launch_defaults]} {
|
|
|
|
|
catch {package require __src_mode_tm_scan__} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------- |
|
|
|
|
#Boot running-state surface (G-031 registration model - the single boot |
|
|
|
|
#"running state" surface G-089 anticipated). Post-boot consumers (e.g |
|
|
|
|
#punk::buildinfo, scriptlib resolution) read facts the boot derived |
|
|
|
|
#instead of re-deriving or guessing. Dict keys: core_version, main_script, |
|
|
|
|
#package_modes, proj_scope, proj_root, kit_payload_base, and (src mode |
|
|
|
|
#only) src_project_root. |
|
|
|
|
#--------------------------------------------------------------- |
|
|
|
|
set boot_payload_base "" |
|
|
|
|
if {$zipkit_mountbase ne ""} { |
|
|
|
|
set boot_payload_base $zipkit_mountbase |
|
|
|
|
} elseif {[info exists ::tcl::kitpath] && $::tcl::kitpath ne ""} { |
|
|
|
|
set boot_payload_base $::tcl::kitpath |
|
|
|
|
} elseif {$has_cookfs_attached} { |
|
|
|
|
set boot_payload_base $cookbase |
|
|
|
|
} |
|
|
|
|
set boot_state_dict [dict create \ |
|
|
|
|
core_version $::punkboot::core_version \ |
|
|
|
|
main_script $::punkboot::main_script \ |
|
|
|
|
package_modes $package_modes \ |
|
|
|
|
proj_scope $proj_scope \ |
|
|
|
|
proj_root $proj_root \ |
|
|
|
|
kit_payload_base $boot_payload_base \ |
|
|
|
|
] |
|
|
|
|
if {[info exists src_project_root]} { |
|
|
|
|
dict set boot_state_dict src_project_root $src_project_root |
|
|
|
|
} |
|
|
|
|
namespace eval ::punkboot [list variable boot_state $boot_state_dict] |
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------- |
|
|
|
|
#Subcommand selection (G-031 registration model) |
|
|
|
|
#Built-ins (tclsh/shellspy/punk/shell/script) ship with this core; a thin |
|
|
|
|
@ -1492,7 +1522,7 @@ if {![info exists ::punkboot::launch_defaults]} {
|
|
|
|
|
# script invocation (default), or the name of a known |
|
|
|
|
# subcommand to receive the whole arglist as its arguments |
|
|
|
|
#--------------------------------------------------------------- |
|
|
|
|
set builtin_subcommands [list tclsh shellspy punk shell script] |
|
|
|
|
set builtin_subcommands [list tclsh shellspy punk shell script buildinfo] |
|
|
|
|
set known_subcommands $builtin_subcommands |
|
|
|
|
foreach k [dict keys $::punkboot::project_subcommands] { |
|
|
|
|
if {$k in $builtin_subcommands} { |
|
|
|
|
@ -1633,7 +1663,11 @@ if {![info exists ::punkboot::launch_defaults]} {
|
|
|
|
|
} |
|
|
|
|
shellspy { |
|
|
|
|
#pass through to shellspy commandline processor |
|
|
|
|
package require app-shellspy |
|
|
|
|
#graceful when a derived kit does not carry the app package (0.2.1) |
|
|
|
|
if {[catch {package require app-shellspy} errM]} { |
|
|
|
|
puts stderr "shellspy: this kit does not carry the app-shellspy package ($errM)" |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
punk { |
|
|
|
|
#The punk executable must also support running commands piped into stdin. |
|
|
|
|
@ -1649,10 +1683,16 @@ if {![info exists ::punkboot::launch_defaults]} {
|
|
|
|
|
|
|
|
|
|
if {[llength $subcommand_arglist]} { |
|
|
|
|
#puts stdout "main.tcl launching app-punkshell with args: $subcommand_arglist" |
|
|
|
|
package require app-punkshell |
|
|
|
|
if {[catch {package require app-punkshell} errM]} { |
|
|
|
|
puts stderr "punk: this kit does not carry the app-punkshell package ($errM)" |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
#punk interactive shell |
|
|
|
|
package require app-repl |
|
|
|
|
if {[catch {package require app-repl} errM]} { |
|
|
|
|
puts stderr "punk: this kit does not carry the app-repl package ($errM)" |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
script { |
|
|
|
|
@ -1661,12 +1701,18 @@ if {![info exists ::punkboot::launch_defaults]} {
|
|
|
|
|
#no shellfilter stacks/transforms, no interactive fallback, honest exit codes. |
|
|
|
|
#The launch plumbing must emit nothing on stdout/stderr (exec-style callers). |
|
|
|
|
set ::tcl_interactive 0 |
|
|
|
|
package require app-punkscript |
|
|
|
|
if {[catch {package require app-punkscript} errM]} { |
|
|
|
|
puts stderr "script: this kit does not carry the app-punkscript package ($errM)" |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
shell { |
|
|
|
|
#app-punkshell supports running a script and maintaining an interactive shell afterwards |
|
|
|
|
# or just launching an interactive shell if no script is specified |
|
|
|
|
package require app-punkshell |
|
|
|
|
if {[catch {package require app-punkshell} errM]} { |
|
|
|
|
puts stderr "shell: this kit does not carry the app-punkshell package ($errM)" |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
#if {[llength $subcommand_arglist]} { |
|
|
|
|
# #run script and maintain interactive shell. |
|
|
|
|
# package require app-punkshell |
|
|
|
|
@ -1675,6 +1721,21 @@ if {![info exists ::punkboot::launch_defaults]} {
|
|
|
|
|
# package require app-repl |
|
|
|
|
#} |
|
|
|
|
} |
|
|
|
|
buildinfo { |
|
|
|
|
#G-025: machine-parseable build/identity report. The single |
|
|
|
|
#implementation is punk::buildinfo - this arm is the thin |
|
|
|
|
#exe-subcommand wrapper. Stdout carries only the report; honest |
|
|
|
|
#exit code; no repl fallthrough (G-015-compatible). |
|
|
|
|
if {[llength $subcommand_arglist]} { |
|
|
|
|
puts stderr "buildinfo: takes no arguments" |
|
|
|
|
exit 2 |
|
|
|
|
} |
|
|
|
|
if {[catch {package require punk::buildinfo} errM]} { |
|
|
|
|
puts stderr "buildinfo: the punk::buildinfo module is not available in this kit/context ($errM)" |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
exit [punk::buildinfo::main] |
|
|
|
|
} |
|
|
|
|
default { |
|
|
|
|
#a project-declared subcommand (thin-main customization point): the |
|
|
|
|
#handler script runs in this frame, ::argv/::argc already hold the |
|
|
|
|
|