#!/bin/sh # # Tcl/Tk script for installing the submit executable # # Bill Bynum # December, 1998 # \ # these are the paths where tclsh and wish will be found \ PATH=$PATH:/usr/local/bin:/usr/lib:/usr/bin #\ export PATH #\ case $DISPLAY in #\ "") exec tclsh "$0" "$@" ;; #\ *) exec wish "$0" "$@" ;; #\ esac ###################################################################### # # Tcl/Tk globals # # arrays # global IntialValue ;# initial & final values of editable entries global FinalValue ;# in Tcl/Tk dialogs global SubmitExe ;# filenames of the master submit executable global exeArch ;# architecture of the submit exes, indexed by group # lists # global NewGroups ;# groups in the user's new .installsubmitrc global Windows ;# list of active windows global Groups ;# groups to which user belongs # The next two lists are used to cycle the selected group choice button # in the X version. Their union is always Groups. When a exes for a # group are installed, that group is moved from Unchosen to Chosen. # When Unchosen is empty, the contents of the lists are switched. global Chosen global Unchosen # procs # These globals, along with the fact that Tcl is an interpreted # provide a way of doing a little home-grown polymorphism. # The program picks the right output proc (X11 or non-X11) based # on whether the DISPLAY variable is set global LocateExes ;# place the submit executable global OK ;# warn user with modal OK? dialog global Tell ;# show user verbose output # flags # global UsingGroups ;# 1 if user belongs to more than one group global Verbose ;# 1 if user wants verbose output global WriteNeeded ;# 1 if fix_exes ever succeeds # other variables global ISfname ;# name of the install_submit startup file global Version ;# install_submit version number # most of these globals are initialized in the main program # at the bottom of the file ###################################################################### # # Window handling procs # necessary for a graceful exit from X # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # add_window # adds window 'w' to the Window list, if it's not already there proc add_window { w } { global Windows set i [lsearch -exact $Windows $w] if { $i < 0 } { ;# only add 'w' if it's not there lappend Windows $w } } ;# add_window #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # destroy_window # destoys window 'w' # and if it was the only window left, kills the withdrawn . proc destroy_window { w } { global Windows set i [lsearch -exact $Windows $w] if { $i >= 0 } { set Windows [lreplace $Windows $i $i] } destroy $w if { [llength $Windows] == 0} { destroy . } } ;# destroy_window ###################################################################### # I/O procs # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # ok_win # displays s and waits for click of OK button # proc ok_win { s } { global WTitle if [winfo exists .td] { destroy .td} toplevel .td add_window .td wm title .td "$WTitle -- OK?" wm geometry .td +400+400 label .td.l -text "$s" button .td.ok -text OK -command { destroy_window .td} pack .td.l -pady 2m -padx 2m pack .td.ok -fill x -expand 1 set win [grab current] grab set .td tkwait window .td if { $win != "" } { grab set $win } } ;# ok_win #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # ok_dlg # displays s and waits for OK response # proc ok_dlg { s } { puts stderr "==========================" puts stderr "$s?" puts stderr "==========================" flush stderr puts -nonewline stderr "(press any key to continue): " gets stdin ans return {} } ;# ok_dlg #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # tell_win # writes s to the verbose output window, if it's there, # else writes s to stderr # proc tell_win { s } { global Windows global .v if { [lsearch -exact $Windows .v ] < 0 } { puts stderr "$s" } else { .v.f.t insert end "$s\n" .v.f.t see end update } } ;# tell_win #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # tell_dlg # writes s to stderr # proc tell_dlg { s } { puts stderr "$s" flush stderr } ;# tell_dlg ###################################################################### # tools to facilitate building Tk windows # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # set_rbutton # An auxiliary proc to make_rbutton. # This is the action performed when one of the radio buttons # of the rbmenu is selected. # Sets the global FinalValue($bname) to $val and resets the # name of the "button" to $val. # proc set_rbutton { button bname val } { global FinalValue set FinalValue($bname) $val $button configure -text "$val" } ;# set_rbutton #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # make_rbmenu # creates an menu button for a Tk display having the form # # +=================+ # | | # +=================+ # |<--- bwidth ---->| # # The button is packed on the left in the frame "fn". The button's # menu consists of radiobuttons, one for each element of "allitems". # "onitem" is the member of "allitems" that is checked initially. # # All radio buttons access the global variable "FinalValue($bname)". # On entry, this variable has the value "onitem", which is stored # in the global variable InitialValue($bname). # # The name of the radio button that has been chosen is stored in # # proc make_rbmenu {fn bname bwidth onitem allitems } { global InitialValue global FinalValue set b $fn.$bname menubutton $b -text "$onitem" -menu $b.m -width [ incr bwidth -1] \ -relief raised -anchor w menu $b.m -tearoff 0 pack $b -side left -fill both -expand 1 -anchor w set InitialValue($bname) "$onitem" set FinalValue($bname) "$onitem" foreach i $allitems { $b.m add radiobutton -label $i -variable FinalValue($bname) \ -command [list set_rbutton $b $bname $i] } pack $b -side left -in $fn } ;# make_rbmenu #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # make_entry_frame # creates an editable entry frame for a Tk display having the form # # +---------------------------------+ # | +=================+ | # frame, named "frame_name" | label_text | init_text | | # | +=================+ | # +---------------------------------+ # |<----------->|<----------------->| # lt_width it_width # # in the window "wn" # # adds the two symbols # "InitialValue($valindex)" and "FinalValue($valindex)" # to the two global arrays used by the caller to # compare the initial value of the editable entry text and its # value after editing # proc make_entry_frame {wn frame_name valindex label_text lt_width init_text it_width} { global InitialValue global FinalValue if {$wn == "." } { set wn "" } global $wn.$frame_name frame $wn.$frame_name label $wn.$frame_name\_l -text "$label_text" -width $lt_width -anchor w entry $wn.$frame_name\_e -width $it_width -relief sunken \ -textvariable FinalValue($valindex) set InitialValue($valindex) "$init_text" $wn.$frame_name\_e delete 0 end $wn.$frame_name\_e insert end $InitialValue($valindex) pack $wn.$frame_name\_l $wn.$frame_name\_e -side left \ -in $wn.$frame_name } ###################################################################### # procs for manipulating .installsubmitrc & installing submit exes # #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # read_installsubmitrc # reads the .installsubmitrc file # proc read_installsubmitrc { } { global Groups global NewGroups global InitialValue global ISfname global env global exeArch set prevGroups {} set NewGroups {} if [catch [list open $ISfname "r"] fd] { return } while {1} { set ct [gets $fd line] if { $ct < 0 } { set NewGroups $prevGroups return } elseif [string match {#*} $line] { ;# skip comment lines continue } else { ;# line is valid # format of a non-comment line of .installsubmitrc is # group submit_dirname Architecture (Pentium or PowerMac) # or # group submit_filename Architecture (Pentium or PowerMac) # set group [lindex $line 0] if {[lsearch -exact $Groups $group] < 0} { continue ;# skip any line with a spurious group name } lappend prevGroups $group if {[llength $line] >= 2} { ;# use first format above set tmp [lindex $line 1] set six [expr [string last "submit" $tmp ] - 1] if { $six >= 0 } { set InitialValue($group) [string range $tmp 0 $six] } else { set InitialValue($group) $tmp } if {[llength $line] >= 3} { set exeArch($group) [lindex $line 2] } else { ;# choose Pentium if no architecture is specified set exeArch($group) Pentium } } else { ;# skip any malformed line continue } } ;# else line is valid } ;# while 1 } ;# read_installsubmitrc #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # write_installsubmitrc # updates the .installsubmitrc file, if possible # proc write_installsubmitrc {} { global InitialValue global FinalValue global ISfname global Version global NewGroups global env global Verbose global OK global Tell global exeArch if {$Verbose} { $Tell "Writing $ISfname" } if [catch [list open $ISfname "w"] af] { $OK "Can't open $ISfname" return } puts $af "# Created by $Version" puts $af "# on [exec date]" puts $af "# group submitexe_location architecture" foreach g $NewGroups { puts -nonewline $af " $g" if [info exists FinalValue($g)] { if [info exists exeArch($g)] { puts $af " $FinalValue($g) $exeArch($g)" } else { puts $af " $FinalValue($g)" } } elseif [info exists InitialValue($g)] { if [info exists exeArch($g)] { puts $af " $InitiaValue($g) $exeArch($g)" } else { puts $af " $InitialValue($g)" } } } ;# foreach g close $af } ;# write_installsubmitrc #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # check_exe_path # checks each directory in the 'path' string to see that it # exists and has +x protection. If the directory doesn't exist, # then the directory is created with protection mode 0711 # returns 0 if everything was OK, 1 otherwise # proc check_exe_path { path } { global Verbose global OK global Tell set comps [split $path "/"] set c {} for {set i 1} {$i < [llength $comps]} {incr i} { set newdir [lindex $comps $i] append c "/$newdir" if { [file exists $c] } { set prot [lindex [exec ls -ld $c] 0] if {! [string match {???x??x??[xt]} $prot] } { if [catch [exec chmod 0711 $c] tmp] { $OK "Can't set 0711 protection for directory\n$tmp" return 1 } } } else { if {$Verbose} { $Tell "Creating $c with protection 0711" } if [catch [exec mkdir -m 0711 $c] tmp] { $OK "Can't create directory\n$tmp" return 1 } } } return 0 } #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # copy_exe # creates locals 'src_exe' and 'dest_exe' by appending 'submit' # to parms 'src_exe_dir' and 'dest_exe_dir' # copies 'src_exe' to 'dest_exe', changing its group to # $group and setting its protection to 6711 # returns 0 if everything was OK, 1 otherwise # proc copy_exe { src_exe dest_exe group } { global OK global Tell global FinalValue global Verbose set src_exe $src_exe set dest_exe $dest_exe\submit if {$Verbose} { $Tell "Removing old copy of $dest_exe" } if [catch [exec rm -f $dest_exe] tmp] { $OK "Can't remove executable\n$dest_exe\n$tmp" return 1 } if {$Verbose} { $Tell "Copying $src_exe\n to $dest_exe" } if [catch [exec cp $src_exe $dest_exe] tmp] { $OK "Can't copy executable\n$src_exe\nto $dest_exe\n$tmp" return 1 } if {$Verbose} { $Tell "Changing group of $dest_exe to $FinalValue(group)" } if [catch [exec chgrp $group $dest_exe] tmp] { $OK "Can't change group of\n$dest_exe\nto $FinalValue(group)\n$tmp" return 1 } if {$Verbose} { $Tell "Setting protection mode of $dest_exe to 06711" } if [catch [exec chmod 6711 $dest_exe] tmp] { $OK "Can't bestow 6711 protection to\n$dest_exe\n$tmp" return 1 } return 0 } ;# copy_exe #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # fix_exes # place the executables where they're wanted to be, if possible # return 1 if something goes wrong, else return 0 # proc fix_exes { } { global FinalValue global InitialValue global SubmitExe global exeArch global WriteNeeded set group $FinalValue(group) addNewGroup $group set submitExecutable $SubmitExe($exeArch($group)) if [check_exe_path [file dirname $FinalValue($group)]] { return 1 } if [copy_exe $submitExecutable $FinalValue($group) $group] { return 1 } set InitialValue($group) $FinalValue($group) set WriteNeeded 1 return 0 } ;# fix_exes #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # set_default_locations # sets default locations for the submit script and executables and # the group 'group', in case they weren't specified in the # .installsubmitrc # proc set_default_exelocs { group } { global InitialValue global FinalValue global exeArch global env if {! [info exists InitialValue($group)] } { set InitialValue($group) $env(HOME)/bin/ } if {! [info exists FinalValue($group)] } { set FinalValue($group) $env(HOME)/bin/ } if {! [info exists exeArch($group)] } { set exeArch($group) Pentium } } ;# set_default_exelocs #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # nextGroup # 'group' is the previous choice, and can either be "" or in # Chosen. # 'group' is added to Chosen, if it's not already there. # If Unchosen is empty, then Chosen & Unchosen are swapped # and the first member of Unchosen is returned. # Abort if 'group' is not "" and not in Chosen. proc nextGroup { group } { global Chosen global Unchosen if {[string compare $group ""] != 0} { set j [lsearch -exact $Chosen $group] ;# group in Chosen? if { $j < 0 } { ;# if not, add it & remove it from Unchosen lappend Chosen $group set i [lsearch -exact $Unchosen $group] if {$i >= 0} { set Unchosen [lreplace $Unchosen $i $i] } else { puts stdout "Aborting!! $group not in Unchosen .$Unchosen." exit 1 } } } if { [llength $Unchosen] == 0 } { set Unchosen $Chosen set Chosen "" } return [lindex $Unchosen 0] } ;# nextGroup #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # addNewGroup # add 'group' to NewGroups list if it's not already there # proc addNewGroup { group } { global NewGroups global Groups if { [lsearch -exact $NewGroups $group] < 0 } { # if $group is first in Groups, then make it first in NewGroups if { $group == [lindex $Groups 0] } { set NewGroups [concat $group $NewGroups] } else { lappend NewGroups $group } } } ;# addNewGroup #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # do_another_group # destroy the window 'w', then call locate_exes_win with # the groupname different from 'group'. proc do_another_group { w } { global FinalValue destroy_window $w locate_exes_win [nextGroup $FinalValue(group)] } ;# do_another_group #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # another_group_win # window to allow user to install submit executable # for another group or quit proc another_group_win { } { global Windows global WTitle toplevel .ag add_window .ag wm title .ag "$WTitle -- More??" wm geometry .ag +400+400 label .ag.l -text "Install submit executable\nfor another group?" button .ag.y -text "Yes" -command {do_another_group .ag} button .ag.q -text "Quit" -command {destroy_window .ag} pack .ag.l .ag.y .ag.q -side top -padx 1m -pady 1m -expand 1 -fill both tkwait window .ag } ;# another_group_win #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # verbose_fix_exes # set the Verbose flag, create the window for verbose output, # call fix_exes, and ifsuccessful, destroy the window .le # proc verbose_fix_exes { } { global UsingGroups global FinalValue global Verbose global .v set Verbose 1 create_verbose_window tkwait visibility .v if { ! [fix_exes] } { if {$UsingGroups} { add_window .ag destroy_window .le another_group_win } else { tkwait window .v destroy_window .le } } } ;# verbose_fix_exes #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # quiet_fix_exes # clear the Verbose flag, call fix_exes and if successful, # destroy the window .le # proc quiet_fix_exes { } { global UsingGroups global Verbose global FinalValue global Groups set Verbose 0 if { ! [fix_exes] } { if {$UsingGroups} { add_window .ag destroy_window .le another_group_win } else { exit } } } ;# quiet_fix_exes #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # locate_exes_win # a Tk dialog to display the locations of the submit script # and executables for a given group and to allow the user to # modify them. # proc locate_exes_win { group } { global InitialValue global FinalValue global env global UsingGroups global Verbose global WTitle global Windows global Groups global exeArch global exeArchitecture toplevel .le add_window .le wm title .le "$WTitle -- Locate Executables" set lcw 18 set rcw 45 set_default_exelocs $group set FinalValue(group) $group frame .le.f1 label .le.f1.l -text "User $env(USER) installing the submit program executable" pack .le.f1.l -in .le.f1 -side top -expand 1 -fill both pack .le.f1 -side top -fill both -expand 1 -padx 2m -pady 2m frame .le.f1a radiobutton .le.f1a.rbPe -variable exeArchitecture -text Pentium \ -value Pentium pack .le.f1a.rbPe -in .le.f1a -side left -fill both -expand 1 radiobutton .le.f1a.rbPM -variable exeArchitecture -text PowerMac \ -value PowerMac pack .le.f1a.rbPM -in .le.f1a -side left -fill both -expand 1 label .le.f1a.l -text "Executable (choose one)" pack .le.f1a.l -in .le.f1a -side left -fill both -expand 1 pack .le.f1a -side top -fill both -expand 1 -padx 2m -pady 2m if { $exeArch($group) == "PowerMac"} { .le.f1a.rbPM select } else { .le.f1a.rbPe select } if {$UsingGroups} { frame .le.f2 label .le.f2.l2 -text "using group;" -width $lcw -anchor w pack .le.f2.l2 -in .le.f2 -side left -expand 1 -fill both make_rbmenu .le.f2 group 12 $group $Groups pack .le.f2 -side top -fill y -expand 1 -anchor w -pady 2m } else { set FinalValue($group) $InitialValue($group) } make_entry_frame .le submit $group "install directory" $lcw \ $InitialValue($group) $rcw pack .le.submit -side top -expand 1 -fill both frame .le.f3 button .le.f3.iv -text "Install verbosely" -padx 3m -pady 3m \ -command { set exeArch($FinalValue(group)) $exeArchitecture; \ verbose_fix_exes} button .le.f3.iq -text "Install quietly" -padx 3m -pady 3m \ -command { set exeArch($FinalValue(group)) $exeArchitecture; \ quiet_fix_exes} button .le.f3.d -text "Quit" -padx 3m -pady 3m \ -command {destroy_window .le} pack .le.f3.iv .le.f3.iq .le.f3.d -side left -in .le.f3 -expand 1 \ -fill both pack .le.f3 -side top -expand 1 -fill both tkwait window .le } ;# locate_exes_win #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # create_verbose_window # creates window for verbose output # proc create_verbose_window { } { global WTitle global Windows if [winfo exists .v] {destroy .v} toplevel .v add_window .v wm title .v "$WTitle -- Verbose Output" frame .v.f text .v.f.t -wrap word -width 60 -height 22 -yscrollcommand {.v.f.s set} pack .v.f.t -in .v.f -side left -fill both -expand 1 scrollbar .v.f.s -orient vert -command {.v.f.t yview} pack .v.f.s -in .v.f -side right -fill y pack .v.f -side top -fill both -expand 1 -padx 2m -pady 2m button .v.b -text "Dismiss" -command {destroy_window .v} pack .v.b -side top -fill both -expand 1 -padx 2m -pady 2m } ;# create_verbose_window #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # choose_exeloc_dlg # The value of FinalValue($group) is determined by this routine. # If InitialValue($group) exists, the it is copied to # FinalValue($group); otherwise, the user is engaged in # a dialog to choose a new file name. # The default file name presented to the user in this dialog # is constructed in one of two ways: # 1. If FinalValue($group) exists, then it is used as the # default, because it was formed previously and user might want # to use it as is. # 2. Otherwise, a "standard" default filename is constructed from # $env(HOME). # proc choose_exeloc_dlg { exe_title } { global UsingGroups global InitialValue global FinalValue global env set group $FinalValue(group) if [info exists InitialValue($group)] { set FinalValue($group) $InitialValue($group) } else { ;# InitialValue($group) doesn't exist if [info exists FinalValue($group)] { set exe_dir [file dirname $FinalValue($group)] set exe_name $exe_dir\submit } else { set exe_dir $env(HOME)/bin set exe_name $exe_dir/submit } puts -nonewline stdout \ "Enter the directory for the location of the $exe_title" if {$UsingGroups} { puts stdout " in group $group" } else { puts stdout "" ;# the newline } puts stdout "RETURN ==> $exe_dir" puts stdout \ "(If first character of your reply is not '/', then your reply will be" puts stdout " appended to $exe_dir" flush stdout gets stdin ans if [string match {/*} $ans] { set FinalValue($group) $ans } elseif {$ans != ""} { set FinalValue($group) $exe_dir/$ans } else { set FinalValue($group) $exe_dir } } ;# InitialValue($group) doesn't exist } ;# choose_exeloc_dlg #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # choose_installation # choose verbose, quiet, or no installation, then do it # return 1 if something went wrong, 0 if all was OK # proc choose_installation { group } { global InitialValue global FinalValue global exeArch global Verbose while {1} { puts stdout "The submit executable for the $exeArch($group) architecture" puts stdout "will be installed in $FinalValue($group) directory" puts stdout " " puts stdout "Choose one of the following:" puts stdout " 1. Let me change the architecture of the submit executable" puts stdout " 2. Let me change the installation directory" puts stdout " 3. Install verbosely" puts stdout " 4. Install quietly" puts stdout " 5. Don't install" puts -nonewline "Enter 1..5: " flush stdout gets stdin ans if {$ans == 1} { choose_architecture $group } elseif {$ans == 2} { if [info exists InitialValue($group)] { unset InitialValue($group) } return 1 } elseif {$ans == 3} { set Verbose 1 return [fix_exes ] } elseif {$ans == 4} { set Verbose 0 set ret [fix_exes] puts stdout "Installation completed" return $ret } elseif {$ans == 5} { return 0 } } } ;# choose_installation #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # choose_architecture # command line proc the user employs to select the architecture # of the submit executable for group 'group' # proc choose_architecture { group } { global FinalValue global exeArch while (1) { puts stdout "There are submit executables for the Pentium and PowerMac architectures" puts stdout "The current architecture chosen is $exeArch($group)" puts stdout " Enter A to choose the Pentium architecture" puts stdout " Enter B to choose the PowerMac architecture" flush stdout puts -nonewline stdout "Enter A or B: " flush stdout gets stdin ans if {$ans == "A"} { set exeArch($group) Pentium return; } elseif {$ans == "B"} { set exeArch($group) PowerMac return; } } ;# while 1 } ;# choose_architecture #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # choose_group_dlg # command line proc the user employs to select the group of the submit # executables # proc choose_group_dlg { } { global Groups global FinalValue while {1} { puts stdout "Install submit executable using group:" set i 1 foreach g $Groups { puts stdout " $i. $g" incr i } puts stdout "or" puts stdout " $i. Quit" flush stdout while {1} { puts -nonewline stdout "Enter 1..$i: " flush stdout gets stdin ans if {($ans < 0) || ($ans > $i)} { puts stdout "\"$ans\" is not a valid choice" flush stdout } else { break } } ;# inner while 1 if {$ans < $i} { set ix [expr $ans - 1] set FinalValue(group) [lindex $Groups $ix] locate_exes_dlg } else { exit } } ;# outer while 1 } ;# choose_group_dlg #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # locate_exes_dlg # a command line dialog to display the locations of the submit script # and executables and allow the user to modify them proc locate_exes_dlg { } { global InitialValue global FinalValue global env global UsingGroups global Verbose set group $FinalValue(group) set_default_exelocs $group while { 1 } { choose_exeloc_dlg "submit executable" if { ![choose_installation $group] } { return } } ;# while 1 } ;# locate_exes_dlg ###################################################################### # # # # # Main Program # # # # # ###################################################################### set Version "\$Id: install_submit,v 1.25 2006/09/13 15:59:25 bynum Exp $" # set the locations of the source submit exes set prefix /home/f85/bynum/submit_pgms set SubmitExe(Pentium) $prefix/submit.Pentium set SubmitExe(PowerMac) $prefix/submit.PowerMac # if the user gives the name of a group to which she/he belongs # on the command line, then don't consider any other groups; # otherwise, use all groups if { $argc > 0} { set argv1 [lindex $argv 0] set tmp [exec groups] if {$argc > 1} { if { $argv1 == "-v" } { set Verbose 1 set argv1 [lindex $argv 1] } } if { [lsearch -exact $tmp $argv1] < 0} { ;# invalid group name, use all set Groups $tmp set UsingGroups [expr [llength $Groups] > 1] } else { set Groups $argv1 set UsingGroups 0 } } else { set Groups [exec groups] set UsingGroups [expr [llength $Groups] > 1] } set FinalValue(group) [lindex $Groups 0] set ISfname $env(HOME)/.installsubmitrc read_installsubmitrc set WriteNeeded 0 if [info exists env(DISPLAY)] { ;# in X set inX 1 option add *Font "-misc-fixed-medium-r-normal-*-20-*-*-*-*-*-*-*" global WTitle set WTitle "Install Submit" set OK ok_win set Windows "" set Tell tell_win set Unchosen $Groups set Chosen "" wm withdraw . locate_exes_win [lindex $Groups 0] } else { ;# using the command line set inX 0 set OK ok_dlg set Tell tell_dlg # if the user gives the name of a group to which she/he belongs # on the command line, then don't consider any other groups; # otherwise, use all groups if { $argc > 0} { set argv1 [lindex $argv 0] set tmp [exec groups] if {$argc > 1} { if { $argv1 == "-v" } { set Verbose 1 set argv1 [lindex $argv 1] } } if { [lsearch -exact $tmp $argv1] < 0} { ;# invalid group name, use all set Groups $tmp set UsingGroups [expr [llength $Groups] > 1] } else { set Groups $argv1 set UsingGroups 0 } } if {$UsingGroups} { choose_group_dlg } else { locate_exes_dlg } } ;# else using the command line if {$WriteNeeded} { write_installsubmitrc } # # $Log: install_submit,v $ # Revision 1.25 2006/09/13 15:59:25 bynum # minor changes to write_installsubmit # # Revision 1.24 2006/09/13 15:54:50 bynum # remove write_script, change to install Pentium or PowerMac exes # # Revision 1.23 2002/05/15 16:55:56 bynum # change from mom4 to f85 # # Revision 1.22 2001/09/10 20:59:41 bynum # fix a number of errors involving group handling (only handling symbolic # links needs fixing) # # Revision 1.21 2001/09/06 20:41:08 bynum # correct several un-dollared OK calls, make .td window toplevel, # grab the focus for .td window # # Revision 1.20 2000/08/14 20:39:25 bynum # remove submit shell script, references to SunOS version # # Revision 1.19 1999/09/14 16:22:46 bynum # change all FinalValue($group,*) vars to FinalValue(*) to fix # group setting bug # # Revision 1.18 1999/01/14 19:13:01 bynum # change locate_exes_win to use a pull-down menu of radio buttons to # choose the group, eliminate the previous choose groups window, and # add a small window the user can click to install more groups # # Revision 1.17 1999/01/06 21:43:34 bynum # recast as Tcl/Tk script # # Revision 1.16 1998/10/01 19:04:20 bynum # write locations of executables into submit script on Sun installation # # Revision 1.15 1998/10/01 18:37:38 bynum # add i686 to the case written to the submit script # # Revision 1.14 1998/09/23 22:06:50 bynum # remove space in "SDIR =" in installin002 part # # Revision 1.13 1998/09/23 21:54:58 bynum # add .installsubmitrc file to reduce number of questions the user is asked # # Revision 1.12 1998/09/15 19:15:53 bynum # add test for cs141server # # Revision 1.9 1998/08/31 10:48:28 bynum # fix case stmt error # # Revision 1.8 1998/07/17 20:15:06 bynum # update for all Pentium 002 lab # # Revision 1.7 1998/03/06 19:35:53 bynum # fix quoting for -f option in the submit script on sun4m # # Revision 1.6 1998/01/06 20:22:56 bynum # modify sun4m to sun4* # # Revision 1.5 1997/10/01 15:36:55 bynum # fix i586 install dir error, replace cp -f with rm -f, then cp # # # Revision 1.4 1997/09/26 09:43:13 bynum # fix 002 dialog # # Revision 1.3 1997/09/26 07:20:18 bynum # fix chmod dialog in install_on_002 # # Revision 1.2 1997/09/26 07:15:09 bynum # fix syntax error in if of install_in_002 # # Revision 1.1 1997/09/26 07:00:38 bynum # Initial revision #