ADDED client/examples/example-1.tcl Index: client/examples/example-1.tcl ================================================================== --- /dev/null +++ client/examples/example-1.tcl @@ -0,0 +1,12 @@ +#! /usr/bin/env tclsh + +lappend auto_path [file join [file dirname [info script]] .. lib] + + package require teapotclient + + puts "The following extensions are available:" + foreach {extension extensioninfo} [::teapotclient::get_extensions \ + [list teapot.activestate.com] \ + {*} {*}] { + puts " $extension [join $extensioninfo {, }]" + } ADDED client/examples/example-2.tcl Index: client/examples/example-2.tcl ================================================================== --- /dev/null +++ client/examples/example-2.tcl @@ -0,0 +1,16 @@ +#! /usr/bin/env tclsh + +lappend auto_path [file join [file dirname [info script]] .. lib] + + package require teapotclient + + set os $tcl_platform(os) + if {$tcl_platform(platform) == "windows"} { + set os $tcl_platform(platform) + } + + puts "Downloading md5 and sha1 packages for the current system" + ::teapotclient::download_extensions "lib" \ + [list teapot.activestate.com] [list md5 sha1] $os \ + $tcl_platform(machine) + Index: client/lib/teapotclient0.1/teapotclient.tcl ================================================================== --- client/lib/teapotclient0.1/teapotclient.tcl +++ client/lib/teapotclient0.1/teapotclient.tcl @@ -51,11 +51,16 @@ set cpuTeapotToLocal(ix86) x86 set cpuTeapotToLocal(sparc) sun4* set cpuTeapotToLocal(universal) * set cpuTeapotToLocal(powerpc) ppc - proc download_extensions {rootdir servers extensions os cpu {existingExts "Tcl Tk"}} { + proc download_extensions {rootdir servers extensions os cpu {existingExts ""}} { + foreach chkdefext [list Tcl Tk] { + if {[lsearch -exact $existingExts $chkdefext] == -1} { + lappend existingExts $chkdefext + } + } foreach server $servers { foreach {pkg pkginfo} [get_extensions $server $os $cpu] { foreach pkginstance $pkginfo { lappend pkginstance $server lappend pkgdata($pkg) $pkginstance @@ -79,11 +84,11 @@ set ver [lindex $pkginfo 0] set arch [lindex $pkginfo 1] set server [lindex $pkginfo 2] - set pkgdir [file join $rootdir lib $extension$ver] + set pkgdir [file join $rootdir $extension$ver] file mkdir $pkgdir $::teapotclient::pkgcachedir set url "http://$server/package/name/$extension/ver/$ver/arch/$arch/file" set urlcachefile [file join $::teapotclient::pkgcachedir [::md5::md5 -hex $url]] Index: client/teapot-client.tcl ================================================================== --- client/teapot-client.tcl +++ client/teapot-client.tcl @@ -23,11 +23,11 @@ set dir [lindex $argv 0] set os [lindex $argv 1] set cpu [lindex $argv 2] set packages [lrange $argv 3 end] - set extsinfo [::teapotclient::download_extensions $dir $teapotservers $packages $os $cpu] + set extsinfo [::teapotclient::download_extensions [file join $dir lib] $teapotservers $packages $os $cpu] set exts [list] puts "Fetched Extensions:" foreach {ext extinfo} $extsinfo { lappend exts $ext puts " $ext v[lindex $extinfo 0]"