ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scramcli
Revision: 1.35
Committed: Wed Feb 20 12:22:01 2002 UTC (23 years, 3 months ago) by sashby
Branch: MAIN
Changes since 1.34: +10 -3 lines
Log Message:
minor changes

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