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 1 #!/usr/bin/env tclsh 2 -# KitCreator downloader v0.1.1 -- download Tclkits generated by 3 -# http://kitcreator.rkeene.org/kitcreator. Works with Tcl 8.5+ and Jim Tcl. 2 +# KitCreator downloader v0.2.0 -- download Tclkits created with the KitCreator 3 +# Web Interface. Works with Tcl 8.5+ and Jim Tcl v0.75+. 4 4 # Copyright (C) 2016, dbohdan. 5 5 # License: MIT. 6 6 proc download url { 7 - set page [split [exec curl -s $url] \n] 8 - set descr [lsearch -glob -inline $page *Description:*] 9 - regexp {(http://kitcreator.rkeene.org/[^"]+/tclkit)} \ 10 - [lsearch -glob -inline $page *URL:*] _ url 11 - 12 - set filename tclkit 13 - 14 - regexp {Tcl ([0-9.]+)} $descr _ version 15 - append filename -$version 16 - 17 - regexp {Platform ([-a-z0-9]+)} $descr _ platform 18 - append filename -$platform 19 - 20 - if {[regexp {packages statically linked} $descr]} { 21 - append filename -staticpkgs 7 + # Guess at what the buildinfo URL might be if we are given, e.g., a building 8 + # page URL. 9 + set url [string map {/building {}} $url] 10 + if {![string match */buildinfo $url]} { 11 + append url /buildinfo 22 12 } 23 13 24 - if {[regexp {Threaded} $descr]} { 25 - append filename -threaded 26 - } 14 + set buildInfo [exec curl -s $url] 15 + 16 + set filename [dict get $buildInfo filename] 17 + append filename -[dict get $buildInfo tcl_version] 18 + append filename -[dict get $buildInfo platform] 27 19 28 - if {[regexp {Packages: (.*)} $descr _ packages]} { 29 - foreach package $packages { 30 - set package [string trimright $package ,] 31 - append filename -$package 20 + foreach option {staticpkgs threaded debug} { 21 + if {[dict exists $buildInfo options $option] && 22 + [dict get $buildInfo options $option]} { 23 + append filename -$option 32 24 } 33 25 } 34 26 35 - puts "Downloading $url to $filename..." 36 - exec curl -o $filename $url >@ stdout 2>@ stderr 27 + append filename -[join [dict get $buildInfo packages] -] 28 + 29 + set tail [file tail $url] 30 + # We can't use [file dirname] here because it will transform 31 + # "http://example.com" into "http:/example.com". 32 + set baseUrl [string range $url 0 end-[string length $tail]] 33 + if {[string index $baseUrl end] ne {/}} { 34 + append baseUrl / 35 + } 36 + set tclkit $baseUrl[dict get $buildInfo filename] 37 + 38 + puts "Downloading $tclkit to $filename..." 39 + exec curl -o $filename $tclkit >@ stdout 2>@ stderr 37 40 } 38 41 39 42 set url [lindex $argv 0] 40 43 if {$url eq {}} { 41 44 puts "usage: $argv0 url" 42 - puts {The URL must be a KitCreator Web Interface build page.} 45 + puts {The URL must be a KitCreator Web Interface buildinfo page.} 43 46 } else { 44 47 download $url 45 48 }