ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scramcli
Revision: 1.32
Committed: Fri Jan 25 16:48:16 2002 UTC (23 years, 3 months ago) by sashby
Branch: MAIN
Changes since 1.31: +89 -2 lines
Log Message:
Added tool tag tagname command.

File Contents

# User Rev Content
1 sashby 1.26 # -*-perl-*-
2 sashby 1.2 #===========================================================================#
3 sashby 1.15 # NAME: scramcli #
4 sashby 1.2 #===========================================================================#
5     # DATE: Mon May 28 11:36:18 2001 #
6     # AUTHOR: C. Williams #
7     # MAINTAINER: Shaun Ashby #
8     #===========================================================================#
9     # DESCRIPTION: The main scram program (NOTE: this is wrapped at runtime to #
10     # set up the path to the SCRAM Perl modules). #
11 sashby 1.15 # #
12 sashby 1.2 #===========================================================================#
13    
14 sashby 1.29 # Verbose mode:
15 sashby 1.31 &local_verbose("MAIN");
16 sashby 1.29
17 sashby 1.19 $main::bold = "";
18     $main::normal = "";
19     $main::line = "-"x80;
20     $main::lookupobject = "";
21 sashby 1.15
22 sashby 1.10 # Test whether the output from SCRAM is being redirected, or
23     # not (prevents escape signals from being printed to STDOUT if
24 sashby 1.25 # STDOUT is redirected to a file or piped):
25 sashby 1.11 if ( -t STDIN && -t STDOUT )
26     {
27     $bold = "\033[1m";
28     $normal = "\033[0m";
29     }
30    
31 sashby 1.2 # Allowed main and dev commands:
32 sashby 1.13 @allowed_commands=qw(project build install version list remove arch setup runtime setroot db tool url);
33 sashby 1.18 @dev_cmds=qw(devtest devint align);
34 hpw 1.1
35 sashby 1.2 # Check for prerequisites:
36     prerequisitecheck();
37     # Check for version consistency:
38 hpw 1.1 versioncheck();
39    
40 sashby 1.28
41 sashby 1.2 # Parse arguments (look for "-verbose" or "-arch" then shift):
42     while ( $ARGV[0] =~ /^-/)
43     {
44     if ( $ARGV[0] eq "-verbose" )
45     {
46 sashby 1.27 # Enable verbose for main as well, by default when -verbose mode selected:
47     $ENV{'SCRAMDEBUG'} = 1;
48 sashby 1.2 shift @ARGV;
49     # If no argument (i.e. class to activate "verbose" for) do nothing:
50     if (defined ($ARGV[0]))
51     {
52 sashby 1.21 print "Verbose mode for $ARGV[0] switched ".$bold."ON".$normal."\n" ;
53 sashby 1.2 scrambasics()->classverbose($ARGV[0],1);
54     }
55     }
56     elsif ( $ARGV[0] eq "-arch" )
57     {
58     shift @ARGV;
59     $ENV{SCRAM_ARCH}=$ARGV[0];
60     scrambasics()->arch($ARGV[0]);
61     }
62     else
63     {
64 sashby 1.31 ReportError("Unknown option $ARGV[0]");
65 sashby 1.2 }
66     shift @ARGV;
67     }
68    
69     # Shift args to get input command:
70 hpw 1.1 $inputcmd=shift;
71     $found='false';
72     $rv=0;
73     $self={};
74    
75 sashby 1.2 # Check that input command is defined, and then
76     # run a scram subroutine for the command or show
77     # some help:
78     if ( $inputcmd ne "" )
79     {
80     foreach $command ( (@allowed_commands,@dev_cmds) )
81     {
82     if ( $command =~ /^$inputcmd/i)
83     {
84     # Deal with a help request
85     do
86     {
87     helpheader($command);
88     &{"help_".$command};
89     exit;
90     } if $ARGV[0] =~ /help/i;
91     $rv=&$command;
92     $found='true';
93     last;
94     }
95     }
96     }
97    
98     if ( ! ( $found =~ /true/ ) )
99     {
100     helpheader('Recognised Commands');
101     foreach $command ( @allowed_commands )
102     {
103     print " $bold scram ".$command.$normal."\n";
104     }
105     print "\n";
106     print "Help on individual commands available through\n\n";
107     print "$bold scram".$normal." command$bold help $normal\n\n";
108    
109     print "\nOptions:\n";
110     print "--------\n";
111     print $bold."-verbose ".$normal."Class : Activate the verbose ".
112     "function on the specified class";
113     print "\n\n";
114     print $bold."-arch ".$normal."architecture : Set the architecture id ".
115     "to that specified";
116     print "\n\n";
117     }
118 hpw 1.1
119 sashby 1.2 # Exit with exit status of subroutine
120     # that was executed in line 80:
121 hpw 1.1 exit $rv;
122 sashby 1.2
123    
124    
125    
126 sashby 1.21
127    
128    
129    
130    
131 sashby 1.2 ######################################################################################
132     ## Subroutine definitions ##
133     ######################################################################################
134    
135 sashby 1.31 sub ReportError
136 sashby 1.2 {
137     ###############################################################
138 sashby 1.31 # ReportError(string) #
139 sashby 1.2 ###############################################################
140     # modified : Mon May 28 11:26:47 2001 / SFA #
141     # params : Error messsage string #
142     # : #
143     # : #
144     # : #
145 sashby 1.31 # function : Exit with an error string. Print string to #
146     # : STDERR if using pipes. #
147 sashby 1.2 # : #
148     ###############################################################
149     my $string=shift;
150 sashby 1.31 &local_verbose("ReportError");
151 sashby 1.28
152 sashby 1.31 if ( -t STDERR ) # Make sure that errors go to STDERR
153     { # when using pipes
154     print STDERR "\n","SCRAM error: ".$string."\n";
155     }
156     else
157     {
158     print "\n","SCRAM error: ".$string."\n";
159     }
160 sashby 1.5 exit (1);
161 sashby 1.2 }
162    
163     sub prerequisitecheck
164     {
165     ###############################################################
166     # prerequisitecheck() #
167     ###############################################################
168     # modified : Mon May 28 11:26:52 2001 / SFA #
169     # params : None. #
170     # : #
171     # : #
172     # : #
173     # function : Check for prerequisite programs. #
174 sashby 1.9 # : Don't bother checking for shell: too much hassle.#
175     # : (and doesn't work outside of HEPiX scheme) #
176 sashby 1.2 ###############################################################
177     my $reqdmake="gmake";
178 sashby 1.31 &local_verbose("prerequisitecheck");
179    
180 sashby 1.9 # We must have gmake. Use "which" to get the gmake command
181     # ("whereis" doesn't work on SunOS):
182 sashby 1.2 chomp(($makeprog)=(`which gmake` =~ /.*\/(\w+)/));
183     # Now test that requirements are satisfied:
184 sashby 1.9 if ( $makeprog eq "$reqdmake" )
185 sashby 1.2 {
186     return (0);
187     }
188     else
189     {
190     print "It appears that you do not have all prerequisite","\n";
191     print "programs. To run SCRAM, you must have:","\n";
192     print "\n";
193     print " - GNU make (gmake)","\n";
194     print "\n";
195 sashby 1.9 print "Please make sure that this program is present.","\n\n";
196 sashby 1.2 exit (1);
197     }
198     }
199    
200     sub versioncheck
201     {
202     ###############################################################
203     # versioncheck(version) #
204     ###############################################################
205     # modified : Mon May 28 11:27:06 2001 / SFA #
206     # params : version (optional) #
207     # : #
208     # : #
209     # : #
210     # function : Check for scram version info. #
211     # : #
212     # : #
213     ###############################################################
214     my $version;
215 sashby 1.31 &local_verbose("versioncheck");
216 sashby 1.2
217     if ( @_ )
218     {
219     $version=shift;
220     }
221     else
222     {
223     # -- get version from local area
224     if ( ! localtop_find() )
225     {
226 hpw 1.1 LoadEnvFile();
227     my $versionfile=$ENV{LOCALTOP}."/$ENV{projconfigdir}/scram_version";
228 sashby 1.2 if ( -f $versionfile )
229     {
230     open (VERSION, "<".$versionfile);
231 hpw 1.1 $version=<VERSION>;
232     chomp $version;
233 sashby 1.2 }
234 hpw 1.1 }
235 sashby 1.2 }
236     if ( defined $version )
237     {
238     scrambasics()->spawnversion($version,@ARGV);
239     }
240     }
241    
242    
243     sub _processcmds
244     {
245     ###############################################################
246     # _processcmds(handlercoderef,refarrayofallowedcommands, #
247     # refarrayofactualcommands, #
248     # arrayofsubroutinestringstocall) #
249     # #
250     ###############################################################
251     # modified : Mon May 28 11:27:12 2001 / SFA #
252     # params : #
253     # : #
254     # : #
255     # : #
256     # function : #
257     # : #
258     # : #
259     ###############################################################
260 sashby 1.31 &local_verbose("_processcmds");
261 sashby 1.28
262 sashby 1.2 my $optionhandler=shift;
263     my $allowed_commands=shift;
264     my $cmds=shift;
265     my @subs=@_;
266     my $found=0;
267    
268     # make a string from the subcommand levels
269     my $substring="";
270     if ( @subs )
271     {
272     $substring= join '_', @subs;
273     $substring=$substring."_";
274     }
275    
276     # Process options
277     if (defined ${$cmds}[0])
278     {
279     while ( ${$cmds}[0] =~ /^-/)
280     {
281     &{$optionhandler}( ${$cmds}[0],$cmds);
282     }
283 hpw 1.1
284 sashby 1.2 my $inputcmd=shift @{$cmds};
285     if ( $inputcmd ne "" )
286     {
287     foreach $command ( @{$allowed_commands} )
288     {
289     if ( $command =~ /^$inputcmd/i)
290     {
291     # Deal with a help request
292     if ( ( defined $$cmds[0]) && $$cmds[0] =~ /help/i )
293     {
294     &helpheader($command,@subs);
295     &{"help_".$substring.$command}; exit;
296     }
297     else
298     {
299     &{$substring.$command}(@{$cmds});
300     $found=1;
301     last;
302     }
303     }
304     }
305     }
306     }
307    
308     if ( ! $found )
309     {
310     &{$substring."error"}(@subs);
311 hpw 1.1 }
312 sashby 1.2 return $found;
313     }
314    
315    
316     sub help_build
317     {
318     ###############################################################
319     # help_build() #
320     ###############################################################
321     # modified : Mon May 28 11:27:23 2001 / SFA #
322     # params : #
323     # : #
324     # : #
325     # : #
326     # function : Show help for the scram build command #
327     # : #
328     # : #
329     ###############################################################
330 sashby 1.31 &local_verbose("help_build");
331 sashby 1.28
332 sashby 1.2 print <<ENDTEXT;
333     Information for building binaries and libraries.
334    
335     Subcommands:
336    
337     scram (b)uild lib/bin
338    
339     Command is run from the src directory.
340    
341     ENDTEXT
342 sashby 1.6 # Also run "build" dir because this will run "gmake help":
343     &build();
344 sashby 1.2 }
345    
346    
347     sub align
348     {
349     ###############################################################
350     # align() #
351     ###############################################################
352     # modified : Mon May 28 11:27:27 2001 / SFA #
353     # params : #
354     # : #
355     # : #
356     # : #
357     # function : #
358     # : #
359     # : #
360     ###############################################################
361 sashby 1.31 &local_verbose("align");
362 sashby 1.2 _localarea()->align();
363     }
364    
365     sub build
366     {
367     ###############################################################
368     # build() #
369     ###############################################################
370     # modified : Mon May 28 11:27:34 2001 / SFA #
371     # params : #
372     # : #
373     # : #
374     # : #
375     # function : Compile project. #
376     # : #
377     # : #
378     ###############################################################
379 sashby 1.31 &local_verbose("build");
380 sashby 1.2
381     # is this a based or free release?
382     FullEnvInit();
383     use BuildSystem::BuildSetup;
384     $ENV{MAKETARGETS}=join ' ',@ARGV;
385    
386     # -- set the runtime environment
387     my $toolrt=scrambasics()->toolruntime(_localarea());
388     $toolrt->sethash(\%Env);
389    
390     # -- set up the builder
391     my $bs=BuildSystem::BuildSetup->new(toolbox());
392     $rv=$bs->BuildSetup($ENV{THISDIR},@ARGV);
393     $rv;
394     }
395    
396     sub project
397     {
398     ###############################################################
399     # project() #
400     ###############################################################
401     # modified : Mon May 28 11:27:38 2001 / SFA #
402     # params : #
403     # : #
404     # : #
405     # : #
406     # function : Set up a project area. #
407     # : #
408     # : #
409     ###############################################################
410 sashby 1.31 &local_verbose("project");
411 sashby 1.28
412 sashby 1.2 my @args=@ARGV;
413    
414     my $devareaname="";
415     use Cwd;
416     my $installarea=cwd();
417 sashby 1.19
418 sashby 1.2 # process options
419     while ( $args[0] =~ "^-" )
420     {
421     if ( $args[0] =~ /-n/ )
422     {
423     shift @args;
424     $devareaname=shift @args;
425     }
426     elsif ( $args[0] =~ /-d/ ) #installation area directory
427     {
428     shift @args;
429     $installarea=$args[0];
430     if ( ! -d $installarea )
431     {
432 sashby 1.31 ReportError("$installarea does not exist");
433 sashby 1.2 }
434     shift @args;
435     }
436     else
437     {
438 sashby 1.31 ReportError("Unknown option $args[0] to project command");
439 sashby 1.2 }
440     }
441    
442     # -- check what arguments have been passed
443     if ( $#args <0 || $#args>1 )
444     {
445 sashby 1.31 ReportError("\"scram project help\" for usage info.");
446 sashby 1.2 }
447     my $area; #somewhere to store the area object when we have it
448    
449     if ( ( $#args == 0 ) && ($args[0] =~ /:/) )
450     {
451     # -- must be a url to bootstrap from
452 sashby 1.7 print "Bootstrapping using ",$args[0],"\n";
453 sashby 1.2 $area=scrambasics()->project($args[0], $installarea,
454     $devareaname);
455 sashby 1.7 print "Setting up tools in project area","\n";
456 sashby 1.19
457 sashby 1.21 # Need to set the sitename for the setup process:
458     if (defined ($area))
459     {
460     # We have an area so we can invoke method:
461     $ENV{'SITENAME'} = $area->sitename();
462 sashby 1.22 $ENV{'PROJECTDIR'} = $area->location();
463 sashby 1.21 }
464    
465 sashby 1.19 # Initialize the lookup table:
466     use Scram::AutoToolSetup;
467     $lookupobject = Scram::AutoToolSetup->new();
468    
469     # Now run the full setup for the area:
470 sashby 1.2 scrambasics()->setuptoolsinarea($area);
471     }
472     elsif ( $#args >0 )
473     {
474     # -- get the release area
475     print "Getting release area....","\n";
476     my $relarea=scrambasics()->scramprojectdb()->getarea(@args);
477     if ( ! defined $relarea )
478     {
479 sashby 1.31 ReportError("Unknown project @args");
480 sashby 1.2 }
481    
482     # -- we need to spawn the correct scram version to handle it:
483     unshift @ARGV, "project";
484     print "Checking SCRAM version....","\n";
485     versioncheck($relarea->scramversion());
486 hpw 1.1
487 sashby 1.2 # -- need to create a satellite area:
488     print "Creating satellite area....","\n";
489     $area=scrambasics()->satellite(@args,$installarea, $devareaname);
490     }
491     else
492     {
493 sashby 1.31 ReportError("\"scram project help\" for usage info.");
494 sashby 1.2 }
495     #
496     # Now create the directories specified in the interface
497     # There should be some better mechanism - TODO
498     #
499     print "Creating directories....","\n";
500     chdir $area->location();
501     foreach $key ( keys %ENV )
502     {
503     if ( $key =~ /^INT/ )
504     {
505     AddDir::adddir($ENV{$key});
506     }
507     }
508 sashby 1.5 # Final message
509 sashby 1.2 print "\n\nInstallation procedure complete.\n";
510     print "Installation Located at:\n\n\t\t".$bold.$area->location().$normal."\n\n";
511     }
512    
513    
514     sub scrambasics
515     {
516     ###############################################################
517     # scrambasics() #
518     ###############################################################
519     # modified : Mon May 28 11:27:44 2001 / SFA #
520     # params : #
521     # : #
522     # : #
523     # : #
524     # function : #
525     # : #
526     # : #
527     ###############################################################
528 sashby 1.31 &local_verbose("scrambasics");
529 sashby 1.28
530 sashby 1.2 require Scram::ScramFunctions;
531     if ( ! defined $scramobj )
532     {
533     environmentinit();
534     $scramobj=Scram::ScramFunctions->new();
535     $scramobj->arch($ENV{SCRAM_ARCH});
536     }
537     return $scramobj;
538     }
539    
540     sub url
541     {
542     ###############################################################
543     # url() #
544     ###############################################################
545     # modified : Mon May 28 11:27:48 2001 / SFA #
546     # params : #
547     # : #
548     # : #
549     # : #
550     # function : #
551     # : #
552     # : #
553     ###############################################################
554 sashby 1.31 &local_verbose("url");
555 sashby 1.28
556 sashby 1.2 @_=@ARGV;
557     localtop();
558     environmentinit();
559     my @allowed_cmds=qw(get);
560     _processcmds("_tooloptions", \@allowed_cmds, \@_, ("url"));
561     }
562    
563     sub url_get
564     {
565     ###############################################################
566     # url_get() #
567     ###############################################################
568     # modified : Mon May 28 11:27:52 2001 / SFA #
569     # params : #
570     # : #
571     # : #
572     # : #
573     # function : #
574     # : #
575     # : #
576     ###############################################################
577 sashby 1.31 &local_verbose("url_get");
578 sashby 1.28
579 sashby 1.2 my $url=shift;
580     my $area=_localarea();
581    
582     ($uurl,$file)=scrambasics()->webget($area,$url);
583 hpw 1.1 print "$file\n";
584 sashby 1.2 }
585 hpw 1.1
586 sashby 1.2 sub help_url
587     {
588     ###############################################################
589     # help_url() #
590     ###############################################################
591     # modified : Mon May 28 11:28:06 2001 / SFA #
592     # params : #
593     # : #
594     # : #
595     # : #
596     # function : Show help for the scram url command. #
597     # : #
598     # : #
599     ###############################################################
600 sashby 1.31 &local_verbose("help_url");
601 sashby 1.28
602 sashby 1.2 print <<ENDTEXT;
603 hpw 1.1 URL information.
604 sashby 1.2
605     Subcommands:
606    
607 hpw 1.1 scram url get
608    
609     ENDTEXT
610 sashby 1.2 }
611 hpw 1.1
612 sashby 1.2 sub help_url_get
613     {
614     ###############################################################
615     # help_url_get() #
616     ###############################################################
617     # modified : Mon May 28 11:28:11 2001 / SFA #
618     # params : #
619     # : #
620     # : #
621     # : #
622     # function : Show help for the scram url get command. #
623     # : #
624     # : #
625     ###############################################################
626 sashby 1.31 &local_verbose("help_url_get");
627 sashby 1.28
628 sashby 1.2 print <<ENDTEXT;
629 hpw 1.1 Description:
630     Return the location of the local copy of the specified url
631     Usage :
632     scram url get url
633    
634     ENDTEXT
635 sashby 1.2 }
636 hpw 1.1
637     # ------------ tool command --------------------------------------------
638 sashby 1.2 sub tool
639     {
640     ###############################################################
641     # tool() #
642     ###############################################################
643     # modified : Mon May 28 11:28:16 2001 / SFA #
644     # params : #
645     # : #
646     # : #
647     # : #
648     # function : #
649     # : #
650     # : #
651     ###############################################################
652 sashby 1.31 &local_verbose("tool");
653 sashby 1.28
654 sashby 1.2 @_=@ARGV;
655     localtop();
656     environmentinit();
657 sashby 1.32 my @allowed_cmds=qw(info list default setup tag);
658 sashby 1.2 _processcmds("_tooloptions", \@allowed_cmds, \@_, ("tool"));
659     }
660    
661     sub tool_error
662     {
663     ###############################################################
664     # tool_error(error_string) #
665     ###############################################################
666     # modified : Mon May 28 11:28:20 2001 / SFA #
667     # params : Error message string. #
668     # : #
669     # : #
670     # : #
671     # function : Show an error message for tool command. #
672     # : #
673     # : #
674     ###############################################################
675 sashby 1.31 &local_verbose("tool_error");
676 sashby 1.28
677 sashby 1.31 ReportError("Unknown tool subcommand : @_");
678 sashby 1.2 }
679    
680     sub tool_default
681     {
682     ###############################################################
683     # tool_default() #
684     ###############################################################
685     # modified : Mon May 28 11:28:24 2001 / SFA #
686     # params : #
687     # : #
688     # : #
689     # : #
690     # function : #
691     # : #
692     # : #
693     ###############################################################
694 sashby 1.31 &local_verbose("tool_default");
695 sashby 1.28
696 sashby 1.2 if ( $#_ != 1 )
697     {
698 sashby 1.31 ReportError("\"scram tool default help\" for usage information");
699 sashby 1.2 }
700     my $tool=shift;
701     my $version=shift;
702     print "Setting default version of $tool to $version\n";
703     # -- adjust the toolbox
704     toolbox()->setdefault($tool,$version);
705     }
706    
707     sub tool_list
708     {
709     ###############################################################
710     # tool_list() #
711     ###############################################################
712     # modified : Mon May 28 11:28:27 2001 / SFA #
713     # params : #
714     # : #
715     # : #
716     # : #
717     # function : List the tools defined in toolbox. #
718     # : #
719     # : #
720     ###############################################################
721 sashby 1.31 &local_verbose("tool_list");
722 sashby 1.28
723 sashby 1.2 my $area=_localarea();
724     my $locationstring="Tool list for location ".$area->location();
725     my $length=length($locationstring);
726    
727 sashby 1.14 print "\n",$locationstring,"\n";
728 sashby 1.2 print "+"x $length;
729     print "\n";
730     print "\n";
731    
732     foreach $t ( toolbox()->tools() )
733     {
734     my $vers=join / /, toolbox()->versions($t);
735 sashby 1.14 print " ".$t." ".$vers." (default=".toolbox()->defaultversion($t).")\n";
736 sashby 1.2 }
737 sashby 1.14 print "\n";
738 sashby 1.2 }
739    
740     sub tool_info
741     {
742     ###############################################################
743     # tool_info() #
744     ###############################################################
745     # modified : Mon May 28 11:28:30 2001 / SFA #
746     # params : #
747     # : #
748     # : #
749     # : #
750     # function : Show info for available tools. #
751     # : #
752     # : #
753     ###############################################################
754 sashby 1.31 &local_verbose("tool_info");
755 sashby 1.28
756 sashby 1.2 my $project=shift;
757     my $area=_localarea();
758     my $locationstring="Tool info as configured in location ".$area->location();
759     my $length=length($locationstring);
760    
761     print $locationstring,"\n";
762     print "+"x $length;
763     print "\n";
764     print "\n";
765    
766     my @tools=toolbox()->gettool($project,@_);
767 sashby 1.32
768 sashby 1.2 foreach $t ( @tools )
769     {
770     if ( defined $t )
771     {
772     print "Name : ".$t->name();
773     print "\n";
774     print "Version : ".$t->version();
775     print "\n";
776     print "Docfile : ".$t->url();
777     print "\n";
778     print "+"x20;
779     print "\n";
780     @features=$t->features();
781     foreach $ft ( @features )
782     {
783     @vals=$t->getfeature($ft);
784     foreach $v ( @vals )
785     {
786 hpw 1.1 print $ft. "=$v\n";
787 sashby 1.2 }
788     }
789     }
790 sashby 1.8 else
791     {
792     print "Tool $t is not defined for this project area.","\n";
793     }
794 sashby 1.2 }
795     }
796 hpw 1.1
797 sashby 1.32 sub tool_tag
798     {
799     ###############################################################
800     # tool_tag() #
801     ###############################################################
802     # modified : Mon May 28 11:28:30 2001 / SFA #
803     # params : #
804     # : #
805     # : #
806     # : #
807     # function : Show value of tool tag <tagname>. #
808     # : #
809     # : #
810     ###############################################################
811     &local_verbose("tool_tag");
812    
813     my $toolname=shift;
814     chomp (my $tagname=shift);
815     my $area=_localarea();
816     my @tools=toolbox()->gettool($toolname,@_);
817    
818     foreach $t ( @tools )
819     {
820     # If we have a hash for this tool, proceed:
821     if ( defined $t )
822     {
823     # Get the features:
824     @features=$t->features();
825     # If a tag name was supplied then try to get the value,
826     # otherwise just display all tag+value pairs defined:
827     if ( defined $tagname )
828     {
829     foreach $feature (@features)
830     {
831     print $t->getfeature($feature),"\n" if ($feature eq $tagname);
832     }
833     }
834     else
835     {
836     # Loop over features:
837     foreach $ft ( @features )
838     {
839     @vals=$t->getfeature($ft);
840     foreach $v ( @vals )
841     {
842     print $ft,"\n";
843     }
844     }
845     }
846     }
847     else
848     {
849     return;
850     }
851     }
852     }
853    
854 sashby 1.2 sub tool_setup
855     {
856     ###############################################################
857     # tool_setup() #
858     ###############################################################
859     # modified : Mon May 28 11:28:35 2001 / SFA #
860     # params : #
861     # : #
862     # : #
863     # : #
864     # function : #
865     # : #
866     # : #
867     ###############################################################
868 sashby 1.31 &local_verbose("tool_setup");
869 sashby 1.28
870 sashby 1.2 print "Please use scram setup command\n";
871     }
872    
873     sub _tooloptions
874     {
875     ###############################################################
876     # _tooloptions(error_string) #
877     ###############################################################
878     # modified : Mon May 28 11:28:38 2001 / SFA #
879     # params : Error message string. #
880     # : #
881     # : #
882     # : #
883     # function : #
884     # : #
885     # : #
886     ###############################################################
887 sashby 1.31 &local_verbose("_tooloptions");
888 sashby 1.28
889 sashby 1.31 ReportError("No Options defined for tool subcommand");
890 sashby 1.2 }
891    
892     sub help_tool
893     {
894     ###############################################################
895     # help_tool() #
896     ###############################################################
897     # modified : Mon May 28 11:28:41 2001 / SFA #
898     # params : #
899     # : #
900     # : #
901     # : #
902     # function : Show help for tool command. #
903     # : #
904     # : #
905     ###############################################################
906 sashby 1.31 &local_verbose("help_tool");
907 sashby 1.28
908 sashby 1.2 print <<ENDTEXT;
909 hpw 1.1 Manage the tools in the scram area that define the areas environment.
910 sashby 1.2 tool subcommands:
911    
912 hpw 1.1 list
913     info tool_name
914     default tool_name tool_version
915 sashby 1.32 tag tool_name tag_name
916    
917 hpw 1.1 ENDTEXT
918 sashby 1.2 }
919 hpw 1.1
920 sashby 1.2 sub help_tool_info
921     {
922     ###############################################################
923     # help_tool_info() #
924     ###############################################################
925     # modified : Mon May 28 11:28:45 2001 / SFA #
926     # params : #
927     # : #
928     # : #
929     # : #
930     # function : Show help for tool info command. #
931     # : #
932     # : #
933     ###############################################################
934 sashby 1.31 &local_verbose("help_tool_info");
935 sashby 1.28
936 sashby 1.2 print <<ENDTEXT;
937 hpw 1.1 Description:
938     Print out information on the specified tool in the current area
939     configuration.
940     Usage :
941     scram tool info tool_name [tool_version]
942    
943     ENDTEXT
944 sashby 1.2 }
945 hpw 1.1
946 sashby 1.2 sub help_tool_list
947     {
948     ###############################################################
949     # help_tool_list() #
950     ###############################################################
951     # modified : Mon May 28 11:28:50 2001 / SFA #
952     # params : #
953     # : #
954     # : #
955     # : #
956     # function : Show help for tool info command. #
957     # : #
958     # : #
959     ###############################################################
960 sashby 1.31 &local_verbose("help_tool_list");
961 sashby 1.28
962 sashby 1.2 print <<ENDTEXT;
963 hpw 1.1 Description:
964     List of currently configured tools available in ther current scram
965     area
966     Usage :
967     scram tool list
968    
969     ENDTEXT
970 sashby 1.2 }
971 hpw 1.1
972 sashby 1.2 sub help_tool_default
973     {
974     ###############################################################
975     # help_tool_default() #
976     ###############################################################
977     # modified : Mon May 28 11:28:54 2001 / SFA #
978     # params : #
979     # : #
980     # : #
981     # : #
982     # function : #
983     # : #
984     # : #
985     ###############################################################
986 sashby 1.31 &local_verbose("help_tool_default");
987 sashby 1.28
988 sashby 1.2 print <<ENDTEXT;
989 hpw 1.1 Description:
990     Change the default version of a tool to be used in the area
991     Usage :
992     scram tool default tool_name tool_version
993    
994     ENDTEXT
995 sashby 1.2 }
996 sashby 1.32
997    
998     sub help_tool_tag
999     {
1000     ###############################################################
1001     # help_tool_tag() #
1002     ###############################################################
1003     # modified : Mon May 28 11:28:45 2001 / SFA #
1004     # params : #
1005     # : #
1006     # : #
1007     # : #
1008     # function : Show help for tool tag command. #
1009     # : #
1010     # : #
1011     ###############################################################
1012     &local_verbose("help_tool_tag");
1013    
1014     print <<ENDTEXT;
1015     Description:
1016     Print out the value of a variable (tag) for the specified tool in the
1017     current area configuration.
1018     Usage :
1019     scram tool tag tool_name [tag name]
1020    
1021     ENDTEXT
1022     }
1023    
1024 hpw 1.1
1025     # ----------------------------------------------------------------------
1026 sashby 1.2 sub _requirements
1027     {
1028     ###############################################################
1029     # _requirements() #
1030     ###############################################################
1031     # modified : Mon May 28 11:28:59 2001 / SFA #
1032     # params : #
1033     # : #
1034     # : #
1035     # : #
1036     # function : #
1037     # : #
1038     # : #
1039     ###############################################################
1040 sashby 1.31 &local_verbose("_requirements");
1041 sashby 1.28
1042 sashby 1.2 if ( ! defined $reqsobj )
1043     {
1044     localtop();
1045     my $area=_localarea();
1046     scrambasics()->arearequirements($area);
1047     }
1048     return $reqsobj;
1049     }
1050    
1051     sub _allprojectinitsearcher
1052     {
1053     ###############################################################
1054     # _allprojectinitsearcher() #
1055     ###############################################################
1056     # modified : Mon May 28 11:29:03 2001 / SFA #
1057     # params : #
1058     # : #
1059     # : #
1060     # : #
1061     # function : #
1062     # : #
1063     # : #
1064     ###############################################################
1065 sashby 1.31 &local_verbose("_allprojectinitsearcher");
1066 sashby 1.28
1067 sashby 1.2 my $search=_projsearcher();
1068     foreach $proj ( _scramprojdb()->list() )
1069     {
1070     $search->addproject($$proj[0],$$proj[1]);
1071     }
1072     }
1073    
1074     sub _projsearcher
1075     {
1076     ###############################################################
1077     # _projsearcher() #
1078     ###############################################################
1079     # modified : Mon May 28 11:29:05 2001 / SFA #
1080     # params : #
1081     # : #
1082     # : #
1083     # : #
1084     # function : #
1085     # : #
1086     # : #
1087     ###############################################################
1088 sashby 1.31 &local_verbose("_projsearcher");
1089 sashby 1.28
1090 sashby 1.2 if ( ! defined $self->{projsearcher} )
1091     {
1092     require Scram::ProjectSearcher;
1093     $self->{projsearcher}=Scram::ProjectSearcher->new(_scramprojdb());
1094     }
1095     return $self->{projsearcher};
1096     }
1097    
1098     sub _scramprojdb
1099     {
1100     ###############################################################
1101     # _scramprodb() #
1102     ###############################################################
1103     # modified : Mon May 28 11:29:10 2001 / SFA #
1104     # params : #
1105     # : #
1106     # : #
1107     # : #
1108     # function : #
1109     # : #
1110     # : #
1111     ###############################################################
1112 sashby 1.31 &local_verbose("_scramprojdb");
1113 sashby 1.28
1114 sashby 1.2 return scrambasics()->scramprojectdb();
1115     }
1116    
1117     sub runtime
1118     {
1119     ###############################################################
1120     # runtime() #
1121     ###############################################################
1122     # modified : Mon May 28 11:29:13 2001 / SFA #
1123     # params : shell type (-sh for Bourne, -csh for C/tcsh) #
1124     # : #
1125     # : #
1126     # : #
1127     # function : Get/set runtime environment. #
1128     # : #
1129     # : #
1130     ###############################################################
1131 sashby 1.31 &local_verbose("runtime");
1132 sashby 1.28
1133 sashby 1.2 my $shell;
1134     require Runtime;
1135    
1136     # process options
1137     while ( $ARGV[0] =~ "^-" )
1138     {
1139     if ( $ARGV[0] =~ /-sh/ )
1140     {
1141     shift @ARGV;
1142     $shell="sh";
1143     next;
1144     }
1145     if ( $ARGV[0] =~ /-csh/ ) #installation area directory
1146     {
1147     shift @ARGV;
1148     $shell="csh";
1149     next;
1150     }
1151 sashby 1.31 ReportError("Unknown Option $ARGV[0]\n");
1152 sashby 1.2 }
1153 sashby 1.12
1154 sashby 1.2 FullEnvInit();
1155 sashby 1.12
1156 sashby 1.2 if ( @ARGV )
1157     {
1158     my $runtime=Runtime->new();
1159     my $arg=shift @ARGV;
1160    
1161     my $info=0;
1162     if ( $arg eq "info" )
1163     {
1164     $arg=shift @ARGV;
1165     $info=1;
1166     }
1167    
1168     # --- determine filename
1169     my $filename;
1170     if ( -f $arg ) # Is it a file?
1171     {
1172     $filename=$arg;
1173     }
1174     else
1175     {
1176     # -- lets see if its a BuildFile location
1177     $filename=_testfile($ENV{LOCALTOP}."/src/".$arg,
1178     $ENV{RELEASETOP}."/src/".$arg,
1179     $ENV{LOCALTOP}."/src/".$arg."/BuildFile",
1180     $ENV{RELEASETOP}."/src/".$arg."/BuildFile");
1181     if ( $filename eq "" )
1182     {
1183 sashby 1.31 ReportError("Unable to find a file (or BuildFile) relating to ".
1184     $arg."\n");
1185 sashby 1.2 }
1186     }
1187     $runtime->file($filename);
1188     if ( ! $info )
1189     {
1190     $runtime->printenv($shell);
1191     }
1192     else
1193     {
1194     if ( @ARGV ) #do we have a specific variable request?
1195     {
1196     _printvardoc($runtime,shift @ARGV);
1197     }
1198     else
1199     {
1200     foreach $var ( $runtime->list() )
1201     {
1202     _printvardoc($runtime,$var);
1203     }
1204     }
1205     }
1206     undef $runtime;
1207     }
1208     else
1209     {
1210     FullEnvInit();
1211     # -- We have to clean up from the last runtime cmd - use env history
1212     foreach $variable ( %ENV )
1213     {
1214     if ( $variable =~ /^SCRAMRT_(.*)/ ) #SCRAMRT are history retaining
1215     {
1216 hpw 1.1 my $var=$1;
1217 sashby 1.2 $ENV{$var} =~ s/\Q$ENV{$variable}\E//g;
1218     $ENV{$var} =~ s/^:*//; # Deal with any Path variables
1219 hpw 1.1 delete $ENV{$variable};
1220 sashby 1.2 }
1221     }
1222 hpw 1.1
1223 sashby 1.2 # -- get the tool runtime environments
1224     my $toolrt=scrambasics()->toolruntime(_localarea());
1225     $toolrt->sethash(\%EnvRuntime);
1226    
1227     # -- create new SCRAMRT history vars.
1228     foreach $variable ( keys %EnvRuntime )
1229     {
1230     printoutenv($shell,"SCRAMRT_$variable",$EnvRuntime{$variable});
1231     }
1232 hpw 1.1
1233 sashby 1.2 # TODO -- this stuff should dissappear with compiler description docs
1234     # Now adapt as necessary - include base environment as well
1235     if ( exists $ENV{LD_LIBRARY_PATH} )
1236     {
1237     addpath("LD_LIBRARY_PATH","$ENV{LD_LIBRARY_PATH}");
1238     }
1239     if ( exists $ENV{MANPATH} )
1240     {
1241     addpath("MANPATH","$ENV{MANPATH}");
1242     }
1243     addpath("PATH","$ENV{PATH}");
1244    
1245     # -- Print out as reqd
1246     # TODO -- we can use the runtime class method once we have removed
1247     # this stuff above
1248     foreach $variable ( keys %EnvRuntime )
1249     {
1250     printoutenv($shell,$variable,$EnvRuntime{$variable});
1251     }
1252 sashby 1.12
1253 sashby 1.30 # Export a copy of LOCALTOP, renamed as a new variable:
1254     printoutenv($shell,"LOCALRT",$ENV{LOCALTOP});
1255 sashby 1.2 }
1256     }
1257 hpw 1.1
1258     # Support rt for runtime
1259    
1260 sashby 1.2 sub _testfile
1261     {
1262     ###############################################################
1263     # _testfile() #
1264     ###############################################################
1265     # modified : Mon May 28 11:29:21 2001 / SFA #
1266     # params : #
1267     # : #
1268     # : #
1269     # : #
1270     # function : #
1271     # : #
1272     # : #
1273     ###############################################################
1274 sashby 1.31 &local_verbose("_testfile");
1275 sashby 1.28
1276 sashby 1.2 my @files=@_;
1277     my $filename="";
1278    
1279     foreach $file ( @files )
1280     {
1281     if ( -f $file )
1282     {
1283     $filename=$file;
1284     last;
1285     }
1286     }
1287     return $filename;
1288     }
1289    
1290     sub _printvardoc
1291     {
1292     ###############################################################
1293     # _printvardoc() #
1294     ###############################################################
1295     # modified : Mon May 28 11:29:25 2001 / SFA #
1296     # params : #
1297     # : #
1298     # : #
1299     # : #
1300     # function : #
1301     # : #
1302     # : #
1303     ###############################################################
1304 sashby 1.31 &local_verbose("_printvardoc");
1305 sashby 1.28
1306 sashby 1.2 my $runtime=shift;
1307     my $var=shift;
1308    
1309     print $var." :\n";
1310     print $runtime->doc($var);
1311     print "\n";
1312     }
1313    
1314     sub printoutenv
1315     {
1316     ###############################################################
1317     # printoutenv() #
1318     ###############################################################
1319     # modified : Mon May 28 11:29:28 2001 / SFA #
1320     # params : #
1321     # : #
1322     # : #
1323     # : #
1324     # function : #
1325     # : #
1326     # : #
1327     ###############################################################
1328 sashby 1.31 &local_verbose("printoutenv");
1329 sashby 1.28
1330 sashby 1.2 my $shell=shift;
1331     my $variable=shift;
1332     my $value=shift;
1333    
1334     if ( $shell eq "csh" )
1335     {
1336     print "setenv $variable \"$value\";\n";
1337     }
1338     elsif ( $shell eq "sh" )
1339     {
1340     print "$variable=\"$value\";\n";
1341     print "export $variable;\n";
1342     }
1343     }
1344    
1345     sub addpath
1346     {
1347     ###############################################################
1348     # addpath() #
1349     ###############################################################
1350     # modified : Mon May 28 11:29:32 2001 / SFA #
1351     # params : #
1352     # : #
1353     # : #
1354     # : #
1355     # function : #
1356     # : #
1357     # : #
1358     ###############################################################
1359 sashby 1.31 &local_verbose("addpath");
1360 sashby 1.28
1361 sashby 1.2 my $name=shift;
1362     my $val=shift;
1363    
1364     my $n;
1365     my @env;
1366     @env=split /:/, $EnvRuntime{$name};
1367     foreach $n ( (split /:/, $val ) )
1368     {
1369     if ( ! grep /^\Q$n\E$/, @env )
1370     {
1371     addvar($name,$n,":");
1372     }
1373     }
1374     }
1375 hpw 1.1
1376 sashby 1.2 sub addvar
1377     {
1378     ###############################################################
1379     # addvar() #
1380     ###############################################################
1381     # modified : Mon May 28 11:29:35 2001 / SFA #
1382     # params : #
1383     # : #
1384     # : #
1385     # : #
1386     # function : #
1387     # : #
1388     # : #
1389     ###############################################################
1390 sashby 1.31 &local_verbose("addvar");
1391 sashby 1.28
1392 sashby 1.2 my $name=shift;
1393     my $val=shift;
1394     my $sep=shift;
1395    
1396     if ( $val ne "" )
1397     {
1398     if ( defined $EnvRuntime{$name} )
1399     {
1400 hpw 1.1 $EnvRuntime{$name}=$EnvRuntime{$name}.$sep.$val;
1401 sashby 1.2 }
1402     else
1403     {
1404 hpw 1.1 $EnvRuntime{$name}=$val;
1405 sashby 1.2 }
1406     }
1407     }
1408    
1409     sub FullEnvInit
1410     {
1411     ###############################################################
1412     # FullEnvInit() #
1413     ###############################################################
1414     # modified : Mon May 28 11:29:38 2001 / SFA #
1415     # params : #
1416     # : #
1417     # : #
1418     # : #
1419     # function : #
1420     # : #
1421     # : #
1422     ###############################################################
1423 sashby 1.31 &local_verbose("FullEnvInit");
1424 sashby 1.28
1425 sashby 1.2 environmentinit();
1426     localtop();
1427     LoadEnvFile();
1428     }
1429    
1430     sub environmentinit
1431     {
1432     ###############################################################
1433     # environmentinit() #
1434     ###############################################################
1435     # modified : Mon May 28 11:29:41 2001 / SFA #
1436     # params : #
1437     # : #
1438     # : #
1439     # : #
1440     # function : Set the environment variables needed #
1441     # : by scram (arch, home etc.) #
1442     # : #
1443     ###############################################################
1444 sashby 1.31 &local_verbose("environmentinit");
1445 sashby 1.28
1446 sashby 1.2 use Utilities::setarchitecture;
1447 sashby 1.23
1448 sashby 1.2 my $name;
1449     my $value;
1450    
1451     $ENV{LatestBuildFile}=""; # stop recursive behaviour in make
1452 sashby 1.23
1453 sashby 1.2 if ( ! defined $ENV{SCRAM_ARCH} )
1454     {
1455     setarchitecture::setarch();
1456     }
1457     $ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}";
1458     $ENV{INTsrc}="src";
1459     $ENV{INTlog}="logs";
1460     $ENV{INTlib}="lib/".$ENV{SCRAM_ARCH};
1461    
1462     ($ENV{SCRAM_BASEDIR}=$ENV{SCRAM_HOME}) =~ s/(.*)\/.*/$1/;
1463     if ( ! ( exists $ENV{SCRAM_CONFIG} ) )
1464     {
1465     $ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration";
1466     }
1467     $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
1468     if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) )
1469     {
1470     if ( -d "$ENV{SCRAM_BASEDIR}/scramdb/" )
1471     {
1472     $ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_BASEDIR}/scramdb/project.lookup";
1473     }
1474     else
1475     {
1476     $ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup";
1477     }
1478     }
1479     $ENV{SCRAM_AVAILDIRS}="";
1480     $ENV{SCRAM_AVAILFILES}="";
1481     }
1482    
1483     sub _localarea
1484     {
1485     ###############################################################
1486     # _localarea() #
1487     ###############################################################
1488     # modified : Mon May 28 11:29:47 2001 / SFA #
1489     # params : #
1490     # : #
1491     # : #
1492     # : #
1493     # function : #
1494     # : #
1495     # : #
1496     ###############################################################
1497 sashby 1.31 &local_verbose("_localarea");
1498 sashby 1.28
1499 sashby 1.2 if ( ! defined $self->{localarea} )
1500     {
1501     require Configuration::ConfigArea;
1502     $self->{localarea}=Configuration::ConfigArea->new();
1503     if ( ! defined $ENV{LOCALTOP} )
1504     {
1505     if ( $self->{localarea}->bootstrapfromlocation() )
1506     {
1507 hpw 1.1 # Were not in a local area
1508     undef $self->{localarea};
1509 sashby 1.2 }
1510     else
1511     {
1512     $self->{localarea}->archname(scrambasics()->arch());
1513     }
1514     }
1515     else
1516     {
1517     $self->{localarea}->bootstrapfromlocation($ENV{LOCALTOP});
1518     }
1519     }
1520     return $self->{localarea};
1521     }
1522    
1523     sub localtop_find
1524     {
1525     ###############################################################
1526     # localtop_find() #
1527     ###############################################################
1528     # modified : Mon May 28 11:29:50 2001 / SFA #
1529     # params : #
1530     # : #
1531     # : #
1532     # : #
1533     # function : #
1534     # : #
1535     # : #
1536     ###############################################################
1537 sashby 1.31 &local_verbose("localtop_find");
1538 sashby 1.28
1539 sashby 1.2 my $rv=1;
1540     if ( defined _localarea())
1541     {
1542     $rv=0;
1543     $ENV{LOCALTOP}=_localarea()->location();
1544     }
1545     return $rv;
1546     }
1547    
1548     sub localtop
1549     {
1550     ###############################################################
1551     # localtop() #
1552     ###############################################################
1553     # modified : Mon May 28 11:29:54 2001 / SFA #
1554     # params : #
1555     # : #
1556     # : #
1557     # : #
1558 sashby 1.5 # function : Find the top directory of local release area. #
1559 sashby 1.2 # : #
1560     # : #
1561     ###############################################################
1562 sashby 1.31 &local_verbose("localtop");
1563 sashby 1.28
1564 sashby 1.2 localtop_find();
1565 sashby 1.30
1566     # localtop_find() should set the variable LOCALTOP if we're
1567     # in a project area. This behaviour should take precedence.
1568     if ( defined ($ENV{LOCALTOP}))
1569     {
1570     # We're in a project area. Do whatever is necessary:
1571     ($ENV{THISDIR}=cwd) =~ s/^\Q$ENV{LOCALTOP}\L//;
1572     }
1573     else
1574 sashby 1.2 {
1575 sashby 1.30 # Not in a project area. See if we've used "setroot" to set
1576     # LOCALRT. If so, use that as LOCALTOP, otherwise say goodbye:
1577     if ( defined ($ENV{'LOCALRT'}))
1578     {
1579     $ENV{LOCALTOP} = $ENV{'LOCALRT'};
1580     ($ENV{THISDIR}=cwd) =~ s/^\Q$ENV{LOCALTOP}\L//;
1581     }
1582     else
1583     {
1584 sashby 1.31 ReportError("Unable to locate the top of local release. Exitting.\n");
1585 sashby 1.30 }
1586 sashby 1.2 }
1587     $ENV{THISDIR} =~ s/^\///;
1588     }
1589    
1590     sub LoadEnvFile
1591     {
1592     ###############################################################
1593     # LoadEnvFile() #
1594     ###############################################################
1595     # modified : Mon May 28 11:29:58 2001 / SFA #
1596     # params : #
1597     # : #
1598     # : #
1599     # : #
1600     # function : #
1601     # : #
1602     # : #
1603     ###############################################################
1604 sashby 1.31 &local_verbose("LoadEnvFile");
1605 sashby 1.28
1606 sashby 1.2 _localarea()->copyenv(\%ENV);
1607     }
1608    
1609     sub env
1610     {
1611     ###############################################################
1612     # env() #
1613     ###############################################################
1614     # modified : Mon May 28 11:30:00 2001 / SFA #
1615     # params : #
1616     # : #
1617     # : #
1618     # : #
1619     # function : #
1620     # : #
1621     # : #
1622     ###############################################################
1623 sashby 1.31 &local_verbose("env");
1624 sashby 1.28
1625 hpw 1.1 print "Sorry - Not yet\n";
1626 sashby 1.2 }
1627 hpw 1.1
1628 sashby 1.2 sub devint
1629     {
1630     ###############################################################
1631     # devint() #
1632     ###############################################################
1633     # modified : Mon May 28 11:30:03 2001 / SFA #
1634     # params : #
1635     # : #
1636     # : #
1637     # : #
1638     # function : #
1639     # : #
1640     # : #
1641     ###############################################################
1642 sashby 1.31 &local_verbose("devint");
1643 sashby 1.28
1644 sashby 1.2 my $class=shift @ARGV;
1645     scrambasics()->scramobjectinterface($class);
1646     }
1647    
1648     sub devtest
1649     {
1650     ###############################################################
1651     # devtest() #
1652     ###############################################################
1653     # modified : Mon May 28 11:30:06 2001 / SFA #
1654     # params : #
1655     # : #
1656     # : #
1657     # : #
1658     # function : #
1659     # : #
1660     # : #
1661     ###############################################################
1662 sashby 1.31 &local_verbose("devtest");
1663 sashby 1.28
1664 sashby 1.2 require Utilities::TestClass;
1665     my $class=shift @ARGV;
1666    
1667     my $tester;
1668     my $path;
1669    
1670     if ( $class =~ /::/ )
1671     {
1672     ($path=$class) =~ s/(.*)::.*/$1/;
1673     }
1674     $tester=Utilities::TestClass->new($class,
1675     "$ENV{SCRAM_HOME}/src/$path/test/testdata");
1676     $tester->dotest(@_);
1677     }
1678 hpw 1.1
1679     #
1680     # Create a lookup tag in the site database
1681     #
1682 sashby 1.2 sub install
1683     {
1684     ###############################################################
1685     # install() #
1686     ###############################################################
1687     # modified : Mon May 28 11:30:09 2001 / SFA #
1688     # params : #
1689     # : #
1690     # : #
1691     # : #
1692     # function : Install a project. Updates project.lookup #
1693     # : files found in /scramdb. #
1694     # : #
1695     ###############################################################
1696 sashby 1.31 &local_verbose("install");
1697 sashby 1.28
1698 sashby 1.2 localtop();
1699    
1700     scrambasics()->addareatoDB(_localarea(),@ARGV);
1701     _localarea()->align();
1702     }
1703    
1704     sub help_install()
1705     {
1706     ###############################################################
1707     # help_install() #
1708     ###############################################################
1709     # modified : Mon May 28 11:30:12 2001 / SFA #
1710     # params : #
1711     # : #
1712     # : #
1713     # : #
1714 sashby 1.28 # function : Show help for the install command. #
1715 sashby 1.2 # : #
1716     # : #
1717     ###############################################################
1718 sashby 1.31 &local_verbose("help_install");
1719 sashby 1.28
1720 sashby 1.2 print <<ENDTEXT;
1721 hpw 1.1 Associates a label with the current release in the SCRAM database.
1722     This allows other users to refer to a centrally installed project by
1723     this label rather than a remote url reference.
1724    
1725     Usage:
1726    
1727     $bold scram install $normal [project_tag [version_tag]]
1728    
1729     porject_tag : override default label (the project name of the current release)
1730     version_tag : the version tag of the current release. If version is not
1731     specified the base release version will be taken by default.
1732    
1733     ENDTEXT
1734 sashby 1.2 }
1735 hpw 1.1
1736 sashby 1.2 sub helpheader ($label)
1737     {
1738     ###############################################################
1739     # helpheader(label) #
1740     ###############################################################
1741     # modified : Mon May 28 11:30:17 2001 / SFA #
1742     # params : label for the header. #
1743     # : #
1744     # : #
1745     # : #
1746     # function : Prints a header for the help command of #
1747     # : scram command "label". #
1748     # : #
1749     ###############################################################
1750 sashby 1.31 &local_verbose("helpheader");
1751 sashby 1.28
1752 sashby 1.2 my $label=shift;
1753    
1754     print <<ENDTEXT;
1755    
1756 hpw 1.1 *************************************************************************
1757 sashby 1.2 SCRAM HELP --------- $label
1758 hpw 1.1 *************************************************************************
1759 sashby 1.2
1760 hpw 1.1 ENDTEXT
1761 sashby 1.2 }
1762 hpw 1.1
1763 sashby 1.2 sub version
1764     {
1765     ###############################################################
1766     # version() #
1767     ###############################################################
1768     # modified : Mon May 28 11:30:24 2001 / SFA #
1769     # params : #
1770     # : #
1771     # : #
1772     # : #
1773     # function : Get the version of scram being used. #
1774     # : #
1775     # : #
1776     ###############################################################
1777 sashby 1.31 &local_verbose("version");
1778 sashby 1.28
1779 sashby 1.2 my $version=shift @ARGV;
1780     my $thisversion;
1781     my $scram_top;
1782     my $cvsobject;
1783    
1784     ($thisversion=$ENV{SCRAM_HOME}) =~ s/(.*)\///;
1785     $scram_top=$1;
1786     if ( $version eq "" )
1787     {
1788     print "$thisversion";
1789     # deal with links
1790     $version=readlink $ENV{SCRAM_HOME};
1791     if ( defined $version)
1792     {
1793     print " ---> $version";
1794     }
1795     print "\n";
1796     }
1797     else
1798     {
1799     if ( -d $scram_top."/".$version )
1800     {
1801     print "Version $version exists\n";
1802     }
1803     else
1804     {
1805     print "Version $version not available locally\n";
1806     print "Attempting download from the SCRAM repository\n";
1807     # set up and configure the cvs module for SCRAM
1808     require Utilities::CVSmodule;
1809     $cvsobject=Utilities::CVSmodule->new();
1810     $cvsobject->set_base(
1811     "cmscvs.cern.ch:/cvs_server/repositories/SCRAM");
1812     $cvsobject->set_auth("pserver");
1813     $cvsobject->set_user("anonymous");
1814     $cvsobject->set_passkey("AA_:yZZ3e");
1815     # Now check it out in the right place
1816     chdir $scram_top or die "Unable to change to $scram_top $!\n";
1817     $cvsobject->invokecvs( ( split / /,
1818     "co -d $version -r $version SCRAM" ));
1819 hpw 1.1
1820 sashby 1.2 # Get rid of cvs object now weve finished
1821     $cvsobject=undef;
1822     print "\n";
1823     }
1824     }
1825     0;
1826     }
1827    
1828     sub list
1829     {
1830     ###############################################################
1831     # list() #
1832     ###############################################################
1833     # modified : Mon May 28 11:30:28 2001 / SFA #
1834     # params : #
1835     # : #
1836     # : #
1837     # : #
1838     # function : List available projects. #
1839     # : #
1840     # : #
1841     ###############################################################
1842 sashby 1.31 &local_verbose("list");
1843 sashby 1.2 &environmentinit;
1844    
1845     my $linebold = "$bold"."$line"."$normal";
1846     my $pjname = "Project Name";
1847     my $pjversion = "Project Version";
1848     my $pjlocation = "Project Location";
1849 sashby 1.5 my $headstring = sprintf("| %-12s | %-24s | %-33s |",$pjname,$pjversion,$pjlocation);
1850 sashby 1.2
1851     if ( ! -f $ENV{SCRAM_LOOKUPDB} )
1852     {
1853 sashby 1.31 ReportError
1854     ("\nNo installation database available - perhaps no projects\nhave been installed locally?\n");
1855 sashby 1.2 }
1856 sashby 1.4 print "\n","Listing installed projects....","\n\n";
1857 sashby 1.2 print $linebold,"\n";
1858     print $headstring."\n";
1859     print $linebold,"\n\n";
1860     listDB(@ARGV);
1861     print "\n";
1862     }
1863    
1864    
1865     sub remove
1866     {
1867     ###############################################################
1868     # remove(project) #
1869     ###############################################################
1870     # modified : Mon May 28 11:30:31 2001 / SFA #
1871 sashby 1.5 # params : project name, project version #
1872 sashby 1.2 # : #
1873     # : #
1874     # : #
1875     # function : Remove the named project from the project.lookup #
1876     # : file (scram database). #
1877     # : #
1878 sashby 1.28 ###############################################################
1879 sashby 1.31 &local_verbose("remove");
1880 sashby 1.28
1881 sashby 1.5 my $projectname=shift @ARGV;
1882     my $projectversion=shift @ARGV;
1883    
1884     # Check there were sufficient args:
1885     if ($projectname eq "" || $projectversion eq "")
1886     {
1887 sashby 1.31 ReportError("\"scram remove help\" for usage info.");
1888 sashby 1.5 }
1889     else
1890     {
1891     scrambasics()->removeareafromDB($projectname,$projectversion);
1892     }
1893     0;
1894 sashby 1.2 }
1895    
1896     sub db
1897     {
1898     ###############################################################
1899     # db() #
1900     ###############################################################
1901     # modified : Mon May 28 11:30:35 2001 / SFA #
1902 sashby 1.5 # params : "link", "unlink" or "show(links )" #
1903 sashby 1.2 # : #
1904     # : #
1905     # : #
1906     # function : Show project info stored in scramdb. Link/unlink #
1907     # : project database files, or show linked databases.#
1908     # : #
1909     ###############################################################
1910 sashby 1.31 &local_verbose("db");
1911 sashby 1.28
1912 sashby 1.2 my $subcmd=shift @ARGV;
1913    
1914     # Make sure we have an argument, or tell the user:
1915     if ( ! defined($subcmd))
1916     {
1917     &help_db;
1918     print "\n";
1919     exit (1);
1920     }
1921    
1922     &environmentinit;
1923    
1924     # First, check for a database area:
1925     if ( ! -f $ENV{SCRAM_LOOKUPDB} )
1926     {
1927 sashby 1.31 ReportError
1928     ("\nNo installation database available - perhaps no projects\nhave been installed locally?\n");
1929 sashby 1.2 }
1930     print "\n","Current scram database: ";
1931     print $bold."$ENV{SCRAM_LOOKUPDB}".$normal."\n\n";
1932    
1933     switch :
1934     {
1935     if ( $subcmd eq 'link' )
1936     {
1937     print "\n","Linked @ARGV to current scram database.","\n\n";
1938     scrambasics()->scramprojectdb()->link(@ARGV);
1939     last switch;
1940     }
1941     if ( $subcmd eq 'unlink' )
1942     {
1943     print "\n","Unlinked @ARGV from current scram database.","\n\n";
1944     scrambasics()->scramprojectdb()->unlink(@ARGV);
1945     last switch;
1946     }
1947     if ( $subcmd eq 'showlinks'
1948     || $subcmd eq 'showlink'
1949     || $subcmd eq 'show')
1950     {
1951     my @links=scrambasics()->scramprojectdb()->listlinks();
1952     # Are there any links defined?:
1953     if ( defined($links[0]) )
1954     {
1955     print "\n","The following scram databases are linked to the current scram database: ","\n\n";
1956     foreach $link ( @links )
1957     {
1958     print " ".$link."\n";
1959     }
1960     print "\n";
1961     }
1962     else
1963     {
1964     print "There are no databases linked.","\n\n";
1965     }
1966     last switch;
1967     }
1968     } # end switch
1969     }
1970 hpw 1.1
1971 sashby 1.2 sub listDB
1972     {
1973     ###############################################################
1974     # listDB() #
1975     ###############################################################
1976     # modified : Mon May 28 11:30:39 2001 / SFA #
1977     # params : Project name #
1978     # : #
1979 sashby 1.4 # function : List projects. Only those projects that were #
1980     # : installed on the user's current OS will be #
1981     # : displayed (slight anomaly here: some projects #
1982     # : were installed on SunOS_5.6 so won't appear if #
1983     # : the user's current platform is SunOS_5.7...). #
1984 sashby 1.2 # : #
1985     ###############################################################
1986 sashby 1.31 &local_verbose("listDB");
1987 sashby 1.28
1988 sashby 1.2 my $project="";
1989 sashby 1.14 my $projectexists=0;
1990     my @missingareas;
1991    
1992 sashby 1.2 if ( @_ )
1993     {
1994     $project=shift;
1995     }
1996 sashby 1.5
1997 sashby 1.2 my @prs=scrambasics()->scramprojectdb()->listall();
1998 sashby 1.5
1999     # Check to see if there are any projects:
2000     if ( ! defined @prs )
2001     {
2002     print "\t\t>>>> No locally installed projects! <<<<","\n";
2003     return (0);
2004     }
2005 sashby 1.14
2006 sashby 1.5 # Iterate over the project list:
2007 sashby 1.2 foreach $pr ( @prs )
2008     {
2009 sashby 1.14 my $url='NULL';
2010    
2011 sashby 1.2 if ( $project eq "" || $project eq $$pr[0] )
2012     {
2013 sashby 1.14 # Check that the area exists (i.e. check that a configarea object
2014     # is returned before attempting to test its' location:
2015     my $possiblearea=scrambasics()->scramprojectdb()->getarea($$pr[0],$$pr[1]);
2016    
2017     if ( defined ($possiblearea))
2018 sashby 1.4 {
2019 sashby 1.14 $url=$possiblearea->location();
2020     if ($project eq $$pr[0]) {$projectexists=1};
2021     }
2022    
2023     # Check that the path to the project area is readable:
2024     if ( -d $url )
2025     {
2026     # Check that there exists an installation for
2027     # our current architecture. Check for a bin and
2028     # a lib directory:
2029     if ( -d "$url/bin/$ENV{SCRAM_ARCH}" || -d "$url/lib/$ENV{SCRAM_ARCH}" )
2030 sashby 1.12 {
2031     # Stagger the printed lines to allow easier
2032     # copying using the mouse:
2033     printf " %-15s %-25s \n",$$pr[0],$$pr[1];
2034     printf "%45s%-30s\n","--> ",$bold.$url.$normal;
2035     }
2036 sashby 1.14 }
2037     else
2038     {
2039     # We have an area that is unreadable. Push an entry onto the array:
2040     push @missingareas, sprintf ">> Project area MISSING: %-10s %-20s \n",$$pr[0],$$pr[1];
2041 sashby 1.4 }
2042 sashby 1.2 }
2043     }
2044 sashby 1.14
2045     if ( ! $projectexists && $project ne "" )
2046     {
2047     print "\t\t>>>> No locally installed $project projects! <<<<","\n";
2048     return(0);
2049     }
2050 sashby 1.31
2051     print "\n\n","Projects available for platform >> ".$bold."$ENV{SCRAM_ARCH}".$normal." <<\n";
2052     print "\n";
2053    
2054 sashby 1.14 # Print out a list of areas that are missing:
2055     if ( @missingareas )
2056     {
2057 sashby 1.31 ReportError(@missingareas);
2058 sashby 1.14 }
2059    
2060 sashby 1.31 # Otherwise exit nicely:
2061     return(0);
2062 sashby 1.2 }
2063    
2064     sub arch
2065     {
2066     ###############################################################
2067     # arch() #
2068     ###############################################################
2069     # modified : Mon May 28 11:30:41 2001 / SFA #
2070     # params : #
2071     # : #
2072     # : #
2073     # : #
2074     # function : Show the information about current architecture. #
2075     # : #
2076     # : #
2077     ###############################################################
2078 sashby 1.31 &local_verbose("arch");
2079 sashby 1.2 &environmentinit();
2080 sashby 1.10
2081     print "$ENV{SCRAM_ARCH}\n";
2082 sashby 1.2 }
2083 hpw 1.1
2084    
2085     #
2086     # Setup a new tool
2087     #
2088    
2089 sashby 1.2 sub setup
2090     {
2091     ###############################################################
2092     # setup() #
2093     ###############################################################
2094     # modified : Mon May 28 11:30:45 2001 / SFA #
2095     # params : #
2096     # : #
2097     # : #
2098     # : #
2099     # function : Setup tools. #
2100     # : #
2101     # : #
2102     ###############################################################
2103 sashby 1.31 &local_verbose("setup");
2104 sashby 1.2 my $interactive=0;
2105    
2106     # process options
2107     while ( $ARGV[0] =~ "^-" )
2108     {
2109     if ( $ARGV[0] =~ /-i/ )
2110     {
2111     shift @ARGV;
2112     $interactive=1;
2113 sashby 1.20 print "Running interactive setup....","\n";
2114 hpw 1.1 }
2115 sashby 1.2 else
2116     {
2117 sashby 1.31 ReportError("Unknown option $ARGV[0] to setup command");
2118 hpw 1.1 }
2119 sashby 1.2 }
2120 hpw 1.1
2121 sashby 1.2 localtop();
2122    
2123     my $area=_localarea();
2124 sashby 1.21 # We have a local area so we can invoke
2125     # method to get the sitename:
2126 sashby 1.22 $ENV{'SITENAME'} = $area->sitename();
2127     $ENV{'PROJECTDIR'} = $area->location();
2128    
2129 sashby 1.2 my $toolname=shift @ARGV;
2130     my $insert=0;
2131 sashby 1.19
2132 sashby 1.2 toolbox()->interactive($interactive);
2133    
2134 sashby 1.20 # Initialize the lookup table:
2135     use Scram::AutoToolSetup;
2136     $lookupobject = Scram::AutoToolSetup->new();
2137    
2138 sashby 1.2 # If no toolname specified then its a full setup
2139     if ( $toolname eq "" )
2140     {
2141     # -- add architecture specific directories
2142     use Utilities::AddDir;
2143 sashby 1.22 AddDir::adddir($ENV{'PROJECTDIR'}."/lib/$ENV{SCRAM_ARCH}");
2144     AddDir::adddir($ENV{'PROJECTDIR'}."/bin/$ENV{SCRAM_ARCH}");
2145 sashby 1.2 # -- check the releasetop area
2146     # if the releasetop has the files copy them
2147     my $releaseobj=_releasearea();
2148     if ( $releaseobj->copysetup($ENV{LOCALTOP}) )
2149     {
2150     print "Doing Full Setup\n";
2151 sashby 1.20 # Run the full setup for the area:
2152 sashby 1.2 scrambasics()->setuptoolsinarea($area);
2153     }
2154     }
2155     else
2156     {
2157 sashby 1.20 print "Running setup for tool ",$toolname,"...","\n";
2158 sashby 1.2 scrambasics()->setuptoolsinarea($area, $toolname,@ARGV);
2159     }
2160     }
2161 sashby 1.11
2162    
2163 sashby 1.12 sub setroot
2164     {
2165     ###############################################################
2166     # setroot #
2167     ###############################################################
2168     # modified : Wed Nov 7 16:22:25 2001 / SFA #
2169     # params : #
2170     # : #
2171     # : #
2172     # : #
2173     # function : #
2174     # : #
2175     # : #
2176     # : #
2177     ###############################################################
2178 sashby 1.31 &local_verbose("setroot");
2179 sashby 1.12 my $shell = shift @ARGV;
2180    
2181     # Check the shell argument...this must be supplied:
2182     if ($shell =~ "^-" )
2183     {
2184     # Remove the hyphen:
2185     $shell =~ s/-//;
2186 sashby 1.31 if ($shell ne "sh" && $shell ne "csh") {ReportError("No shell given! Exitting.");}
2187 sashby 1.12 }
2188     else
2189     {
2190 sashby 1.31 ReportError("No shell given! Exitting.");
2191 sashby 1.12 }
2192    
2193     my $projectname=shift @ARGV;
2194     my $projectversion=shift @ARGV;
2195    
2196     # Check there were sufficient args:
2197     if ($projectname eq "" || $projectversion eq "")
2198     {
2199 sashby 1.31 ReportError("\"scram setroot help\" for usage info.");
2200 sashby 1.12 }
2201     else
2202     {
2203 sashby 1.13 # And on we go. Let's find a release area for this project/version:
2204 sashby 1.12 my $releasearea = scrambasics()->scramprojectdb()->getarea($projectname,$projectversion);
2205 sashby 1.31 ReportError("No release area!!") if ( ! defined ($releasearea));
2206    
2207 sashby 1.12 # The info we need is stored in a hash and can be accessed using the key ENV.
2208 sashby 1.30 # If LOCALTOP is not defined, look for RELEASETOP:
2209     if ( ${${$releasearea}{'ENV'}}{'LOCALTOP'} eq '' )
2210 sashby 1.12 {
2211 sashby 1.30 if ( ${${$releasearea}{'ENV'}}{'RELEASETOP'} ne '' )
2212 sashby 1.12 {
2213 sashby 1.30 printoutenv($shell,"LOCALRT",${${$releasearea}{'ENV'}}{'RELEASETOP'});
2214 sashby 1.12 }
2215     }
2216 sashby 1.30 else
2217     # LOCALTOP is set so we can use it.
2218     # Set LOCALRT to LOCALTOP and return:
2219 sashby 1.12 {
2220 sashby 1.30 printoutenv($shell,"LOCALRT",${${$releasearea}{'ENV'}}{'LOCALTOP'});
2221 sashby 1.12 }
2222     }
2223 sashby 1.30 0;
2224 sashby 1.12 }
2225    
2226 sashby 1.2
2227     sub _releasearea
2228     {
2229     ###############################################################
2230     # _releasearea() #
2231     ###############################################################
2232     # modified : Mon May 28 11:30:50 2001 / SFA #
2233     # params : #
2234     # : #
2235     # : #
2236     # : #
2237     # function : #
2238     # : #
2239     # : #
2240     ###############################################################
2241 sashby 1.31 &local_verbose("_releasearea");
2242 sashby 1.28
2243 sashby 1.2 if ( !defined $self->{releasearea} )
2244     {
2245     require Configuration::ConfigArea;
2246     $self->{releasearea}=Configuration::ConfigArea->new();
2247     $self->{releasearea}->bootstrapfromlocation($ENV{RELEASETOP});
2248     }
2249     return $self->{releasearea};
2250     }
2251 hpw 1.1
2252     # get a toolbox object for the local area
2253 sashby 1.2 sub toolbox
2254     {
2255     ###############################################################
2256     # toolbox() #
2257     ###############################################################
2258     # modified : Mon May 28 11:30:53 2001 / SFA #
2259     # params : #
2260     # : #
2261     # : #
2262     # : #
2263     # function : #
2264     # : #
2265     # : #
2266     ###############################################################
2267 sashby 1.31 &local_verbose("toolbox");
2268 sashby 1.28
2269 sashby 1.2 if ( ! defined $toolbox )
2270     {
2271     localtop();
2272     my $area=_localarea();
2273     $toolbox=scrambasics()->areatoolbox($area);
2274     }
2275     return $toolbox;
2276     }
2277 sashby 1.27
2278    
2279     sub local_verbose
2280     {
2281     ###############################################################
2282     # local_verbose #
2283     ###############################################################
2284     # modified : Mon Jan 21 12:38:02 2002 / SFA #
2285     # params : Only debug env variable (switch) #
2286     # : #
2287     # : #
2288     # : #
2289     # function : Enable verbose mode for package "main" (i.e. #
2290     # : this wrapped script) #
2291     # : #
2292     # : #
2293     ###############################################################
2294     my $subroutine=shift;
2295 sashby 1.31
2296 sashby 1.28 if ($ENV{'SCRAMDEBUG'})
2297 sashby 1.30 {
2298     print "-------- [verbose mode]: subname >> ",$subroutine,"\n";
2299     }
2300     }
2301 sashby 1.2
2302     sub help_db
2303     {
2304     ###############################################################
2305     # help_db() #
2306     ###############################################################
2307     # modified : Mon May 28 11:30:56 2001 / SFA #
2308     # params : #
2309     # : #
2310     # : #
2311     # : #
2312     # function : Show help for scram db command. #
2313     # : #
2314     # : #
2315     ###############################################################
2316 sashby 1.31 &local_verbose("help_db");
2317 sashby 1.28
2318 sashby 1.2 print <<ENDTEXT;
2319 hpw 1.1 scram database administration command.
2320    
2321     Usage:
2322    
2323     $bold scram db $normal subcommand
2324    
2325 sashby 1.2 Subcommands:
2326    
2327 hpw 1.1 link :
2328     Make available an additional database for
2329     project and list operations
2330    
2331     $bold scram db link $normal /a/directory/path/project.lookup
2332    
2333     unlink :
2334     Remove a database from the link list. Note this does
2335     not remove the database, just the link to it in scram.
2336    
2337     $bold scram db unlink $normal /a/directory/path/project.lookup
2338    
2339     showlinks :
2340     List the databases that are linked in
2341    
2342     ENDTEXT
2343 sashby 1.2 }
2344 hpw 1.1
2345 sashby 1.2 sub help_setup
2346     {
2347     ###############################################################
2348     # help_setup() #
2349     ###############################################################
2350     # modified : Mon May 28 11:31:02 2001 / SFA #
2351     # params : #
2352     # : #
2353     # : #
2354     # : #
2355     # function : Show help for scram setup command. #
2356     # : #
2357     # : #
2358     ###############################################################
2359 sashby 1.31 &local_verbose("help_setup");
2360 sashby 1.28
2361 sashby 1.2 print <<ENDTEXT;
2362 hpw 1.1 Allows installation/re-installation of a new tool/external package into an
2363     already existing development area. If not toolname is specified,
2364     the complete installation process is initiated.
2365    
2366     Usage:
2367    
2368 sashby 1.24 $bold scram setup [-i]$normal [toolname] [[version] [url]]
2369 hpw 1.1
2370     toolname : The name of the tool setup file required.
2371     version : where more than one version exists specify the version
2372     url : when setting up a completely new tool specify the url too
2373    
2374     The -i option turns off the automatic search mechanism allowing for more
2375     user interaction with the setup mechanism
2376     ENDTEXT
2377 sashby 1.2 }
2378 hpw 1.1
2379 sashby 1.2 sub help_list
2380     {
2381     ###############################################################
2382     # help_list() #
2383     ###############################################################
2384     # modified : Mon May 28 11:31:09 2001 / SFA #
2385     # params : #
2386     # : #
2387     # : #
2388     # : #
2389     # function : Show help for scram list command. #
2390     # : #
2391     # : #
2392     ###############################################################
2393 sashby 1.31 &local_verbose("help_list");
2394 sashby 1.28
2395 sashby 1.2 print <<ENDTEXT;
2396 hpw 1.1 List the available projects and versions installed in the local SCRAM database
2397     (see scram install help)
2398    
2399     Usage:
2400    
2401 sashby 1.24 $bold scram list $normal [ProjectName]
2402 hpw 1.1
2403     ENDTEXT
2404 sashby 1.2 }
2405    
2406     sub help_remove
2407     {
2408     ###############################################################
2409     # help_remove() #
2410     ###############################################################
2411     # modified : Mon May 28 11:31:12 2001 / SFA #
2412     # params : #
2413     # : #
2414     # : #
2415     # : #
2416     # function : Show help for scram remove command. #
2417     # : #
2418     # : #
2419     ###############################################################
2420 sashby 1.31 &local_verbose("help_remove");
2421 sashby 1.28
2422 sashby 1.2 print <<ENDTEXT;
2423 sashby 1.5 Remove a project entry from scram database file (\"project.lookup\").
2424 sashby 1.2
2425     Usage:
2426    
2427 sashby 1.24 $bold scram remove $normal [ProjectName] [Version]
2428 sashby 1.2
2429     ENDTEXT
2430     }
2431 hpw 1.1
2432 sashby 1.2 sub help_project
2433     {
2434     ###############################################################
2435     # help_project() #
2436     ###############################################################
2437     # modified : Mon May 28 11:31:16 2001 / SFA #
2438     # params : #
2439     # : #
2440     # : #
2441     # : #
2442     # function : Show help for scram project command. #
2443     # : #
2444     # : #
2445     ###############################################################
2446 sashby 1.31 &local_verbose("help_project");
2447 sashby 1.28
2448 sashby 1.2 print <<ENDTEXT;
2449 hpw 1.1 Setup a new project development area. The new area will appear in the current
2450     working directory.
2451     Usage:
2452    
2453     $bold scram project [-d install_area] [-n directory_name]$normal project_url [project_version]
2454    
2455     Options:
2456    
2457     project_url: The url of a scram bootstrap file.
2458     Currently supported types are:
2459     $bold Database label $normal
2460     Labels can be assigned to bootstrap files for easy
2461     access (See "scram install" command). If you
2462     specify a label you must also specify a project_version.
2463     e.g.
2464    
2465     scram project SCRAM V1_0
2466    
2467     scram project ORCA ORCA_1_1_1
2468    
2469     To see the list of installed projects use the
2470     "scram list" command.
2471    
2472     $bold file: $normal A regular file on an accessable file system
2473     e.g.
2474    
2475     file:~/myprojects/projecta/config/BootStrapFile
2476    
2477     project_version:
2478     Only for use with a database label
2479    
2480     -d install_area:
2481     Indicate a project installation area into which the new
2482     project area should appear. Default is the current working
2483     directory.
2484    
2485     -n directory_name:
2486     Specify the name of the SCRAM development area you wish to
2487     create.
2488    
2489     ENDTEXT
2490 sashby 1.2 }
2491 hpw 1.1
2492 sashby 1.2 sub help_version
2493     {
2494     ###############################################################
2495     # help_version() #
2496     ###############################################################
2497     # modified : Mon May 28 11:31:23 2001 / SFA #
2498     # params : #
2499     # : #
2500     # : #
2501     # : #
2502     # function : Show help for scram version command. #
2503     # : #
2504     # : #
2505     ###############################################################
2506 sashby 1.31 &local_verbose("help_version");
2507 sashby 1.28
2508 sashby 1.2 print <<ENDTEXT;
2509     With no $bold [version] $normal argument given, this command will simply
2510 hpw 1.1 print to standard output the current version number.
2511    
2512     Providing a version argument will cause that version to be downloaded and
2513     installed, if not already locally available.
2514    
2515    
2516     Usage:
2517     $bold scram version [version]$normal
2518    
2519     ENDTEXT
2520 sashby 1.2 }
2521 hpw 1.1
2522 sashby 1.2 sub help_arch
2523     {
2524     ###############################################################
2525     # help_arch() #
2526     ###############################################################
2527     # modified : Mon May 28 11:31:33 2001 / SFA #
2528     # params : #
2529     # : #
2530     # : #
2531     # : #
2532     # function : Show help for scram arch command. #
2533     # : #
2534     # : #
2535     ###############################################################
2536 sashby 1.31 &local_verbose("help_arch");
2537 sashby 1.28
2538 sashby 1.2 print <<ENDTEXT;
2539 hpw 1.1 Print out the architecture flag for the current machine.
2540    
2541     Usage:
2542     $bold scram arch $normal
2543     ENDTEXT
2544 sashby 1.2 }
2545 hpw 1.1
2546 sashby 1.2 sub help_runtime
2547     {
2548     ###############################################################
2549     # help_runtime() #
2550     ###############################################################
2551     # modified : Mon May 28 11:31:37 2001 / SFA #
2552     # params : #
2553     # : #
2554     # : #
2555     # : #
2556     # function : Show help for scram runtime command. #
2557     # : #
2558     # : #
2559     ###############################################################
2560 sashby 1.31 &local_verbose("help_runtime");
2561 sashby 1.28
2562 sashby 1.2 print <<ENDTEXT;
2563 hpw 1.1 Echo to Standard Output the Runtime Environment for the current development area
2564     Output available in csh or sh flavours
2565    
2566     Usage:
2567     1) $bold scram runtime [-csh|-sh] $normal
2568     or
2569     2) $bold scram runtime [-csh|-sh] filename $normal
2570     or
2571     3) $bold scram runtime info filename [variable]$normal
2572    
2573     1) For the general configuration environment
2574     2) For environment described in filename or
2575     areatop/src/directory/BuildFile
2576     3) Display information concerning the environment in the given file
2577     (limited to variable if specified)
2578    
2579     The file for cases 2) and 3) are searched as follows :
2580     a) straightforward filename
2581     b) filename relative to local_area/src
2582     c) filename relative to release_area/src
2583     d) BuildFile relative to local_area/src
2584     e) BuildFile relative to release_area/src
2585    
2586     Examples:
2587    
2588     Setup the current environment to include the project Runtime Environment
2589     in a csh environment
2590    
2591     $bold eval `scram runtime -csh` $normal
2592    
2593     Setup the current environment to include the project Runtime Environment in a
2594     sh environment
2595    
2596     $bold eval `scram runtime -sh` $normal
2597    
2598 sashby 1.12 ENDTEXT
2599     }
2600    
2601    
2602     sub help_setroot
2603     {
2604     ###############################################################
2605     # help_setroot #
2606     ###############################################################
2607     # modified : Wed Nov 7 16:23:32 2001 / SFA #
2608     # params : #
2609     # : #
2610     # : #
2611     # : #
2612     # function : #
2613     # : #
2614     # : #
2615     # : #
2616     ###############################################################
2617 sashby 1.31 &local_verbose("help_setroot");
2618 sashby 1.28
2619 sashby 1.12 print <<ENDTEXT;
2620     Set a SCRAM-aware variable which points to a particular project area. This
2621     permits the setting of the runtime environment outside of the project area.
2622    
2623     Usage:
2624 sashby 1.24 $bold scram setroot [-sh|-csh] [ProjectName] [Version] $normal
2625 sashby 1.12
2626 sashby 1.24 To set the environment:
2627 sashby 1.12
2628 sashby 1.24 $bold eval `scram setroot [-sh|-csh] [ProjectName] [Version]` $normal
2629 hpw 1.1
2630     ENDTEXT
2631 sashby 1.2 }