Posted to tcl by hypnotoad at Thu Dec 03 16:17:33 GMT 2015view pretty

proc fossil_dbfile {module} {
  if {![info exists ::fossil_dbfile($module)]} {
    set ::fossil_dbfile($module) [file join $::fossilRepoPath $module.fossil]
  }
  return $::fossil_dbfile($module)
}

set scriptfile  [file join [pwd] [info script]]
set tclsrcroot [file dirname [file dirname $scriptfile]]
set fossilRepoPath [file join $tclsrcroot .. fossil]
set tclConfigPath  [file join $tclsrcroot .. tclconfig]


foreach line [split [exec fossil all list] \n] {
   set file [string trim $line]
   set module [file rootname [file tail $file]]
   set fossil_dbfile($module) $line
}

if {![file exists $tclConfigPath]} {
  set dbfile [fossil_dbfile tclconfig]
  if {![file exists $dbfile]} {
    fossil clone http://core.tcl.tk/tclconfig $dbfile
  }
  file mkdir $tclConfigPath
  cd $tclConfigPath
  fossil open $dbfile trunk
}

foreach {module url tag} {
  thread http://core.tcl.tk/thread trunk
  sqlite http://cyqlite.sourceforge.net/cgi-bin/sqlite trunk
  tdbc http://core.tcl.tk/tdbc trunk
  tdbcsqlite http://core.tcl.tk/tdbcsqlite trunk
} {
   set fossdb [fossil_dbfile $module]
   if {![file exists $fossdb]} {
     fossil clone $url $fossdb
   }
   set srcpath [file join $tclsourceroot pkgs $module]]
   if {![file exists $srcpath]} {
      file mkdir $srcpath
      cd $srcpath
      exec fossil open $fossdb $tag --nested
      if {[file exists [file join $tclsourceroot tools/pkgs/$module.tcl]]} {
         source [file join $tclsourceroot tools/pkgs/$module.tcl]
      }
   } else {
      cd $srcpath
      exec fossil update $tag
   }
}