1 #!/bin/sh -- because we're not sure where perl is yet
4 'true' ||
eval 'exec perl -S $0 $argv:q';
5 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
6 & eval 'exec /usr/local/bin/perl -S $0 $argv:q'
9 # Usage: [perl] configure [file]
11 # This replaces the program paths (e.g. /bin/awk) with an
12 # alternate path that is found in the file "file.paths". It also finds
13 # perl5 and changes the path in all the stand-alone perl programs.
19 # Target shell scripts in question:
20 @shell_scripts
=("conf/paths.pl", "conf/paths.sh");
21 @perl5_src
= < bin
/webstone-gui.pl bin
/WebStone-common.pl bin
/killbench.pl bin
/view-results.pl bin
/WebStone-manage.pl bin
/move-filelist.pl bin
/write-testbed.pl bin
/WebStone-run.pl bin
/move-runs.pl bin
/WebStone-setup.pl bin
/runbench.pl
>;
22 @perl_src
= < bin
/wscollect.pl bin
/mine-logs.pl
>;
23 @benchmark_dir_src
= < webstone bin
/killbench bin
/runbench
>;
25 # all the HTML browsers we know about, IN ORDER OF PREFERENCE!
26 @all_www
= ("netscape", "Mosaic", "xmosaic", "lynx");
29 # Potential directories to find commands; first, find the user's path...
32 # additional dirs; *COLON* separated!
33 $other_dirs="/usr/ccs/bin:/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/ucb/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/bin/X11:/usr/X11/bin:/usr/openwin/bin";
36 # split into a more reasonable format. Personal aliases come last.
37 @all_dirs
= split(/:/, $other_dirs .
":" .
$PATH);
39 print
"checking to make sure all the target(s) are here...\n";
41 for (@shell_scripts
) {
42 die
"ERROR -- $_ not found!\n" unless
-f $_;
46 print
"Trying to find perl...\n";
47 for $dir (@all_dirs
) {
48 # first, find where it might be
50 while (<$dir/perl
*>) {
52 $perl_version=`($_ -v 2> /dev/null) |
53 awk '/This is perl/ { print $NF }'`;
66 print
"\nPerl is in $PERL\n";
67 for (@perl_src
) { $perl_src .
= "$_ "; }
68 print
"\nchanging the source in: $perl_src\n";
69 system
"$PERL -pi -e \"s@^#!.*/perl.*@#!$PERL@;\" $perl_src";
71 # make sure things are executable...
72 system
("chmod u+x $perl_src");
76 printf "\nSome WebStone functions require Perl\n" unless
$PERL;
82 print
"Trying to find perl5...\n";
83 for $dir (@all_dirs
) {
84 # first, find where it might be; oftentimes you'll see perl,
85 # perl4, perl5, etc. in the same dir
87 while (<$dir/perl5
* $dir/perl
*>) {
89 $perl_version=`($_ -v 2> /dev/null) |
90 awk '/This is perl, version 5/ { print $NF }'`;
103 print
"\nPerl5 is in $PERL5\n";
105 for (@perl5_src
) { $perl5_src .
= "$_ "; }
106 print
"\nchanging the source in: $perl5_src\n";
107 system
"$PERL5 -pi -e \"s@^#!.*/perl.*@#!$PERL5@;\" $perl5_src";
108 system
("chmod u+x $perl5_src");
112 printf "\nThe WebStone GUI requires Perl5\n" unless
$PERL5;
116 # find the most preferred www viewer first.
117 for $www (@all_www
) {
118 for $dir (@all_dirs
) {
120 if (-x "$dir/$www") {
128 print
"\nHTML/WWW Browser is $MOSAIC\n";
130 $upper{"MOSAIC"} = $MOSAIC;
132 else { print
"Cannot find a web browser! WebStone cannot be run except in CLI"; }
134 print
"\nOk, now doing substitutions on the shell scripts...\n";
135 for $shell (@shell_scripts
) {
136 print
"Changing paths in $shell...\n";
137 die
"Can't open $shell\n" unless open
(SCRIPT
, $shell);
138 rename
($shell, $shell .
'.old');
139 die
"Can't open $shell\n" unless open
(OUT
, ">$shell");
142 # Open up the script, search for lines beginning with
143 # stuff like "TEST", "AWK", etc. If the file ends in "pl",
144 # assume it's a perl script and change it accordingly
147 for $command (keys
%upper
) {
148 if(/^\$?
$command=/) {
150 if ($shell !~
/.pl$
/) {
151 print OUT
"$command=$upper{$command}\n"; }
154 print OUT
"\$" .
"$command=\"$upper{$command}\";\n";
159 print OUT
$_ if !$found;
167 for (@benchmark_dir_src
) { $benchmark_dir_src .
= "$_ "; }
168 print
"\nchanging the source in: $benchmark_dir_src\n";
169 $BENCHMARK_DIR=`pwd`;
171 $BENCHMARK_DIR =~ s
/\
//\\\
//g
;
172 system
"$PERL -pi -e \"s/<BENCHMARK_DIR>/$BENCHMARK_DIR/\" $benchmark_dir_src";