Install everything nicely. Generate tcllib.n. --- installer.tcl.orig Wed Jun 3 22:01:19 2015 +++ installer.tcl Thu Jun 4 01:41:03 2015 @@ -84,16 +84,24 @@ if {![package vsatisfies [package provide Tcl] 8.0]} { proc xcopyfile {src dest} { # dest can be dir or file + if {[file isdirectory $dest]} { + set dest [file join $dest [file tail $src]] + } + log "Installing $src to $dest" run file copy -force $src $dest + file attributes $dest -permissions 0o444 return } proc xcopy {src dest recurse {pattern *}} { + log "Making directory $dest" run file mkdir $dest + file attributes $dest -permissions 0o755 if {[string equal $pattern *] || !$recurse} { foreach file [glob -nocomplain [file join $src $pattern]] { set base [file tail $file] + if {$base eq "ChangeLog" || [file extension $base] in {.orig .beforesubst}} { continue } set sub [file join $dest $base] if {0 == [string compare CVS $base]} {continue} @@ -144,6 +152,7 @@ proc write_out {f text} { catch {file delete -force $f} puts -nonewline [set of [open $f w]] $text close $of + file attributes $f -permissions 0o444 } @@ -184,7 +193,6 @@ proc run {args} { return -code error "Install error:\n $msg" } } - log* . return } @@ -209,18 +217,23 @@ proc ainstall {} { set aexe [file join $distribution apps $a] set adst [file join $config(app,path) ${a}$ext] - log "\nGenerating $adst" - if {!$config(dry)} { - file mkdir [file dirname $adst] - catch {file delete -force $adst} - file copy -force $aexe $adst + if {![file exists $config(app,path)]} { + log "Making directory $config(app,path)" + run file mkdir $config(app,path) + file attributes $config(app,path) -permissions 0o755 } + _exafile $aexe $adst + if {[file exists $aexe.man]} { + set fn [file tail $aexe].n + _manfile [file join $distribution idoc man files apps $fn] [file join $config(doc,nroff,path) $fn] + } } return } proc doinstall {} { global config package_version distribution package_name modules excluded + global pkgs if {!$config(no-exclude)} { foreach p $excluded { @@ -230,26 +243,29 @@ proc doinstall {} { } } + array set pkgs [exec [info nameofexecutable] [file join $distribution sak.tcl] provided] + if {$config(doc,nroff)} { set config(man.macros) [string trim [get_input \ [file join $distribution support installation man.macros]]] } if {$config(pkg)} { xinstall pkg $config(pkg,path) - gen_main_index $config(pkg,path) $package_name $package_version } - if {$config(doc,nroff)} { + if 0 { foreach dir [glob -directory $distribution/idoc/man/files/modules *] { xcopy $dir $config(doc,nroff,path) 1 } xcopy $distribution/idoc/man/files/apps $config(doc,nroff,path) 1 } + xinstall doc [file join $distribution idoc man files modules] $config(doc,nroff,path) if {$config(doc,html)} { #xinstall doc html html $config(doc,html,path) xcopy $distribution/idoc/www $config(doc,html,path) 1 } - if {$config(exa)} {xinstall exa $config(exa,path)} + if {$config(exa)} {xinstall exa [file join $distribution examples] $config(exa,path)} if {$config(app)} {ainstall} + mkindex log "" return } @@ -511,6 +527,10 @@ proc processargs {} { set config(exa,path) [lindex $argv 1] set argv [lrange $argv 1 end] } + -csb - -descr - -mp - -tclsh - -wish { + set config([string range [lindex $argv 0] 1 end]) [lindex $argv 1] + set argv [lrange $argv 1 end] + } -help - default { puts stderr "usage: $argv0 ?-dry-run/-simulate? ?-no-wait? ?-no-gui? ?-html|-no-html? ?-nroff|-no-nroff? ?-examples|-no-examples? ?-pkgs|-no-pkgs? ?-pkg-path path? ?-apps|-no-apps? ?-app-path path? ?-nroff-path path? ?-html-path path? ?-example-path path?" @@ -566,6 +586,40 @@ proc wait {} { exit 0 } return +} + +proc mkindex {} { + global config package_name package_version modinfos + package require doctools + + set modinfos [lsort -dictionary -index 0 $modinfos] + + set title [expr {[string index $package_name 1] eq "k" ? "Tk" : "Tcl"}] + append title " Standard Library" + + set mp "" + append mp {[comment {-*- tcl -*- doctools manpage}]} + append mp "\[manpage_begin $package_name n $package_version\]" + append mp "\[titledesc {$title}\]" + append mp "\[moddesc {$title}\]" + + append mp {[description]} \n $config(descr) + + append mp {[section MODULES] [list_begin options]} + foreach mi $modinfos { + set s "\[opt_def {[lindex $mi 0]} [string map {& ""} [lindex $mi 1]]\]" + append mp $s [string map {\\& "" [ [lb] ] [rb] N& N s& s} " [lindex $mi 2] - [lindex $mi 3]"] + } + append mp {[list_end]} + + append mp {[manpage_end]} + + set fn [file join $config(doc,nroff,path) $package_name.n] + log "Installing $package_name.n to $fn" + set f [open $fn w] + puts -nonewline $f [[::doctools::new mp -format nroff] format $mp] + close $f + file attributes $fn -permissions 0o444 } # --------------------------------------------------------------