Check-in [0aa347b99c]
Overview
Comment:KitCreator downloader: use /buildinfo URLs instead of parsing building pages.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0aa347b99cc61a2b24b7dd23b40e646363526b41
User & Date: dbohdan on 2016-03-08 18:20:14
Other Links: manifest | tags
Context
2016-03-08
18:28
KitCreator downloader: Make the downloaded Tclkit executable check-in: ffc6b46c9f user: dbohdan tags: trunk
18:20
KitCreator downloader: use /buildinfo URLs instead of parsing building pages. check-in: 0aa347b99c user: dbohdan tags: trunk
17:44
Added build/utils/kitcreator-downloader.tcl, a script to download Tclkits built with the Web Interface check-in: 0c51e0404a user: dbohdan tags: trunk
Changes

Modified build/utils/kitcreator-downloader.tcl from [a94515b53d] to [f7dbe58451].

1
2
3
4
5
6

7
8
9

10
11
12
13
14
15
16
17

18
19
20
21
22
23
24

25
26
27
28
29
30
31
32






33

34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env tclsh
# KitCreator downloader v0.1.1 -- download Tclkits generated by
# http://kitcreator.rkeene.org/kitcreator. Works with Tcl 8.5+ and Jim Tcl.
# Copyright (C) 2016, dbohdan.
# License: MIT.
proc download url {

    set page [split [exec curl -s $url] \n]
    set descr [lsearch -glob -inline $page *Description:*]
    regexp {(http://kitcreator.rkeene.org/[^"]+/tclkit)} \

            [lsearch -glob -inline $page *URL:*] _ url

    set filename tclkit

    regexp {Tcl ([0-9.]+)} $descr _ version
    append filename -$version

    regexp {Platform ([-a-z0-9]+)} $descr _ platform

    append filename -$platform

    if {[regexp {packages statically linked} $descr]} {
        append filename -staticpkgs
    }

    if {[regexp {Threaded} $descr]} {

        append filename -threaded
    }

    if {[regexp {Packages: (.*)} $descr _ packages]} {
        foreach package $packages {
            set package [string trimright $package ,]
            append filename -$package
        }






    }


    puts "Downloading $url to $filename..."
    exec curl -o $filename $url >@ stdout 2>@ stderr
}

set url [lindex $argv 0]
if {$url eq {}} {
    puts "usage: $argv0 url"
    puts {The URL must be a KitCreator Web Interface build page.}
} else {
    download $url
}

|
|



>
|
<
|
>
|
|
<

|
<

<
>
|
<
<
|
|
|
|
>
|
|
|
|
<
<
|
|
>
>
>
>
>
>

>

|
|





|



1
2
3
4
5
6
7
8

9
10
11
12

13
14

15

16
17


18
19
20
21
22
23
24
25
26


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env tclsh
# KitCreator downloader v0.2.0 -- download Tclkits created with the KitCreator
# Web Interface. Works with Tcl 8.5+ and Jim Tcl v0.75+.
# Copyright (C) 2016, dbohdan.
# License: MIT.
proc download url {
    # Guess at what the buildinfo URL might be if we are given, e.g., a building
    # page URL.

    set url [string map {/building {}} $url]
    if {![string match */buildinfo $url]} {
        append url /buildinfo
    }


    set buildInfo [exec curl -s $url]



    set filename [dict get $buildInfo filename]
    append filename -[dict get $buildInfo tcl_version]


    append filename -[dict get $buildInfo platform]

    foreach option {staticpkgs threaded debug} {
        if {[dict exists $buildInfo options $option] &&
                [dict get $buildInfo options $option]} {
            append filename -$option
        }
    }



    append filename -[join [dict get $buildInfo packages] -]

    set tail [file tail $url]
    # We can't use [file dirname] here because it will transform
    # "http://example.com" into "http:/example.com".
    set baseUrl [string range $url 0 end-[string length $tail]]
    if {[string index $baseUrl end] ne {/}} {
        append baseUrl /
    }
    set tclkit $baseUrl[dict get $buildInfo filename]

    puts "Downloading $tclkit to $filename..."
    exec curl -o $filename $tclkit >@ stdout 2>@ stderr
}

set url [lindex $argv 0]
if {$url eq {}} {
    puts "usage: $argv0 url"
    puts {The URL must be a KitCreator Web Interface buildinfo page.}
} else {
    download $url
}