ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/scram
(Generate patch)

Comparing COMP/SCRAM/src/scram (file contents):
Revision 1.13 by williamc, Thu Mar 25 15:31:37 1999 UTC vs.
Revision 1.25 by williamc, Mon Jun 7 15:01:18 1999 UTC

# Line 7 | Line 7 | $inputcmd=shift;
7   $found='false';
8   $bold  = "\033[1m";
9   $normal = "\033[0m";
10 < @allowed_commands=qw(project build env install version list arch setup);
10 > @allowed_commands=qw(project build install version list arch setup runtime devtest);
11  
12 < foreach $command ( @allowed_commands ) {
13 <         if ( $inputcmd=~/^$command\Z/i) {
12 > if ( $inputcmd ne "" ) {
13 > foreach $command ( @allowed_commands ) {
14 >         if ( $command=~/^$inputcmd/i) {
15                  # Deal with a help request
16 <                do{     helpheader($command);
16 >                do{ &helpheader($command);
17                          &{"help_".$command}; exit; } if $ARGV[0]=~/help/i;
18                  &$command; $found='true';
19                  last;
20           }
21 + }
22   }
23  
24   if ( ! ( $found=~/true/ ) ) {
25 <        print "scram help\n---------\n";
24 <        print "Recognised Commands: \n";
25 >        helpheader('Recognised Commands');
26          foreach $command ( @allowed_commands ) {
27 <        print "       ".$command."\n";  
27 >        print "      $bold scram ".$command.$normal."\n";      
28          }
29 +        print "\n";
30 +        print "Help on individual commands available through\n\n";
31 +        print "$bold       scram".$normal." command$bold help $normal\n\n";
32 + }
33 +
34 + sub devtest {
35 +        use Utilities::testclass;
36 +        my $class;
37 +        my $tester;
38 +        my $path;
39 +
40 +        $class=shift @ARGV;
41 +        ($path=$class)=~s/(.*)\/.*/\1/;
42 +        $tester=testclass->new($class,
43 +                "$ENV{SCRAM_HOME}/src/$path/test/testdata");
44 +        $tester->dotest(@ARGV);
45 + }
46 +
47 + sub test_setup {
48 +        my $tool;
49 +        my $toolversion;
50 +        my $interactive=0;
51 +        my $listonly=0;
52 +
53 +        # process options
54 +        while ( $ARGV[0]=~"^-" ) { # turn on interactive setup mode
55 +         if ( $ARGV[0]=~/-i/ ) {
56 +           shift @ARGV;
57 +           $interactive=1;
58 +           print "Entering Interactive Setup Mode\n";
59 +           next;
60 +         }
61 +         if ( $ARGV[0]=~/-r/ ) {
62 +           shift @ARGV;
63 +           $listonly=1;
64 +           print "---------------- Project Requirements List -----------\n";
65 +           next;
66 +         }
67 +         print "Error : Unknown Option $ARGV[0]\n";
68 +         help_setup();
69 +         exit 1;
70 +        }
71 +        my $toolname=shift @ARGV;
72 +        my $version=shift @ARGV;
73 +
74 +        &FullEnvInit();
75 +        &RequirementsInit;
76 +
77 +        if ( $toolname ne "" ) {
78 +          _setuptool($interactive, $toolname, $version);
79 +        }
80 +        else {
81 +          $reqobj->IteratorReset;
82 +          while ( ( $toolname=$reqobj->IteratorNext() ) ne "" ) {
83 +            if ( $listonly ) {
84 +                print $bold.$toolname.$normal.
85 +                        " version ".$reqobj->Version($toolname)."\n";
86 +            }
87 +            else {
88 +              _setuptool
89 +                 ($interactive, $toolname, $reqobj->Version("$toolname"));
90 +            }
91 +          }
92 +        }
93 + }
94 +
95 + sub _setuptool {
96 +        my $tool;
97 +        my $toolversion;
98 +        my $interactive=shift;
99 +        my $toolname=shift;
100 +        my $version=shift;
101 +
102 +
103 +        if ( ( $version eq "" ) && ( $interactive == 0 )) {
104 +          #if not specified set to that of req. doc
105 +          $version=$reqobj->Version($toolname);
106 +        }
107 +
108 +        # ideally try and download it if not already in .SCRAM
109 +        # Only scram toolbox files supported so far
110 +          if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) {
111 +                &urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/"
112 +                        .$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ;
113 +          }
114 +        use ToolSetup;
115 +        $tool=ToolSetup->new("$ENV{LOCALTOP}/.SCRAM/$toolname");
116 +
117 +        # check we have a version
118 +        if ( $interactive == 0 ) {
119 +         $tool->UnSetInteractive();
120 +        }
121 +        else {
122 +          $tool->SetInteractive();
123 +        }
124 +        $tool->Setup($toolname, $version);
125 +        
126   }
127  
128 + sub help_build {
129 +        &build;
130 + }
131   sub build {
132          # is this a based or free release?
133          FullEnvInit();
# Line 39 | Line 140 | sub build {
140   sub project {
141          # process options
142          while ( $ARGV[0]=~"^-" ) {
143 <         if ( (shift @ARGV)=~/-d/ ) {  #installation area directory
143 >         if ( $ARGV[0]=~/-n/ ) {
144 >           shift @ARGV;
145 >           $ENV{devareaname}=shift @ARGV;
146 >         }
147 >         if ( $ARGV[0]=~/-d/ ) {  #installation area directory
148 >          shift @ARGV;
149            chdir $ARGV[0];
150            shift @ARGV;
151           }
# Line 50 | Line 156 | sub project {
156          use File::Copy;
157          use Utilities::AddDir;
158          
159 <           use BootStrapProject;
159 >           use BootStrapProject2;
160             # get the bootstrap files downloaded
161 <           BootStrapProject("$project\?\?$version");
161 > #          BootStrapProject("$project\?\?$version");
162 >           $bootstrapper->BootStrap("$project\?\?$version");
163             # Go setup the rest of the environement, now we can
164             chdir $ENV{LOCALTOP};
165 <           &localtop;
165 >           &localtop;
166             LoadEnvFile();
167             #
168             # Now create the directories specified in the interface
# Line 72 | Line 179 | sub project {
179             use clientfile;
180             BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
181             use Cwd;
182 <           print "Installation Located at:\n".cwd()."\n";
183 <           ReturnToContinue();
182 >           print "\nInstallation Procedure Complete. \n".
183 >                        "Installation Located at:\n".cwd()."\n";
184 > }
185 >
186 > sub runtime {
187 >        my $shell;
188 >        environmentinit();
189 >        localtop();
190 >
191 >        # process options
192 >        while ( $ARGV[0]=~"^-" ) {
193 >         if ( $ARGV[0]=~/-sh/ ) {
194 >           shift @ARGV;
195 >           $shell="sh";
196 >           next;
197 >         }
198 >         if ( $ARGV[0]=~/-csh/ ) {  #installation area directory
199 >          shift @ARGV;
200 >          $shell="csh";
201 >          next;
202 >         }
203 >         print "Unknown Option $ARGV[0]\n";
204 >         exit 1;
205 >        }
206 >        open (file, "$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings" )
207 >                or die "Unable to open file ".
208 >                "$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/clientsettings $!";
209 >        while( <file> ) {
210 >           chomp;
211 >           next if /^#/;
212 >           next if /^\s*$/;
213 >           ($product, $version, $type, $variable, $value, @junk)=split /:/;
214 >           next if ( $variable=~/\&/ );
215 >           if ( $type=~/^R/ ) {
216 >                if ( ( $type=~/path/ ) ) { #type Rtype
217 >                   addvar($variable,$value,":"); # Colon seperated
218 >                }
219 >                else {                   #type R
220 >                   addvar($variable,$value," "); # Add with spaces
221 >                }
222 >           }
223 >        }
224 >        close file;
225 >        addvar("LD_LIBRARY_PATH","$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}",":");
226 >        addvar("PATH","$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}",":");
227 >        # We have to clean up from the last runtime cmd - use env history
228 >        foreach $variable ( %ENV ) {
229 >          if ( $variable=~/^SCRAMRT_(.*)/ ) { #SCRAMRT are history retaining
230 >            $ENV{$1}=~s/\Q$ENV{$variable}\N\:*//;
231 >            delete $ENV{$variable};
232 >          }
233 >        }
234 >        # create new SCRAMRT history vars.
235 >        foreach $variable ( keys %EnvRuntime ) {
236 >          addvar("SCRAMRT_$variable", $EnvRuntime{$variable}, "");
237 >        }
238 >        # Now adapt as necessary - include base environment as well
239 >        addvar("LD_LIBRARY_PATH","$ENV{LD_LIBRARY_PATH}",":");
240 >        addvar("PATH","$ENV{PATH}",":");
241 >        # Print out as reqd
242 >        foreach $variable ( keys %EnvRuntime ) {
243 >         if ( $shell eq "csh" ) {
244 >           print "setenv $variable \"$EnvRuntime{$variable}\";\n";
245 >         }
246 >         elsif ( $shell eq "sh" ) {
247 >           print "export $variable=$EnvRuntime{$variable};\n";
248 >         }
249 >        }
250 > }
251 >
252 > # Support rt for runtime
253 > sub addvar {
254 >        my $name=shift;
255 >        my $val=shift;
256 >        my $sep=shift;
257 >
258 >        if ( $val ne "" ) {
259 >        if ( defined $EnvRuntime{$name} ) {
260 >         $EnvRuntime{$name}=$EnvRuntime{$name}.$sep.$val;
261 >        }
262 >        else {  
263 >         $EnvRuntime{$name}=$val;
264 >        }
265 >        }
266   }
267  
268   sub FullEnvInit {
# Line 124 | Line 313 | sub localtop {
313          } while ( ( $thispath=~s/(.*)\/.*/$1/ )=~/./  );
314          if ( ! (defined $ENV{LOCALTOP}) ) {
315           print "Unable to locate the top of local release. Exiting\n";
316 <         ReturnToContinue();
316 >         exit 1;
317          }
318          } #end block
319 <        ($ENV{THISDIR}=cwd)=~s/^$ENV{LOCALTOP}//;
319 >        ($ENV{THISDIR}=cwd)=~s/^\Q$ENV{LOCALTOP}\L//;
320          $ENV{THISDIR}=~s/^\///;
321          $ENV{SCRAM_WORKDIR}="$ENV{LOCALTOP}/.SCRAM";
322   }
# Line 149 | Line 338 | sub env {
338     print "Sorry - Not yet\n";
339   }
340  
341 + sub RequirementsInit {
342 +        use Requirements;
343 +        $reqobj=Requirements->new($ENV{SCRAM_ProjReqsDoc});
344 + }
345 +
346   #
347   # Create a lookup tag in the site database
348   #
# Line 167 | Line 361 | sub install ( $tagname, $version ) {
361          my $filename="$ENV{SCRAM_CONFIG}/project.lookup";
362          my $outfile="$ENV{SCRAM_CONFIG}/project.lookup.tmp";
363          open ( LOCALLOOKUPDB, "<$filename" );
364 <        open ( OUTFILE , ">$outfile" );
364 >        open ( OUTFILE , ">$outfile" ) or die "Unable to open $outfile $!\n";
365          while ( <LOCALLOOKUPDB> ) {
366              if ( /^$tagname/ ) {
367                  print "Related tag :".$_."\n";
# Line 226 | Line 420 | ENDTEXT
420   }
421  
422   sub version {
423 <        print "Scram version : prototype\n";
423 >        my $version=shift @ARGV;
424 >        my $thisversion;
425 >        my $scram_top;
426 >        my $cvsobject;
427 >
428 >        ($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
429 >        $scram_top=$1;
430 >        if ( $version eq "" ) {
431 >          print "$thisversion\n";
432 >        }
433 >        else {
434 >          if ( -d $scram_top."/".$version ) {
435 >                print "Version $version exists\n";
436 >          }
437 >          else {
438 >              print "Version $version not available locally\n";
439 >              print "Attempting download from the SCRAM repository";
440 >              # set up and configure the cvs module for SCRAM
441 >              use Utilities::cvsmodule;
442 >              $cvsobject=cvsmodule->new();
443 >              $cvsobject->set_base(
444 >                "cmscvs.cern.ch:/cvs_server/repositories/SCRAM");
445 >              $cvsobject->set_auth("pserver");
446 >              $cvsobject->set_user("anonymous");
447 >              $cvsobject->set_passkey("AA_:yZZ3e");
448 >              # Now check it out in the right place
449 >              chdir $scram_top or die "Unable to change to $scram_top $!\n";
450 >              $cvsobject->invokecvs( ( split / /,
451 >                        "co -d $version -r $version SCRAM" ));
452 >                
453 >              # Get rid of cvs object now weve finished
454 >              $cvsobject=undef;
455 >              print "\n";
456 >          }
457 >        }
458   }
459  
460   sub list {
# Line 251 | Line 479 | sub arch {
479          print "$ENV{SCRAM_ARCH}\n";
480   }
481  
254 sub ReturnToContinue {
255           print "Press RETURN to exit\n";
256           $junk=<STDIN>;
257 }
482  
483   #
484   # Setup a new tool
# Line 262 | Line 486 | sub ReturnToContinue {
486  
487   sub setup {
488          my $toolname=shift @ARGV;
489 +        my $insert=0;
490  
491          &FullEnvInit;
492 <        if ( $ENV{SCRAM_BootStrapFiles}!~/$ENV{LOCALTOP}\/\.SCRAM/ ) {
492 >        if ( $ENV{SCRAM_BootStrapFiles}!~/\Q$ENV{LOCALTOP}\N\/\.SCRAM/ ) {
493            $ENV{SCRAM_BootStrapFiles}="$ENV{LOCALTOP}/.SCRAM:".
494                          $ENV{SCRAM_BootStrapFiles};
495          }
496 <        # Check for the correct toolfile
497 <        # ideally try and download it if not already in .SCRAM
498 <        # Only scram toolbox files supported so far
499 <        if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) {
496 >        my $filebase="$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}";
497 >        rename "$filebase/clientsettings", "$filebase/clientsettings.old";
498 >        chdir $ENV{LOCALTOP}; # make sure we do this from the top dir
499 >        # If no toolname specified then its a full setup
500 >        if ( $toolname eq "" ) {
501 >           rename "$filebase/clientsettings_reqs",
502 >                                "$filebase/clientsettings_reqs.old";
503 >           use clientfile;
504 >           BuildClientFile( $ENV{SCRAM_ProjReqsDoc} );
505 >           # Work-around for Broken ARCH directories
506 >           use Utilities::AddDir;
507 >           AddDir::adddir("$ENV{LOCALTOP}/lib/$ENV{SCRAM_ARCH}");
508 >           AddDir::adddir("$ENV{LOCALTOP}/bin/$ENV{SCRAM_ARCH}");
509 >        }
510 >        else {
511 >          # Check for the correct toolfile
512 >          # ideally try and download it if not already in .SCRAM
513 >          # Only scram toolbox files supported so far
514 >          if ( ! -e "$ENV{LOCALTOP}/.SCRAM/$toolname" ) {
515                  &urlhandler::urlhandler("file:$ENV{SCRAM_HOME}/toolbox/"
516                          .$toolname, "$ENV{LOCALTOP}/.SCRAM/$toolname") ;
517 +          }
518 +          # Parse the toolfile and update the clientsettings file
519 +          # currently just append to the end
520 +          use clientfile;
521 +          #create a new clientfile containing just the tool
522 +          clientfile::openclientfile('add');
523 +          clientfile::_tool("file:$toolname");
524 +          clientfile::closeclientfile();
525 +          #Now splice it in to the original - replacing the previous one if
526 +          #necessary - a bit of a hack to say the least -fortunately is
527 +          # already rewrittten for the next release!
528 +        
529 +          open FILEIN, "$filebase/clientsettings" or die "$!\n";
530 +          while ( <FILEIN> ) {
531 +            push @filelines, $_;
532 +            next, if /^\s*#/;
533 +            chomp;
534 +            ($toolkey=$_)=~s/(.*?:).*/$1/;
535 +          }
536 +          close FILEIN;
537 +          open FILEIN, "<$filebase/clientsettings.old";
538 +          open FILEOUT, ">$filebase/clientsettings.tmp";
539 +          while ( <FILEIN> ) {
540 +           if ( ( $_=~/^$toolkey/ ) ) {
541 +            if ( $insert==0 ) {
542 +             foreach $line ( @filelines ) {
543 +                print FILEOUT $line;
544 +             }
545 +             $insert=1;
546 +            }
547 +            next;
548 +           }
549 +           else {
550 +                print FILEOUT $_;
551 +           }
552 +         }
553 +         if ( $insert==0 ) {
554 +          foreach $line ( @filelines ) {
555 +                print FILEOUT $line;
556 +          }
557 +         }
558 +         close FILEOUT;
559 +         close FILE;
560 +         rename "$filebase/clientsettings.tmp", "$filebase/clientsettings";
561          }
562 <        # Parse the toolfile and update the clientsettings file
279 <        # currently just append to the end
280 <        use clientfile;
281 <        clientfile::openclientfile('add');
282 <        clientfile::_tool("file:$toolname");
283 <        closeclientfile;
562 >        
563   }
564  
565   sub help_setup {
566  
567   print <<ENDTEXT;
568 < Allows installation of a new tool/external package into an already existing
569 < area.
568 > Allows installation/re-installation of a new tool/external package into an
569 > already existing development area. If not toolname is specified,
570 > the complete installation process is initiated.
571  
572   Usage:
573  
574 <                 scram setup toolname
574 >                 $bold scram setup $normal [toolname]
575  
576   toolname : The name of the tool setup file required.
577   ENDTEXT
# Line 304 | Line 584 | Create an entry in the SCRAM database so
584   referenced in the 'project' command by a tag/version combination.
585   Usage: (command to be issued from inside an installed project)
586  
587 <                scram install [project_tag [version_tag]]
587 >        $bold   scram install $normal [project_tag [version_tag]]
588  
589   If not specified the project_tag and version_tag default to the project
590   name and version of the installation.
# Line 317 | Line 597 | Setup a new project development area. Th
597   working directory.
598   Usage:
599  
600 <        $bold scram project [-d install_area] $normal project_url [project_version]
600 >        $bold scram project [-d install_area] [-n directory_name]$normal project_url [project_version]
601  
602   Options:
603  
# Line 348 | Line 628 | project_version:
628                   Indicate a project installation area into which the new
629                   project area should appear. Default is the current working
630                   directory.
631 +
632 + -n directory_name:
633 +                 Specify the name of the SCRAM development area you wish to
634 +                 create.
635          
636 + -n dir_name     :
637 +                 Specify name of the new development area directory
638 + ENDTEXT
639 + }
640 +
641 + sub help_version {
642 + print <<ENDTEXT;
643 + With now $bold[version] $normal argument given, this command will simply
644 + print to standard output the current version number.
645 +
646 + Providing a version argument will cause that version to be downloaded and
647 + installed, if not already locally available.
648 + [Coming soon: When available locally, your current development area will
649 + then be associated with the specified scram version rather than the default]
650 +
651 +
652 + Usage:
653 +                $bold scram version [version]$normal
654 +
655 + ENDTEXT
656 + }
657 +
658 + sub help_arch {
659 + print <<ENDTEXT;
660 + Print out the architecture flag for the current machine.
661 +
662 + Usage:
663 +        $bold   scram arch $normal
664 + ENDTEXT
665 + }
666 +
667 + sub help_devtest {
668 + print <<ENDTEXT;
669 + For SCRAM development only. Allows testing of new features.
670 +
671 + Usage:
672 +        $bold   scram devtest
673 + ENDTEXT
674 + }
675 +
676 + sub help_runtime {
677 + print <<ENDTEXT;
678 + Echo to Standard Output the Runtime Environment for the current development area
679 + Output available in csh or sh flavours
680 +
681 + Usage:
682 +        $bold   scram runtime [-csh|-sh] $normal
683 +
684 + Examples:
685 +
686 + Setup the current environment to include the project Runtime Environment
687 + in a csh environment
688 +
689 +       $bold  eval `scram runtime -csh` $normal
690 +
691 + Setup the current environment to include the project Runtime Environment in a
692 + sh environment
693 +
694 +       $bold  `scram runtime -sh` $normal
695 +
696   ENDTEXT
697   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines