ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scramcli
Revision: 1.7
Committed: Wed Jul 11 15:48:16 2001 UTC (23 years, 10 months ago) by sashby
Branch: MAIN
Changes since 1.6: +2 -0 lines
Log Message:
More changes.

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