ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scramcli
Revision: 1.33
Committed: Tue Feb 19 17:43:27 2002 UTC (23 years, 3 months ago) by sashby
Branch: MAIN
Changes since 1.32: +13 -4 lines
Log Message:
Fixed couple of things: FNAL site probs with setup, general auto setup probs.

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