#!/usr/bin/tclsh # First, auto-generate the standard direct-style package index pkg_mkIndex -verbose -direct . *.tcl file rename -force pkgIndex.tcl pkgIndex.tcl.direct set in [open pkgIndex.tcl.direct r] set out [open pkgIndex.tcl w] # Now generate a new version that hides the sub-packages puts $out [gets $in] # Tcl package index file, version 1.1 puts $out " # This file is generated by the MakeIndex script in the tclhttpd # lib directory. The goal is to not pollute the package namespace # until you package require httpd " # Skip the other comment block. We know the line for # httpd comes first. while {[gets $in line] >= 0} { if {[regexp {package ifneeded httpd ([^ ]+)} $line x version]} { puts $out "package ifneeded httpd $version \"" puts $out "\tsource \\\[file join \[list \$dir] httpd.tcl\\\]" break } } # Now reformat the other lines slightly to protect the # list and file join commands, but let the $dir get expanded while {[gets $in line] >= 0} { regsub -all {[][]} $line {\\&} line regsub -all {\$dir} $line {[list &]} line puts $out \t$line } puts $out "\""