ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scram
Revision: 1.35.2.2.2.9
Committed: Thu Nov 2 17:38:46 2000 UTC (24 years, 6 months ago) by williamc
Branch: V0_16branch
CVS Tags: BuildSystemProto1, V0_18_0model, V0_18_0alpha
Changes since 1.35.2.2.2.8: +8 -4 lines
Log Message:
update for new buildsystem

File Contents

# User Rev Content
1 williamc 1.33 #!/usr/local/bin/perl5
2     # ^^^^^^^^^^^^^^^^^^^^
3     # we dont need this anymore to invoke perl but options placed here will be
4     # used.
5 williamc 1.1 #
6     # User Interface
7     #
8 williamc 1.33 # Make sure were running the right version
9 williamc 1.1
10 williamc 1.33 versioncheck();
11 williamc 1.28
12 williamc 1.35.2.2.2.1 # -- handle options
13     while ( $ARGV[0]=~/^-/) {
14     if ( $ARGV[0] eq "-verbose" ) {
15     shift @ARGV;
16     print "verbose mode for $ARGV[0] on\n";
17     scrambasics()->classverbose($ARGV[0],1);
18     }
19 williamc 1.35.2.2.2.8 elsif ( $ARGV[0] eq "-arch" ) {
20     shift @ARGV;
21     $ENV{SCRAM_ARCH}=$ARGV[0];
22     scrambasics()->arch($ARGV[0]);
23     }
24 williamc 1.35.2.2.2.1 else {
25     error("Unknown option $ARGV[0]");
26     }
27     shift @ARGV;
28     }
29    
30 williamc 1.33 $inputcmd=shift;
31     $found='false';
32 williamc 1.28 $bold = "\033[1m";
33 williamc 1.33 $rv=0;
34 williamc 1.28 $normal = "\033[0m";
35 williamc 1.33 $self={};
36 williamc 1.28
37 williamc 1.35.2.2.2.8 @allowed_commands=qw(project build install version list arch setup runtime db tool url);
38 williamc 1.35.2.2.2.2 @dev_cmds=qw(devtest devint align);
39 williamc 1.29
40 williamc 1.35.2.2.2.1
41 williamc 1.33 if ( $inputcmd ne "" ) {
42     foreach $command ( (@allowed_commands,@dev_cmds) ) {
43     if ( $command=~/^$inputcmd/i) {
44     # Deal with a help request
45     do{ helpheader($command);
46     &{"help_".$command}; exit; } if $ARGV[0]=~/help/i;
47     $rv=&$command; $found='true';
48     last;
49     }
50     }
51     }
52 williamc 1.28
53     if ( ! ( $found=~/true/ ) ) {
54     helpheader('Recognised Commands');
55     foreach $command ( @allowed_commands ) {
56     print " $bold scram ".$command.$normal."\n";
57     }
58     print "\n";
59     print "Help on individual commands available through\n\n";
60     print "$bold scram".$normal." command$bold help $normal\n\n";
61 williamc 1.35.2.2.2.1
62     print "\nOptions:\n";
63     print "--------\n";
64     print $bold."-verbose ".$normal."Class : Activate the verbose".
65     "function on the specified class";
66     print "\n\n";
67 williamc 1.35.2.2.2.8 print $bold."-arch ".$normal."architecture : Set the architecture id".
68     "to that specified";
69     print "\n\n";
70 williamc 1.29 }
71 williamc 1.33 exit $rv;
72 williamc 1.29
73 williamc 1.33 sub error {
74     my $string=shift;
75     print "scram : ".$string."\n";
76     exit 1;
77 williamc 1.28 }
78    
79     sub versioncheck {
80     my $version;
81    
82 williamc 1.33 if ( @_ ) {
83     $version=shift;
84     }
85     else {
86 williamc 1.35.2.1 # -- get version from local area
87 williamc 1.33 if ( ! localtop_find() ) {
88     LoadEnvFile();
89     my $versionfile=$ENV{LOCALTOP}."/$ENV{projconfigdir}/scram_version";
90     if ( -f $versionfile ) {
91     open (VERSION, "<".$versionfile);
92 williamc 1.28 $version=<VERSION>;
93     chomp $version;
94 williamc 1.33 }
95     }
96     }
97     if ( defined $version ) {
98 williamc 1.35.2.1 scrambasics()->spawnversion($version,@ARGV);
99 williamc 1.28 }
100     }
101    
102 williamc 1.35.2.2.2.8 #
103     #
104     # _procescmds(handlercoderef,refarrayofallowedcommands,
105     # refarrayofactualcommands,arrayofsubroutinestringstocall)
106     #
107     #
108 williamc 1.33 sub _processcmds {
109     my $optionhandler=shift;
110     my $allowed_commands=shift;
111     my $cmds=shift;
112     my @subs=@_;
113    
114 williamc 1.35.2.2.2.8 my $found=0;
115 williamc 1.33 # make a string from the subcommand levels
116     my $substring="";
117     if ( @subs ) {
118     $substring= join '_', @subs;
119     $substring=$substring."_";
120     }
121    
122     # Process options
123     if ( defined ${$cmds}[0] ) {
124     while ( ${$cmds}[0]=~/^-/) {
125     &{$optionhandler}( ${$cmds}[0],$cmds);
126     }
127    
128     my $inputcmd=shift @{$cmds};
129     if ( $inputcmd ne "" ) {
130     foreach $command ( @{$allowed_commands} ) {
131     if ( $command=~/^$inputcmd/i) {
132     # Deal with a help request
133     if ( ( defined $$cmds[0]) && $$cmds[0]=~/help/i ) {
134     &helpheader($command,@subs);
135     &{"help_".$substring.$command}; exit;
136     }
137     else {
138     #print "calling $substring".$command."(@{$cmds})\n";
139 williamc 1.35.2.2.2.8 &{$substring.$command}(@{$cmds}); $found=1;
140 williamc 1.33 last;
141     }
142     }
143     }
144     }
145     }
146 williamc 1.35.2.2.2.8 if ( ! $found ) {
147     &{$substring."error"}(@subs);
148     }
149 williamc 1.33 return $found;
150 williamc 1.28 }
151    
152 williamc 1.33
153 williamc 1.28 sub help_build {
154     &build;
155     }
156 williamc 1.33
157     sub align {
158     _localarea()->align();
159     }
160    
161 williamc 1.28 sub build {
162     # is this a based or free release?
163     FullEnvInit();
164     $ENV{MAKETARGETS}=join ' ',@ARGV;
165 williamc 1.35.2.2.2.7
166     # -- set the runtime environment
167     my $toolrt=scrambasics()->toolruntime(_localarea());
168     $toolrt->sethash(\%Env);
169    
170     # -- set up the builder
171 williamc 1.35.2.2.2.9 #require BuildSystem::BuildSetup;
172     #my $bs=BuildSystem::BuildSetup->new(toolbox());
173     #$rv=$bs->BuildSetup($ENV{THISDIR},@ARGV);
174     #$rv;
175     require BuildSystem::Build;
176     my $bs=BuildSystem::Build->new(_localarea());
177     $rv=$bs->build($ENV{THISDIR},@ARGV);
178     return $rv->status();
179 williamc 1.28 }
180    
181     sub project {
182 williamc 1.33 my @args=@ARGV;
183    
184     my $devareaname="";
185     use Cwd;
186     my $installarea=cwd();
187    
188 williamc 1.28 # process options
189 williamc 1.33 while ( $args[0]=~"^-" ) {
190     if ( $args[0]=~/-n/ ) {
191     shift @args;
192     $devareaname=shift @args;
193 williamc 1.28 }
194 williamc 1.33 elsif ( $args[0]=~/-d/ ) { #installation area directory
195     shift @args;
196     $installarea=$args[0];
197     if ( ! -d $installarea ) {
198     error("$installarea does not exist");
199     }
200     shift @args;
201 williamc 1.28 }
202     else {
203 williamc 1.33 error("unknown option $args[0] to project command");
204 williamc 1.28 }
205     }
206 williamc 1.29
207 williamc 1.33 # -- check what arguments have been passed
208     if ( $#args <0 || $#args>1 ) {
209     error("\"scram project help\" for usage info");
210     }
211     my $area; #somewhere to store the area object when we have it
212    
213     if ( ( $#args==0 ) && ($args[0]=~/:/) ) {
214     # -- must be a url to bootstrap from
215     $area=scrambasics()->project($args[0], $installarea,
216     $devareaname);
217     scrambasics()->setuptoolsinarea($area);
218     }
219     elsif ( $#args >0 ) {
220 williamc 1.35.2.2.2.5 # -- get the release area
221     my $relarea=scrambasics()->scramprojectdb()->getarea(@args);
222     if ( ! defined $relarea ) {
223     error("Unknown project @args");
224     }
225     # -- we need to spawn the correct scram version to handle it
226     unshift @ARGV, "project";
227     versioncheck($relarea->scramversion());
228    
229 williamc 1.33 # -- need to create a satellite area
230     $area=scrambasics()->satellite(@args,$installarea, $devareaname);
231 williamc 1.29 }
232     else {
233 williamc 1.33 error("\"scram project help\" for usage info");
234     }
235    
236     #
237     # Now create the directories specified in the interface
238     # There should be some better mechanism - TODO
239     #
240     chdir $area->location();
241     foreach $key ( keys %ENV ) {
242     if ( $key=~/^INT/ ) {
243     AddDir::adddir($ENV{$key});
244     }
245     }
246    
247     print "\nInstallation Procedure Complete. \n".
248     "Installation Located at:\n".$area->location()."\n";
249     }
250    
251     sub scrambasics {
252     require Scram::ScramFunctions;
253     if ( ! defined $scramobj ) {
254     environmentinit();
255     $scramobj=Scram::ScramFunctions->new();
256     $scramobj->arch($ENV{SCRAM_ARCH});
257     #$scramobj->verbosity(1);
258     }
259     return $scramobj;
260     }
261    
262 williamc 1.35.2.2.2.8 # ------------ url command --------------------------------------------
263     sub url {
264     @_=@ARGV;
265     localtop();
266     environmentinit();
267     my @allowed_cmds=qw(get);
268     _processcmds("_tooloptions", \@allowed_cmds, \@_, ("url"));
269     }
270    
271     sub url_get {
272     my $url=shift;
273     my $area=_localarea();
274    
275     ($uurl,$file)=scrambasics()->webget($area,$url);
276     print "$file\n";
277     }
278    
279     sub help_url {
280     print <<ENDTEXT;
281     URL information.
282    
283     SubCommands :
284     scram url get
285    
286     ENDTEXT
287     }
288    
289     sub help_url_get {
290     print <<ENDTEXT;
291     Description:
292     Return the location of the local copy of the specified url
293     Usage :
294     scram url get url
295    
296     ENDTEXT
297     }
298    
299 williamc 1.33 # ------------ tool command --------------------------------------------
300     sub tool {
301     @_=@ARGV;
302     localtop();
303     environmentinit();
304 williamc 1.34 my @allowed_cmds=qw(info list default setup);
305 williamc 1.33 _processcmds("_tooloptions", \@allowed_cmds, \@_, ("tool"));
306     }
307    
308 williamc 1.35.2.2.2.8 sub tool_error {
309     error("Unknown tool subcommand : @_");
310     }
311    
312 williamc 1.33 sub tool_default {
313     if ( $#_ != 1 ) {
314     error("\"scram tool default help\" for usage information");
315     }
316     my $tool=shift;
317     my $version=shift;
318     print "Setting default version of $tool to $version\n";
319     # -- adjust the toolbox
320     toolbox()->setdefault($tool,$version);
321    
322     }
323    
324     sub tool_list {
325     my $area=_localarea();
326     print "Tool List for "; #.$area->name()." ".$area->version()."\n";
327     print "Location : ".$area->location()."\n";
328     print "+"x60;
329     print "\n";
330     foreach $t ( toolbox()->tools() ) {
331     my $vers=join / /, toolbox()->versions($t);
332     print $t." ".$vers." (default=".toolbox()->defaultversion($t).")\n";
333     }
334     }
335    
336     sub tool_info {
337     my $project=shift;
338     my $area=_localarea();
339     print "Tool Info as configured in ";
340     #.$area->name()." ".$area->version()."\n";
341     print "Location : ".$area->location()."\n";
342     print "+"x60;
343     print "\n";
344    
345     my @tools=toolbox()->gettool($project,@_);
346     foreach $t ( @tools ) {
347     if ( defined $t ) {
348     print "Name : ".$t->name();
349     print "\n";
350     print "Version : ".$t->version();
351     print "\n";
352     print "Docfile : ".$t->url();
353     print "\n";
354     print "+"x20;
355     print "\n";
356     @features=$t->features();
357     foreach $ft ( @features ) {
358     @vals=$t->getfeature($ft);
359     foreach $v ( @vals ) {
360     print $ft. "=$v\n";
361     }
362     }
363     }
364     }
365 williamc 1.34 }
366    
367     sub tool_setup {
368     print "Please use scram setup command\n";
369 williamc 1.33 }
370    
371     sub _tooloptions {
372     error("No Options defined for tool subcommand");
373     }
374    
375     sub help_tool {
376     print <<ENDTEXT;
377     Manage the tools in the scram area that define the areas environment.
378     tool subcommands :
379     list
380     info tool_name
381     default tool_name tool_version
382    
383     ENDTEXT
384     }
385    
386     sub help_tool_info {
387     print <<ENDTEXT;
388     Description:
389     Print out information on the specified tool in the current area
390     configuration.
391     Usage :
392     scram tool info tool_name [tool_version]
393    
394     ENDTEXT
395     }
396    
397     sub help_tool_list {
398     print <<ENDTEXT;
399     Description:
400     List of currently configured tools available in ther current scram
401     area
402     Usage :
403     scram tool list
404    
405     ENDTEXT
406     }
407    
408     sub help_tool_default {
409     print <<ENDTEXT;
410     Description:
411     Change the default version of a tool to be used in the area
412     Usage :
413     scram tool default tool_name tool_version
414    
415     ENDTEXT
416     }
417    
418     # ----------------------------------------------------------------------
419     sub _requirements {
420     if ( ! defined $reqsobj ) {
421     localtop();
422     my $area=_localarea();
423     scrambasics()->arearequirements($area)
424     }
425     return $reqsobj;
426     }
427    
428     sub _allprojectinitsearcher {
429     my $search=_projsearcher();
430     foreach $proj ( _scramprojdb()->list() ) {
431     $search->addproject($$proj[0],$$proj[1]);
432 williamc 1.29 }
433 williamc 1.33 }
434    
435     sub _projsearcher {
436     if ( ! defined $self->{projsearcher} ) {
437     require Scram::ProjectSearcher;
438     $self->{projsearcher}=Scram::ProjectSearcher->new(_scramprojdb());
439     }
440     return $self->{projsearcher};
441     }
442    
443     sub _scramprojdb {
444     return scrambasics()->scramprojectdb();
445 williamc 1.28 }
446    
447     sub runtime {
448     my $shell;
449 williamc 1.33 require Runtime;
450 williamc 1.28
451     # process options
452     while ( $ARGV[0]=~"^-" ) {
453     if ( $ARGV[0]=~/-sh/ ) {
454     shift @ARGV;
455     $shell="sh";
456     next;
457     }
458     if ( $ARGV[0]=~/-csh/ ) { #installation area directory
459     shift @ARGV;
460     $shell="csh";
461     next;
462     }
463     print "Unknown Option $ARGV[0]\n";
464     exit 1;
465     }
466 williamc 1.33
467     FullEnvInit();
468     if ( @ARGV ) {
469     my $runtime=Runtime->new();
470     my $arg=shift @ARGV;
471    
472     my $info=0;
473     if ( $arg eq "info" ) {
474     $arg=shift @ARGV;
475     $info=1;
476     }
477    
478     # --- determine filename
479     my $filename;
480     if ( -f $arg ) { # Is it a file?
481     $filename=$arg;
482     }
483     else {
484     # -- lets see if its a BuildFile location
485     $filename=_testfile($ENV{LOCALTOP}."/src/".$arg,
486     $ENV{RELEASETOP}."/src/".$arg,
487     $ENV{LOCALTOP}."/src/".$arg."/BuildFile",
488     $ENV{RELEASETOP}."/src/".$arg."/BuildFile");
489     if ( $filename eq "" ) {
490     print "Unable to find a file (or BuildFile) relating to ".
491     $arg."\n";
492     exit 1;
493     }
494     }
495     $runtime->file($filename);
496     if ( ! $info ) {
497     $runtime->printenv($shell);
498     }
499     else {
500     if ( @ARGV ) { #do we have a specific variable request?
501     _printvardoc($runtime,shift @ARGV);
502     }
503     else {
504     foreach $var ( $runtime->list() ) {
505     _printvardoc($runtime,$var);
506     }
507     }
508     }
509     undef $runtime;
510     }
511     else {
512     FullEnvInit();
513 williamc 1.35.2.2.2.7 # -- We have to clean up from the last runtime cmd - use env history
514 williamc 1.33 foreach $variable ( %ENV ) {
515     if ( $variable=~/^SCRAMRT_(.*)/ ) { #SCRAMRT are history retaining
516     my $var=$1;
517     $ENV{$var}=~s/\Q$ENV{$variable}\E//g;
518     $ENV{$var}=~s/^:*//; # Deal with any Path variables
519     #print "$variable : $ENV{$variable} \n$var : $ENV{$var}\n";
520     delete $ENV{$variable};
521     }
522     }
523    
524     # -- get the tool runtime environments
525 williamc 1.35.2.2.2.7 my $toolrt=scrambasics()->toolruntime(_localarea());
526     $toolrt->sethash(\%EnvRuntime);
527 williamc 1.33
528 williamc 1.35.2.2.2.7 # -- create new SCRAMRT history vars.
529 williamc 1.33 foreach $variable ( keys %EnvRuntime ) {
530     printoutenv($shell,"SCRAMRT_$variable",$EnvRuntime{$variable});
531     #addvar("SCRAMRT_$variable", $EnvRuntime{$variable}, "");
532     }
533 williamc 1.35.2.2.2.7
534     # TODO -- this stuff should dissappear with compiler description docs
535 williamc 1.33 # Now adapt as necessary - include base environment as well
536     if ( exists $ENV{LD_LIBRARY_PATH} ) {
537     addpath("LD_LIBRARY_PATH","$ENV{LD_LIBRARY_PATH}");
538     }
539     if ( exists $ENV{MANPATH} ) {
540     addpath("MANPATH","$ENV{MANPATH}");
541     }
542     addpath("PATH","$ENV{PATH}");
543 williamc 1.35.2.2.2.7
544     # -- Print out as reqd
545     # TODO -- we can use the runtime class method once we have removed
546     # this stuff above
547 williamc 1.33 foreach $variable ( keys %EnvRuntime ) {
548     printoutenv($shell,$variable,$EnvRuntime{$variable});
549     }
550     }
551 williamc 1.28 }
552    
553     # Support rt for runtime
554    
555 williamc 1.33 sub _testfile {
556     my @files=@_;
557    
558     my $filename="";
559     foreach $file ( @files ) {
560     if ( -f $file ) {
561     $filename=$file;
562     last;
563     }
564     }
565     return $filename;
566     }
567    
568     sub _printvardoc {
569     my $runtime=shift;
570     my $var=shift;
571    
572     print $var." :\n";
573     print $runtime->doc($var);
574     print "\n";
575     }
576    
577 williamc 1.28 sub printoutenv {
578     my $shell=shift;
579     my $variable=shift;
580     my $value=shift;
581    
582     if ( $shell eq "csh" ) {
583     print "setenv $variable \"$value\";\n";
584     }
585     elsif ( $shell eq "sh" ) {
586     print "$variable=\"$value\";\n";
587     print "export $variable;\n";
588     }
589     }
590    
591     sub addpath {
592     my $name=shift;
593     my $val=shift;
594    
595     my $n;
596     my @env;
597     @env=split /:/, $EnvRuntime{$name};
598     foreach $n ( (split /:/, $val ) ){
599     if ( ! grep /^\Q$n\E$/, @env ) {
600     addvar($name,$n,":");
601     }
602     }
603     }
604    
605     sub addvar {
606     my $name=shift;
607     my $val=shift;
608     my $sep=shift;
609    
610     if ( $val ne "" ) {
611     if ( defined $EnvRuntime{$name} ) {
612     $EnvRuntime{$name}=$EnvRuntime{$name}.$sep.$val;
613     }
614     else {
615     $EnvRuntime{$name}=$val;
616     }
617     }
618     }
619    
620     sub FullEnvInit {
621     environmentinit();
622     localtop();
623     LoadEnvFile();
624     }
625    
626     sub environmentinit {
627 williamc 1.33 use Utilities::setarchitecture;
628 williamc 1.28 my $name;
629     my $value;
630    
631     $ENV{LatestBuildFile}=""; # stop recursive behaviour in make
632 williamc 1.35.2.2.2.8 if ( ! defined $ENV{SCRAM_ARCH} ) {
633     setarchitecture::setarch();
634     }
635 williamc 1.28 $ENV{INTwork}="tmp/$ENV{SCRAM_ARCH}";
636     $ENV{INTsrc}="src";
637     $ENV{INTlog}="logs";
638 williamc 1.35.2.2.2.8 $ENV{INTlib}="lib/".$ENV{SCRAM_ARCH};
639 williamc 1.28
640     ($ENV{SCRAM_BASEDIR}=$ENV{SCRAM_HOME})=~s/(.*)\/.*/$1/;
641     if ( ! ( exists $ENV{SCRAM_CONFIG} ) ){
642     $ENV{SCRAM_CONFIG}="$ENV{SCRAM_HOME}/configuration";
643     }
644 williamc 1.35 $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
645 williamc 1.28 if ( ! ( exists $ENV{SCRAM_LOOKUPDB} ) ){
646     if ( -d "$ENV{SCRAM_BASEDIR}/scramdb/" ) {
647     $ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_BASEDIR}/scramdb/project.lookup";
648     }
649     else {
650     $ENV{SCRAM_LOOKUPDB}="$ENV{SCRAM_CONFIG}/project.lookup";
651     }
652     }
653     $ENV{SCRAM_AVAILDIRS}="";
654     $ENV{SCRAM_AVAILFILES}="";
655     }
656    
657 williamc 1.33 sub _localarea {
658     if ( ! defined $self->{localarea} ) {
659     require Configuration::ConfigArea;
660     $self->{localarea}=Configuration::ConfigArea->new();
661     if ( ! defined $ENV{LOCALTOP} ) {
662     if ( $self->{localarea}->bootstrapfromlocation() ) {
663     # Were not in a local area
664     undef $self->{localarea};
665     }
666     else {
667     $self->{localarea}->archname(scrambasics()->arch());
668     }
669     }
670     else {
671     $self->{localarea}->bootstrapfromlocation($ENV{LOCALTOP});
672     }
673     }
674     return $self->{localarea};
675     }
676    
677 williamc 1.28 sub localtop_find {
678     my $rv=1;
679 williamc 1.33 if ( defined _localarea()) {
680     $rv=0;
681     $ENV{LOCALTOP}=_localarea()->location();
682     }
683 williamc 1.28 return $rv;
684     }
685    
686     sub localtop {
687     localtop_find();
688     if ( ! (defined $ENV{LOCALTOP}) ) {
689     print "Unable to locate the top of local release. Exiting\n";
690     exit 1;
691     }
692     ($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//;
693     $ENV{THISDIR}=~s/^\///;
694     }
695    
696     sub LoadEnvFile {
697 williamc 1.33 _localarea()->copyenv(\%ENV);
698 williamc 1.28 }
699    
700     sub env {
701     print "Sorry - Not yet\n";
702 williamc 1.35.2.2.2.2 }
703    
704     sub devint {
705     my $class=shift @ARGV;
706     scrambasics()->scramobjectinterface($class);
707 williamc 1.28 }
708    
709 williamc 1.33 sub devtest {
710     require Utilities::TestClass;
711     my $class=shift @ARGV;
712    
713     my $tester;
714     my $path;
715    
716     #_initproject();
717     if ( $class=~/::/ ) {
718     ($path=$class)=~s/(.*)::.*/$1/;
719     }
720     $tester=Utilities::TestClass->new($class,
721     "$ENV{SCRAM_HOME}/src/$path/test/testdata");
722     $tester->dotest(@_);
723     }
724    
725 williamc 1.28 #
726     # Create a lookup tag in the site database
727     #
728 williamc 1.33 sub install {
729     localtop();
730     scrambasics()->addareatoDB(_localarea(),@ARGV);
731     _localarea()->align();
732 williamc 1.28 }
733    
734 williamc 1.33 sub help_install() {
735 williamc 1.28
736     print <<ENDTEXT;
737     Associates a label with the current release in the SCRAM database.
738     This allows other users to refer to a centrally installed project by
739     this label rather than a remote url reference.
740    
741     Usage:
742    
743     $bold scram install $normal [project_tag [version_tag]]
744    
745     porject_tag : override default label (the project name of the current release)
746     version_tag : the version tag of the current release. If version is not
747     specified the base release version will be taken by default.
748    
749     ENDTEXT
750     }
751    
752 williamc 1.33 sub helpheader ($label) {
753     my $label=shift;
754     print <<ENDTEXT;
755     *************************************************************************
756     SCRAM HELP --------- $label
757     *************************************************************************
758     ENDTEXT
759 williamc 1.28 }
760    
761     sub version {
762 williamc 1.33 my $version=shift @ARGV;
763 williamc 1.28 my $thisversion;
764     my $scram_top;
765     my $cvsobject;
766    
767     ($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
768     $scram_top=$1;
769 williamc 1.33 if ( $version eq "" ) {
770 williamc 1.28 print "$thisversion";
771     # deal with links
772     $version=readlink $ENV{SCRAM_HOME};
773     if ( defined $version) {
774     print " ---> $version";
775     }
776     print "\n";
777     }
778     else {
779     if ( -d $scram_top."/".$version ) {
780     print "Version $version exists\n";
781     }
782     else {
783     print "Version $version not available locally\n";
784     print "Attempting download from the SCRAM repository\n";
785     # set up and configure the cvs module for SCRAM
786 williamc 1.35 require Utilities::CVSmodule;
787 williamc 1.33 $cvsobject=Utilities::CVSmodule->new();
788 williamc 1.28 $cvsobject->set_base(
789     "cmscvs.cern.ch:/cvs_server/repositories/SCRAM");
790     $cvsobject->set_auth("pserver");
791     $cvsobject->set_user("anonymous");
792     $cvsobject->set_passkey("AA_:yZZ3e");
793     # Now check it out in the right place
794     chdir $scram_top or die "Unable to change to $scram_top $!\n";
795     $cvsobject->invokecvs( ( split / /,
796     "co -d $version -r $version SCRAM" ));
797    
798     # Get rid of cvs object now weve finished
799     $cvsobject=undef;
800     print "\n";
801     }
802     }
803 williamc 1.33 0;
804 williamc 1.28 }
805    
806     sub list {
807 williamc 1.33 &environmentinit;
808     if ( ! -f $ENV{SCRAM_LOOKUPDB} ) {
809     print "No installation database available - perhaps no projects".
810     " have been installed locally\n";
811     exit 1;
812     }
813 williamc 1.28 print "Installed Projects\n";
814     print "------------------\n";
815     print "|Project Name | Project Version |\n";
816     print "----------------------------------\n";
817 williamc 1.35.2.2.2.4 listDB(@ARGV);
818 williamc 1.28 }
819    
820     sub db {
821     my $subcmd=shift @ARGV;
822     &environmentinit;
823    
824     switch : {
825     if ( $subcmd eq 'link' ) {
826 williamc 1.35.2.2.2.3 scrambasics()->scramprojectdb()->link(@ARGV);
827 williamc 1.28 last switch;
828     }
829 williamc 1.33 if ( ! -f $ENV{SCRAM_LOOKUPDB} ) {
830     print "No installation database available - perhaps no projects".
831     "have been installed locally\n";
832     exit 1;
833     }
834 williamc 1.28 if ( $subcmd eq 'unlink' ) {
835 williamc 1.35.2.2.2.3 scrambasics()->scramprojectdb()->unlink(@ARGV);
836 williamc 1.28 last switch;
837     }
838     if ( $subcmd eq 'showlinks' ) {
839 williamc 1.35.2.2.2.3 my @links=scrambasics()->scramprojectdb()->listlinks();
840     foreach $link ( @links ) {
841     print $link."\n";
842     }
843 williamc 1.28 last switch;
844     }
845     } # end switch
846    
847     }
848    
849 williamc 1.35.2.2.2.3 sub listDB {
850 williamc 1.35.2.2.2.4 my $project="";
851     if ( @_ ) {
852     $project=shift;
853     }
854 williamc 1.35.2.2.2.3 my @prs=scrambasics()->scramprojectdb()->listall();
855     foreach $pr ( @prs ) {
856 williamc 1.35.2.2.2.4 if ( $project eq "" || $project eq $$pr[0] ) {
857 williamc 1.35.2.2.2.3 printf "%1s",$$pr[0];
858     printf "%25s\n",$$pr[1];
859     my $url=scrambasics()->scramprojectdb()->
860     getarea($$pr[0],$$pr[1])->location();
861     printf "--> %25s\n",$url;
862 williamc 1.35.2.2.2.4 }
863 williamc 1.28 }
864 williamc 1.33 0;
865 williamc 1.28 }
866    
867     sub arch {
868 williamc 1.33 &environmentinit();
869     print "$ENV{SCRAM_ARCH}\n";
870 williamc 1.28 }
871    
872    
873 williamc 1.33 #
874     # Setup a new tool
875     #
876    
877     sub setup {
878     my $interactive=0;
879    
880     # process options
881     while ( $ARGV[0]=~"^-" ) {
882     if ( $ARGV[0]=~/-i/ ) {
883     shift @ARGV;
884     $interactive=1;
885     }
886     else {
887     error("scram: unknown option $ARGV[0] to project command");
888     }
889     }
890 williamc 1.29
891 williamc 1.33 localtop();
892     my $area=_localarea();
893     my $toolname=shift @ARGV;
894     my $insert=0;
895     toolbox()->interactive($interactive);
896 williamc 1.31
897 williamc 1.33 # If no toolname specified then its a full setup
898     if ( $toolname eq "" ) {
899     # -- add architecture specific directories
900     use Utilities::AddDir;
901     AddDir::adddir($area->location()."/lib/$ENV{SCRAM_ARCH}");
902     AddDir::adddir($area->location()."/bin/$ENV{SCRAM_ARCH}");
903 williamc 1.31
904 williamc 1.33 # -- check the releasetop area
905     # if the releasetop has the files copy them
906     my $releaseobj=_releasearea();
907     if ( $releaseobj->copysetup($ENV{LOCALTOP}) ) {
908     print "Doing Full Setup\n";
909     scrambasics()->setuptoolsinarea($area);
910 williamc 1.31 }
911     }
912     else {
913 williamc 1.33 scrambasics()->setuptoolsinarea($area, $toolname,@ARGV);
914 williamc 1.31 }
915     }
916    
917 williamc 1.33 sub _releasearea {
918     if ( !defined $self->{releasearea} ) {
919     require Configuration::ConfigArea;
920     $self->{releasearea}=Configuration::ConfigArea->new();
921     $self->{releasearea}->bootstrapfromlocation($ENV{RELEASETOP});
922 williamc 1.31 }
923 williamc 1.33 return $self->{releasearea};
924 williamc 1.29 }
925    
926 williamc 1.33 # get a toolbox object for the local area
927     sub toolbox {
928     if ( ! defined $toolbox ) {
929     localtop();
930     my $area=_localarea();
931     $toolbox=scrambasics()->areatoolbox($area);
932 williamc 1.28 }
933 williamc 1.33 return $toolbox;
934 williamc 1.28 }
935    
936     sub help_db {
937     print <<ENDTEXT;
938     scram database administration command.
939    
940     Usage:
941    
942     $bold scram db $normal subcommand
943    
944     subcommands:
945     link :
946     Make available an additional database for
947     project and list operations
948    
949     $bold scram db link $normal /a/directory/path/project.lookup
950    
951     unlink :
952     Remove a database from the link list. Note this does
953     not remove the database, just the link to it in scram.
954    
955     $bold scram db unlink $normal /a/directory/path/project.lookup
956    
957     showlinks :
958     List the databases that are linked in
959    
960     ENDTEXT
961     }
962    
963     sub help_setup {
964    
965     print <<ENDTEXT;
966 williamc 1.33 Allows installation/re-installation of a new tool/external package into an
967     already existing development area. If not toolname is specified,
968     the complete installation process is initiated.
969 williamc 1.28
970     Usage:
971    
972 williamc 1.33 $bold scram setup [-i]$normal [toolname] [[version] [url]]
973 williamc 1.29
974 williamc 1.33 toolname : The name of the tool setup file required.
975     version : where more than one version exists specify the version
976     url : when setting up a completely new tool specify the url too
977 williamc 1.29
978 williamc 1.33 The -i option turns off the automatic search mechanism allowing for more
979     user interaction with the setup mechanism
980 williamc 1.29 ENDTEXT
981     }
982    
983 williamc 1.28 sub help_list {
984     print <<ENDTEXT;
985     List the available projects and versions installed in the local SCRAM database
986     (see scram install help)
987    
988     Usage:
989    
990 williamc 1.35.2.2.2.4 $bold scram list $normal [ProjectName]
991 williamc 1.28
992     ENDTEXT
993     }
994    
995     sub help_project {
996     print <<ENDTEXT;
997     Setup a new project development area. The new area will appear in the current
998     working directory.
999     Usage:
1000    
1001     $bold scram project [-d install_area] [-n directory_name]$normal project_url [project_version]
1002    
1003     Options:
1004    
1005     project_url: The url of a scram bootstrap file.
1006     Currently supported types are:
1007     $bold Database label $normal
1008     Labels can be assigned to bootstrap files for easy
1009     access (See "scram install" command). If you
1010     specify a label you must also specify a project_version.
1011     e.g.
1012    
1013     scram project SCRAM V1_0
1014    
1015     scram project ORCA ORCA_1_1_1
1016    
1017     To see the list of installed projects use the
1018     "scram list" command.
1019    
1020     $bold file: $normal A regular file on an accessable file system
1021     e.g.
1022    
1023     file:~/myprojects/projecta/config/BootStrapFile
1024    
1025     project_version:
1026     Only for use with a database label
1027    
1028     -d install_area:
1029     Indicate a project installation area into which the new
1030     project area should appear. Default is the current working
1031     directory.
1032    
1033     -n directory_name:
1034     Specify the name of the SCRAM development area you wish to
1035     create.
1036    
1037     ENDTEXT
1038     }
1039    
1040     sub help_version {
1041     print <<ENDTEXT;
1042 williamc 1.33 With now $bold [version] $normal argument given, this command will simply
1043 williamc 1.28 print to standard output the current version number.
1044    
1045     Providing a version argument will cause that version to be downloaded and
1046     installed, if not already locally available.
1047    
1048    
1049     Usage:
1050     $bold scram version [version]$normal
1051    
1052     ENDTEXT
1053     }
1054    
1055     sub help_arch {
1056     print <<ENDTEXT;
1057     Print out the architecture flag for the current machine.
1058    
1059     Usage:
1060     $bold scram arch $normal
1061     ENDTEXT
1062     }
1063    
1064     sub help_runtime {
1065     print <<ENDTEXT;
1066     Echo to Standard Output the Runtime Environment for the current development area
1067     Output available in csh or sh flavours
1068    
1069     Usage:
1070 williamc 1.33 1) $bold scram runtime [-csh|-sh] $normal
1071     or
1072     2) $bold scram runtime [-csh|-sh] filename $normal
1073     or
1074     3) $bold scram runtime info filename [variable]$normal
1075    
1076     1) For the general configuration environment
1077     2) For environment described in filename or
1078     areatop/src/directory/BuildFile
1079     3) Display information concerning the environment in the given file
1080     (limited to variable if specified)
1081    
1082     The file for cases 2) and 3) are searched as follows :
1083     a) straightforward filename
1084     b) filename relative to local_area/src
1085     c) filename relative to release_area/src
1086     d) BuildFile relative to local_area/src
1087     e) BuildFile relative to release_area/src
1088 williamc 1.28
1089     Examples:
1090    
1091     Setup the current environment to include the project Runtime Environment
1092     in a csh environment
1093    
1094     $bold eval `scram runtime -csh` $normal
1095    
1096     Setup the current environment to include the project Runtime Environment in a
1097     sh environment
1098    
1099     $bold eval `scram runtime -sh` $normal
1100    
1101    
1102     ENDTEXT
1103     }