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

Comparing COMP/SCRAM/src/Configuration/ConfigArea.pm (file contents):
Revision 1.22 by sashby, Tue Dec 4 19:24:04 2001 UTC vs.
Revision 1.26 by sashby, Wed Feb 2 18:57:01 2005 UTC

# Line 63 | Line 63 | sub new {
63          $self->{admindir}=".SCRAM";
64          $self->{cachedir}="cache";
65          $self->{dbdir}="ObjectDB";
66 +        $self->{tbupdate}=0;
67          undef $self->{linkarea};
68  
69          return $self;
# Line 86 | Line 87 | sub cache {
87          return $self->{cache};
88   }
89  
90 + # Tool and project cache info:
91 + sub cacheinfo
92 +   {
93 +   my $self=shift;
94 +   print "\n","<ConfigArea> cacheinfo: ToolCache = ",$self->{toolcachefile},
95 +   ", ProjectCache = ",$self->{projectcachefile},"\n";
96 +   }
97 +
98 + sub toolcachename
99 +   {
100 +   my $self=shift;
101 +   return ($self->location()."/".$self->{admindir}."/".$ENV{SCRAM_ARCH}."/ToolCache.db");
102 +   }
103 +
104 + sub projectcachename
105 +   {
106 +   my $self=shift;
107 +   return ($self->location()."/".$self->{admindir}."/".$ENV{SCRAM_ARCH}."/ProjectCache.db");
108 +   }
109 +
110 + sub _tbupdate
111 +   {
112 +   # Update toolbox relative to new RequirementsDoc:
113 +   my $self=shift;
114 +   @_?$self->{tbupdate}=shift
115 +      :$self->{tbupdate};
116 +   }
117 +
118   sub _newcache {
119          my $self=shift;
120          my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
# Line 138 | Line 167 | sub setup {
167          # -- check we have a project name and version
168          my $name=$self->name();
169          my $vers=$self->version();
170 +        
171          if ( ( ! defined $name ) && ( ! defined $version )) {
172            $self->error("Set ConfigArea name and version before setup");
173          }
# Line 181 | Line 211 | sub configurationdir {
211          return (defined $self->{configurationdir})?$self->{configurationdir}:undef;
212   }
213  
214 + sub sourcedir {
215 +        my $self=shift;
216 +        if ( @_ ) {
217 +          $self->{sourcedir}=shift;
218 +        }
219 +        return (defined $self->{sourcedir})?$self->{sourcedir}:undef;
220 + }
221 +
222   sub toolbox {
223          my $self=shift;
224          if ( ! defined $self->{toolbox} ) {
# Line 189 | Line 227 | sub toolbox {
227          return $self->{toolbox};
228   }
229  
230 + sub toolboxversion {
231 +        my $self=shift;
232 +        if ( @_ ) {
233 +          $self->{toolboxversion}=shift;
234 +        }
235 +        return (defined $self->{toolboxversion})?$self->{toolboxversion}:undef;
236 + }
237 +
238   sub requirementsdoc {
239          my $self=shift;
240          if ( @_ ) {
# Line 279 | Line 325 | sub bootstrapfromlocation {
325          else {
326           $self->location($location);
327           $self->verbose("Found top ".$self->location());
282         my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat";
328           $self->_LoadEnvFile();
329          }
330          return $rv;
# Line 364 | Line 409 | sub satellite {
409          $sat->version($self->version());
410          $sat->requirementsdoc($self->{reqdoc});
411          $sat->configurationdir($self->configurationdir());
412 +        $sat->sourcedir($self->sourcedir());
413 +        $sat->toolboxversion($self->toolboxversion());
414          $sat->setup(@_);
415  
416          # -- copy across the cache and ObjectStore
# Line 430 | Line 477 | sub align {
477  
478   sub copysetup {
479          my $self=shift;
480 <        my $dest=shift;
434 <
480 >        my $dest=shift;
481          my $rv=1;
482          # copy across the admin dir
483          my $temp=$self->location()."/".$self->{admindir}."/".$self->arch();
# Line 445 | Line 491 | sub copysetup {
491          return $rv;
492   }
493  
494 + sub copyurlcache {
495 +        my $self=shift;
496 +        my $dest=shift;
497 +        my $rv=1;
498 +        # copy across the admin dir
499 +        my $temp=$self->location()."/".$self->{admindir}."/cache";
500 +        my $temp2=$dest."/".$self->{admindir}."/cache";
501 +        if ( $temp ne $temp2 ) {
502 +         if ( -d $temp ) {
503 +          AddDir::copydir($temp,$temp2);
504 +          $rv=0;
505 +         }
506 +        }
507 +        return $rv;
508 + }
509 +
510 + sub copywithskip {
511 +        my $self=shift;
512 +        my $dest=shift;
513 +        my ($filetoskip)=@_;            
514 +        my $rv=1;
515 +        # copy across the admin dir
516 +        my $temp=$self->location()."/".$self->{admindir}."/".$self->arch();
517 +        my $temp2=$dest."/".$self->{admindir}."/".$self->arch();
518 +        if ( $temp ne $temp2 ) {
519 +         if ( -d $temp ) {
520 +          AddDir::copydirwithskip($temp,$temp2,$filetoskip);
521 +          $rv=0;
522 +         }
523 +        }
524 +        return $rv;
525 + }
526 +
527   sub copyenv {
528          my $self=shift;
529          my $hashref=shift;
# Line 462 | Line 541 | sub arch {
541   sub linkto {
542          my $self=shift;
543          my $location=shift;
544 +
545          if ( -d $location ) {
546          my $area=Configuration::ConfigArea->new();
547          $area->bootstrapfromlocation($location);
# Line 497 | Line 577 | sub save {
577  
578   # ---- support routines
579  
580 < sub _SaveEnvFile {
581 <        my $self=shift;
582 <        use FileHandle;
583 <        my $fh=FileHandle->new();
584 <        open ( $fh, ">".$self->location()."/".$self->{admindir}."/".
585 <                "Environment" ) or
586 <                $self->error("Cannot Open Environment file to Save ("
587 <                                .$self->location().")\n $!");
580 > sub _SaveEnvFile
581 >   {
582 >   my $self=shift;
583 >   my $filemode = 0644;
584 >  
585 >   use FileHandle;
586 >   my $fh=FileHandle->new();
587 >   open ( $fh, ">".$self->location()."/".$self->{admindir}."/".
588 >          "Environment" ) or
589 >          $self->error("Cannot Open Environment file to Save ("
590 >                       .$self->location().")\n $!");
591          
592 <        print $fh "SCRAM_PROJECTNAME=".$self->name()."\n";
593 <        print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n";
594 <        print $fh "projconfigdir=".$self->configurationdir()."\n";
595 <        print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n";
596 <        if ( defined $self->linkarea() ) {
597 <          my $area=$self->linkarea()->location();
598 <          if ( $area ne "" ) {
599 <          print $fh "RELEASETOP=".$area."\n";
600 <          }
601 <        }
602 <        undef $fh;
603 < }
604 <
592 >   print $fh "SCRAM_PROJECTNAME=".$self->name()."\n";
593 >   print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n";
594 >   print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n";
595 >   print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n";
596 >   print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n";
597 >   print $fh "SCRAM_TOOLBOXVERSION=".$self->{toolboxversion}."\n";
598 >
599 >   if ( defined $self->linkarea() )
600 >      {
601 >      my $area=$self->linkarea()->location();
602 >      if ( $area ne "" )
603 >         {
604 >         print $fh "RELEASETOP=".$area."\n";
605 >         }
606 >      }
607 >  
608 >   undef $fh;
609 >  
610 >   # Set the default permissions (-rw-r--r--):
611 >   chmod $filemode, $self->location()."/".$self->{admindir}."/Environment";
612 >   }
613  
614 < sub _LoadEnvFile {
615 <        my $self=shift;
614 > sub _LoadEnvFile
615 >   {
616 >   my $self=shift;
617  
618 <        use FileHandle;
619 <        my $fh=FileHandle->new();
620 <        open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
621 <                "Environment" ) or
622 <                $self->error("Cannot find Environment file. Area Corrupted? ("
623 <                                .$self->location().")\n $!");
624 <        while ( <$fh> ) {
625 <           chomp;
626 <           next if /^#/;
627 <           next if /^\s*$/ ;
628 <           ($name, $value)=split /=/;
629 <           eval "\$self->{ENV}{${name}}=\"$value\"";
630 <        }
631 <        undef $fh;
618 >   use FileHandle;
619 >   my $fh=FileHandle->new();
620 >   open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
621 >          "Environment" ) or
622 >          $self->error("Cannot find Environment file. Area Corrupted? ("
623 >                       .$self->location().")\n $!");
624 >   while ( <$fh> )
625 >      {
626 >      chomp;
627 >      next if /^#/;
628 >      next if /^\s*$/ ;
629 >      ($name, $value)=split /=/;
630 >      eval "\$self->{ENV}{${name}}=\"$value\"";
631 >      }
632 >   undef $fh;
633          
634 <        # -- set internal variables appropriately
635 <        if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) {
636 <          $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
637 <        }
638 <        if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) {
639 <          $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
640 <        }
641 <        if ( defined $self->{ENV}{"projconfigdir"} ) {
642 <          $self->configurationdir($self->{ENV}{projconfigdir});
643 <        }
644 <        if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) {
645 <          $self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc});
646 <        }
647 <        if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
648 <                        ($self->{ENV}{"RELEASETOP"} ne $self->location())) {
649 <          $self->linkto($self->{ENV}{"RELEASETOP"});
650 <        }
651 <        else {
652 <          $self->{ENV}{"RELEASETOP"}=$self->location();
653 <        }
654 < }
634 >   # -- set internal variables appropriately
635 >   if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} )
636 >      {
637 >      $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
638 >      }
639 >   if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} )
640 >      {
641 >      $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
642 >      }
643 >   if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} )
644 >      {
645 >      $self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"});
646 >      }
647 >   if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} )
648 >      {
649 >      $self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"});
650 >      }
651 >   if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} )
652 >      {
653 >      $self->requirementsdoc($self->{ENV}{"SCRAM_ProjReqsDoc"});
654 >      }
655 >   if ( defined $self->{ENV}{"SCRAM_TOOLBOXVERSION"} )
656 >      {
657 >      $self->toolboxversion($self->{ENV}{"SCRAM_TOOLBOXVERSION"});
658 >      }
659 >  
660 >   if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
661 >        ($self->{ENV}{"RELEASETOP"} ne $self->location()))
662 >      {
663 >      $self->linkto($self->{ENV}{"RELEASETOP"});
664 >      }
665 >   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines