Version ID

Version IDs are produced by the SDX "version" command. They are designed to make it easy to identify the version of a particular starkit. An example:

    $ sdx version critcl.kit
    2003/02/08 14:34:36  29946-43727  critcl.kit
    $

The first two values reported are the modification date and time of the most recent file found inside the starkit.

The third value is based on the 32-bit CRC of all names, dates, and sizes found inside the starkit.

The Tcl code on which the version ID calculation is based, is:

  proc traverse {args} {
    set sig 0
    set mod 0
    while {[llength $args] > 0} {
      set d [lindex $args 0]
      set args [lrange $args 1 end]
      foreach path [lsort [glob -nocomplain [file join $d *]]] {
        set t [file tail $path]
        switch -- $t CVS - RCS - core - a.out continue
        lappend sig $t
        if {[file isdir $path]} {
          lappend args $path
        } else {
          set m [file mtime $path]
          if {$m > $mod} { set mod $m }
          lappend sig $m [file size $path]
        }
      }
    }
    list [vfs::crc [join $sig " "]] $mod
  }

For purposes of readability, the resulting 32-bit value is formatted as 5 digits, dash, 5 digits:

  proc version_id {dir {name ""}} {
    lassign [traverse $dir] sig mod
    set time [clock format $mod -format {%Y/%m/%d %H:%M:%S} -gmt 1]
    puts [format {%s  %d-%d  %s} $time [expr {(($sig>>16) & 0xFFFF) + 10000}] \
                                        [expr {($sig & 0xFFFF) + 10000}] $name]
  }

Some comments: