tcl-hacks

Check-in [fab3e764ea]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:improve help, adjust some tclenv.txt, stub some stuff
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fab3e764ea43fb14e5d704b6390a798504415898
User & Date: aspect 2018-06-05 14:22:22
Context
2018-06-05
14:27
note well-behaved needs review check-in: 1866439ebe user: aspect tags: trunk
14:22
improve help, adjust some tclenv.txt, stub some stuff check-in: fab3e764ea user: aspect tags: trunk
2018-05-30
10:57
seperate tclenv.txt from tipple.txt, document some more check-in: b7067b3f66 user: aspect tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to hacks/cuppa/cuppa.tcl.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
        macosx%     darwin
    }
    variable map_cpu {
        ix86        {x86 intel i_86 i86pc}
        sparc       sun4%
        sparc64     {sun4u sun4v}
        universal   %
        ""          %
        powerpc     ppc
    }

    db::reset {
        db eval {
            drop table if exists servers;
            drop table if exists packages;







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
        macosx%     darwin
    }
    variable map_cpu {
        ix86        {x86 intel i_86 i86pc}
        sparc       sun4%
        sparc64     {sun4u sun4v}
        universal   %
        {""}        %
        powerpc     ppc
    }

    db::reset {
        db eval {
            drop table if exists servers;
            drop table if exists packages;

Changes to tipple/README.md.

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
150
151
152
153
154
155
156
157
158













159
160
161
162
163
164
165
    lib_dir     lib/tcl8.6
    tm_dir      lib/tcl8/site-tcl
    
    # teapot repos to use, in order of preference
    teapot https://teapot.rkeene.org/
    teapot https://teapot.activestate.org/
    
    # MAYBE: optionally specify architecture for fetching binary pkgs from teapot
    architecture OS ARCH


## Package Metadata: `tipple.txt`

Tipple looks in the root of any package it installs for `tipple.txt`, which can specify requirements that will be satisfied recursively.  It looks like:

    # this is a comment, as you might expect
................................................................................

### Coming soon

A `tipple.txt` file might also want to be written for an upstream repo that we don't control.  This **will** be supported by creating a local `tipple.txt` that can use additional directives:

    provide somepackage 0.1.2
    source https://some.url/tarball.tar.gz
    require some-dependency
    patch some-file.patch















## Use cases (mostly articulated by stevel)

 * I want to install my own copies of packages that are not installed on the system, and I may not have root
 * I want to install a more up-to-date copy of a package that is already installed on the system
 * I want to wrap a script (as a starpack or just an archive) and include a copy of the dependent packages







|
|







 







<

>
>
>
>
>
>
>
>
>
>
>
>
>







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
150
151
152
153
154
155
156

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
    lib_dir     lib/tcl8.6
    tm_dir      lib/tcl8/site-tcl
    
    # teapot repos to use, in order of preference
    teapot https://teapot.rkeene.org/
    teapot https://teapot.activestate.org/
    
    # MAYBE: optionally specify platform for fetching binary pkgs from teapot
    platform OS-ARCH


## Package Metadata: `tipple.txt`

Tipple looks in the root of any package it installs for `tipple.txt`, which can specify requirements that will be satisfied recursively.  It looks like:

    # this is a comment, as you might expect
................................................................................

### Coming soon

A `tipple.txt` file might also want to be written for an upstream repo that we don't control.  This **will** be supported by creating a local `tipple.txt` that can use additional directives:

    provide somepackage 0.1.2
    source https://some.url/tarball.tar.gz

    patch some-file.patch
    
    # plus the usual:
    require some-dependency


### Possible extensions to `tipple.txt`

I'm avoiding these, as they lie in the direction of hairy yaks, but noting them just the same.

 * specifying multiple modules in the same repo has some appeal, though it adds complexity (and it's a job for teapot)
 * directives saying what to install, in case `/lib` and `/modules` and `/bin` are inadequate

The goal is not to grow into quill or kbskit.


## Use cases (mostly articulated by stevel)

 * I want to install my own copies of packages that are not installed on the system, and I may not have root
 * I want to install a more up-to-date copy of a package that is already installed on the system
 * I want to wrap a script (as a starpack or just an archive) and include a copy of the dependent packages

Changes to tipple/tipple.tcl.

25
26
27
28
29
30
31


32





33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
80
81
82
83
84
85
86


87
88
89
90
91


































92
93
94
95
96
97
98
}

namespace eval tipple {
    namespace ensemble create
    namespace export {[a-z]*}

    proc help {} {


        puts "Subcommands: [lmap c [info commands [namespace current]::\[a-z\]*] {namespace tail $c}]"





    }

    proc init {topdir} {

        set topdir [file normalize $topdir]

        if {[file exists $topdir]} {
            if {[file exists $topdir/tipple.txt]} {
                return -code error "Error: $topdir/tipple.txt already exists!"
            }
            puts "Setting up in existing directory: $topdir"
        } else {
            puts "Setting up new directory: $topdir"
        }

        set tclver [info tclversion]
................................................................................
            }] -permissions 0755

        }

        createfile $topdir/tclenv.txt [subst {
            # Tcl environment initialised at [clock format [clock seconds]]
            tcl_version $tclver


            lib_dir [list $rellibdir]
            tm_dir  [list $relmoddir]

        }]
    }


































}

proc main {args} {
    if {$args eq ""} {set args "help"}
    try {
        tipple {*}$args
    } on error {err opts} {







>
>
|
>
>
>
>
>







|
|







 







>
>
|
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
}

namespace eval tipple {
    namespace ensemble create
    namespace export {[a-z]*}

    proc help {} {
        puts "Subcommands:"
        foreach pat [namespace export] {
            foreach cmd [info commands [namespace current]::$pat] {
                set args [info args $cmd]
                set cmd [namespace tail $cmd]
                puts "  $cmd $args"
            }
        }
    }

    proc init {topdir} {

        set topdir [file normalize $topdir]

        if {[file exists $topdir]} {
            if {[file exists $topdir/tclenv.txt]} {
                return -code error "Error: $topdir/tclenv.txt already exists!"
            }
            puts "Setting up in existing directory: $topdir"
        } else {
            puts "Setting up new directory: $topdir"
        }

        set tclver [info tclversion]
................................................................................
            }] -permissions 0755

        }

        createfile $topdir/tclenv.txt [subst {
            # Tcl environment initialised at [clock format [clock seconds]]
            tcl_version $tclver
            platform    [platform::identify]

            lib_dir     [list $rellibdir]
            tm_dir      [list $relmoddir]

        }]
    }

    proc install {pkgname {pkgver ""}} {
        # download: pkgname is one of:
        #  * just a package name - use teapot
        #  * a local path - goto install
        #  * a url - download it
        #   * if it's a zip or tarball, extract it in DIR/src and goto install
        #   * otherwise install as a tm
        #  * fossil+$url or git+$url - clone it in DIR/src
        #
        # install:
        #   * look for tipple.txt
        #   * install files
        #    ? if tipple.txt specified, follow its directions
        #    * lib/ modules/ bin/
        #    ? or if there's /*.tm or /pkgIndex.tcl, the whole shebang
        #   * record package presence in log (+tclenv.txt?)
    }

    proc _read_txt {filename} {
        set fd [open $filename r]
        try {
            set res {}
            while {[gets $fd line]>=0} {
                if {[string match #* $line]} continue
                if {$line eq ""} continue
                set val [lassign $line key]
                dict lappend res $key {*}$val
            }
            return $res
        } finally {
            close $fd
        }
    }
}

proc main {args} {
    if {$args eq ""} {set args "help"}
    try {
        tipple {*}$args
    } on error {err opts} {