1#--------------- 2# install.tcl 3#--------------- 4# Author(s): 5# Peter G Baum, 2003 6# William J Giddings, 2009 7#--------------- 8# Description: 9# Install package using Tcl. 10# This will ensure installation into correct directory. 11# Notes: 12# Ensure that pkgIndex.tcl is up to date. To ensure this,run 13# make pkgIndex.tcl. 14#--------------- 15 16#!/bin/sh 17# the next line restarts using /usr/local/bin/tclsh8.6 \ 18exec /usr/local/bin/tclsh8.6 "$0" "$@" 19 20#--------------- 21# lazy way to get preformated time and date 22#--------------- 23proc date { {i date} } { 24 switch -- $i { 25 d&t { set f "%c" } 26 year { set f "%Y" } 27 week { set f "%W" } 28 day { set f "%A" } 29 month { set f "%B" } 30 time { set f "%H:%M:%S" } 31 date { set f "%d/%m/%y" } 32 date4 { set f "%Y-%m-%d" } 33 D4T24 { set f "%Y-%m-%d %T" } 34 } 35 return [clock format [clock seconds] -format "$f"] 36} 37 38# error checking 39if { $argc != 4 } { 40 set name [file tail $argv0] 41 error "Wrong number of args.\nUsage: $name package version install/uninstall" 42} 43 44# get parameters 45foreach {package version name what} $argv { break } 46 47# get installation directory 48set dir /opengrok/src/dports/x11-toolkits/gnocl/stage/usr/local/lib 49 50# create sub-directory to receive package 51set destDir [file join $dir $name$version] 52switch -- $what { 53 "install" { 54 if { [file exists $destDir] } { 55 puts "$destDir exists already. Aborting installation." 56 exit -1 57 } 58 puts "Create updated package file." 59 set fp [open pkgIndex.tcl "w"] 60 puts $fp "# Created: [date] [date time]" 61 puts $fp {# Tcl package index file, version 1.1} 62 puts $fp {# This file is sourced either when an application starts up or} 63 puts $fp {# by a "package unknown" script. It invokes the} 64 puts $fp {# "package ifneeded" command to set up package-related} 65 puts $fp {# information so that packages will be loaded automatically} 66 puts $fp {# in response to "package require" commands. When this} 67 puts $fp {# script is sourced, the variable $dir must contain the} 68 puts $fp {# full path name of this file's directory.} 69 puts $fp {} 70 puts $fp "package ifneeded $package $version \[list load \[file join \$dir $name.so\]\]" 71 close $fp 72 puts "Creating $destDir" 73 file mkdir $destDir 74 set files [glob *.so] 75 lappend files pkgIndex.tcl 76 foreach file $files { 77 puts "Copying $file" 78 file copy $file $destDir 79 exec chmod 444 $file 80 } 81 } 82 "uninstall" { 83 puts "Deleting $destDir" 84 file delete -force $destDir 85 } 86 default { 87 error "unknown type \"$what\" must be install, test or uninstall" 88 } 89} 90 91