#!/usr/bin/tclsh set WebSite "http://www-obs.univ-lyon1.fr/labo/perso/arlette.pecontal/IFU_soft_dev" proc print_usage {} { puts "Usage: check_for_IFU_updates [-v|-verbose]" } proc no_install_found {} { puts "None IFU installation found on your system" puts "Please set your IFU_PATH environment variable to the correct PATH" } global env argc argv set verbose 0 if {$argc == 1} { # verbose option ? if {[lindex $argv 0] == "-v"} { set verbose 1 } { if {[lindex $argv 0] == "-verbose"} { set verbose 1 } { print_usage exit } } } if {$verbose == 0} { puts "Tip: Use -v option for more details" } if {$argc > 1} { print_usage exit } # check for IFU packages location # does IFU_PATH exists ? set varnames [split [array names env]] if {[lsearch $varnames IFU_PATH] < 0} { no_install_found exit } set IFU_PATH $env(IFU_PATH) if {[string trim $IFU_PATH] == ""} { no_install_found exit } # retrieve last versions from Webserver catch "exec wget -N $WebSite/last_versions" set fd [open last_versions r] set archives [split [read $fd] "\n"] close $fd exec rm last_versions # for each archive ... foreach file $archives { if {[string trim $file] == ""} { continue } catch "exec wget -N $WebSite/ChangeLog.$file.txt" set dir [file rootname [file rootname $file]] if {![file exists $IFU_PATH/$dir/ChangeLog]} { # ChangeLog not present (old packages versions) puts "\n!!! Directory $dir not found. Please update archive $file " if {$verbose} { puts "List of changes:" set fd [open ChangeLog.$file.txt r] set changes [split [read $fd] "\n"] close $fd foreach line $changes { puts $line } } } else { if {[catch "exec diff ChangeLog.$file.txt $IFU_PATH/$dir/ChangeLog" error]} { set changes [split $error "\n"] set nb 0 foreach line $changes { if {[string index $line 0 ] == "<"} { incr nb } } if {$nb == 0} { puts "Archive $file is newer than the one on the Web server" } else { if {$verbose} { # puts changes between install and webserver version puts "List of changes for $file:" foreach line $changes { if {[string index $line 0 ] == "<"} { puts [string range $line 2 end] } } } puts "\n!!! Please update archive $file" } } { puts "$file is up to date" } } exec rm ChangeLog.$file.txt } # end