1 #!/usr/local/bin/wish -f
5 #Revision 1.2 1994/12/06 00:51:21 jkh
6 #Many of John T. Kohl's patches from NetBSD. Thanks, John!
9 # Revision 1.1 1994/01/06 08:16:20 jkh
12 # Revision 1.1 1993/09/04 17:06:09 jkh
13 # Added Rich's wish front-end.
15 # Revision 1.6 1993/09/03 23:37:22 rich
16 # warn user if no tar archives are found in the current directory.
17 # removed the revision string from the lower text frame.
19 # Revision 1.5 1993/09/03 15:48:04 rich
20 # glob for .tar.gz, .tar.z and .tar.Z looking for archives
22 # Revision 1.4 1993/08/28 15:53:59 rich
23 # added version and date info to lower text window.
25 # Revision 1.3 1993/08/28 15:47:12 rich
26 # filtered out ^Ls in pkg_* output.
30 wm title . "Package Installation"
31 #--------------------------------------------------------------
32 # The top level main window, consisting of a bar of buttons and a list
33 # of packages and a description of the current package.
34 #--------------------------------------------------------------
35 frame .menu -relief raised -borderwidth 1
36 frame .frame -borderwidth 4
38 scrollbar .frame.scroll -relief sunken -command ".frame.list yview"
39 listbox .frame.list -yscroll ".frame.scroll set" -relief sunken -setgrid 1
40 pack append .frame .frame.scroll {right filly} \
41 .frame.list {left expand fill}
43 # build the lower window shoing the complete description of a pacage
44 frame .f -borderwidth 4
45 text .f.t -width 80 -height 20 -yscrollcommand ".f.s set" -relief sunken
47 # Initially display instructions in this window. Erase the
48 # instructions and show the package description when the user clicks
51 .f.t insert end "Double click on a package above to see its
52 complete description here."
53 scrollbar .f.s -relief sunken -command ".f.t yview"
54 pack append .f .f.s {right filly} .f.t {left expand fill}
56 bind .frame.list <Double-Button-1> \
57 {foreach i [selection get] {do_description $i}}
58 pack append . .menu {top fill} \
59 .f {bottom expand fill} \
60 .frame {bottom expand fill}
62 #----------------------------------------------------------------
64 #----------------------------------------------------------------
65 button .menu.inst -text "Install" \
66 -command "apply_to_pkg \"pkg_add -v\""
67 button .menu.dein -text "Deinstall" \
68 -command "apply_to_pkg \"pkg_delete -v\""
69 button .menu.installed -text "What is Installed?" \
70 -command "list_pkgs \"pkg_info -I -a |tr ' ' ' '\""
71 button .menu.available -text "What can I install?" \
72 -command "list_pkgs \"pkg_info -I -c [glob -nocomplain *.{tgz,tar.z,tar.gz,tar.Z}] |tr ' ' ' '\""
73 button .menu.cont -text "Contents?" \
74 -command "apply_to_pkg \"pkg_info -d -v\""
75 button .menu.quit -text "Quit" -command "destroy ."
76 button .menu.help -text "Help" -command "do_help"
81 .menu.installed left \
82 .menu.available left \
86 #-------------------------------------------------------
87 # Display the package description.
88 #-------------------------------------------------------
91 set f [eval "open {| sh -c \"$s\" } r"]
92 .frame.list delete 0 end
93 while {[gets $f line] > 0} {
94 .frame.list insert end $line
99 # display the list of available packages
100 set archives [glob -nocomplain *.{tgz,tar.z,tar.gz,tar.Z}]
101 if {$archives == ""} {
102 .frame.list delete 0 end
103 .frame.list insert end "Warning: no compressed tar archives files found."
105 list_pkgs "pkg_info -I -c $archives |tr ' ' ' '"
108 #-------------------------------------------------------
109 # Display the package description.
110 #-------------------------------------------------------
111 proc do_description {s} {
113 regexp {[^ ]*} $s filename
114 set pkgname $filename
116 set cmd "pkg_info -d $filename |tr -d '
\f'"
117 set f [eval "open {| csh -c \"$cmd\" } r"]
119 .f.t insert end [read $f]
122 #-------------------------------------------------------
123 # package install window.
124 #-------------------------------------------------------
125 proc do_help {{w .help}} {
129 wm iconname $w "Help"
130 button $w.ok -text OK -command "destroy $w"
131 message $w.t -relief raised -bd 2 \
132 -text "You can install, deinstall and list info on the available packages. To select a package and see its complete description, press mouse button 1 over the package name. To install a selected package, press the Install button. To exit, press the \"Quit\" button."
133 pack append $w $w.ok {bottom fillx} $w.t {expand fill}
135 #-------------------------------------------------------
136 # Apply a command to a package.
137 #-------------------------------------------------------
138 proc apply_to_pkg {s} {
139 apply_to_pkg_err $s ""
141 #-------------------------------------------------------
142 # Apply a command to a package, with error stream redirection instructions.
143 #-------------------------------------------------------
144 proc apply_to_pkg_err {s errredir} {
147 if {$pkgname == ""} {
148 .f.t insert end "You must double click on a package name first!"
150 apply_to_pkg_int "$s $pkgname" "2>&1"
153 proc apply_to_pkg_int {s errredir} {
155 .f.t insert end "Running: $s\n"
156 set f [eval "open {| sh -c \"$s $errredir\" } r"]
158 .f.t insert end [read $f 64]
161 #-------------------------------------------------------
162 # Invoke an arbitrary command.
163 #-------------------------------------------------------
164 proc do_command {s} {
166 .f.t insert end "Running: $s\n"
167 set f [eval "open {| $s} r"]
169 .f.t insert end [read $f 64]
174 # compile-command: ""
175 # comment-start: "# "
176 # comment-start-skip: "# "