ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scramcli
Revision: 1.2
Committed: Mon Jun 11 13:07:39 2001 UTC (23 years, 11 months ago) by sashby
Branch: MAIN
CVS Tags: V0_18_5
Changes since 1.1: +1913 -834 lines
Log Message:
Ensured that modifications are built onto V18_2

File Contents

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