ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scramcli
Revision: 1.36
Committed: Wed Feb 20 12:45:53 2002 UTC (23 years, 3 months ago) by sashby
Branch: MAIN
CVS Tags: V0_19_3
Changes since 1.35: +2 -0 lines
Log Message:
Ready for release V0_19_3.

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