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.25 by sashby, Wed Feb 2 16:31:12 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 copywithskip {
495 +        my $self=shift;
496 +        my $dest=shift;
497 +        my ($filetoskip)=@_;            
498 +        my $rv=1;
499 +        # copy across the admin dir
500 +        my $temp=$self->location()."/".$self->{admindir}."/".$self->arch();
501 +        my $temp2=$dest."/".$self->{admindir}."/".$self->arch();
502 +        if ( $temp ne $temp2 ) {
503 +         if ( -d $temp ) {
504 +          AddDir::copydirwithskip($temp,$temp2,$filetoskip);
505 +          $rv=0;
506 +         }
507 +        }
508 +        return $rv;
509 + }
510 +
511   sub copyenv {
512          my $self=shift;
513          my $hashref=shift;
# Line 462 | Line 525 | sub arch {
525   sub linkto {
526          my $self=shift;
527          my $location=shift;
528 +
529          if ( -d $location ) {
530          my $area=Configuration::ConfigArea->new();
531          $area->bootstrapfromlocation($location);
# Line 497 | Line 561 | sub save {
561  
562   # ---- support routines
563  
564 < sub _SaveEnvFile {
565 <        my $self=shift;
566 <        use FileHandle;
567 <        my $fh=FileHandle->new();
568 <        open ( $fh, ">".$self->location()."/".$self->{admindir}."/".
569 <                "Environment" ) or
570 <                $self->error("Cannot Open Environment file to Save ("
571 <                                .$self->location().")\n $!");
564 > sub _SaveEnvFile
565 >   {
566 >   my $self=shift;
567 >   my $filemode = 0644;
568 >  
569 >   use FileHandle;
570 >   my $fh=FileHandle->new();
571 >   open ( $fh, ">".$self->location()."/".$self->{admindir}."/".
572 >          "Environment" ) or
573 >          $self->error("Cannot Open Environment file to Save ("
574 >                       .$self->location().")\n $!");
575          
576 <        print $fh "SCRAM_PROJECTNAME=".$self->name()."\n";
577 <        print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n";
578 <        print $fh "projconfigdir=".$self->configurationdir()."\n";
579 <        print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n";
580 <        if ( defined $self->linkarea() ) {
581 <          my $area=$self->linkarea()->location();
582 <          if ( $area ne "" ) {
583 <          print $fh "RELEASETOP=".$area."\n";
584 <          }
585 <        }
586 <        undef $fh;
587 < }
588 <
576 >   print $fh "SCRAM_PROJECTNAME=".$self->name()."\n";
577 >   print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n";
578 >   print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n";
579 >   print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n";
580 >   print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n";
581 >   print $fh "SCRAM_TOOLBOXVERSION=".$self->{toolboxversion}."\n";
582 >
583 >   if ( defined $self->linkarea() )
584 >      {
585 >      my $area=$self->linkarea()->location();
586 >      if ( $area ne "" )
587 >         {
588 >         print $fh "RELEASETOP=".$area."\n";
589 >         }
590 >      }
591 >  
592 >   undef $fh;
593 >  
594 >   # Set the default permissions (-rw-r--r--):
595 >   chmod $filemode, $self->location()."/".$self->{admindir}."/Environment";
596 >   }
597  
598 < sub _LoadEnvFile {
599 <        my $self=shift;
598 > sub _LoadEnvFile
599 >   {
600 >   my $self=shift;
601  
602 <        use FileHandle;
603 <        my $fh=FileHandle->new();
604 <        open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
605 <                "Environment" ) or
606 <                $self->error("Cannot find Environment file. Area Corrupted? ("
607 <                                .$self->location().")\n $!");
608 <        while ( <$fh> ) {
609 <           chomp;
610 <           next if /^#/;
611 <           next if /^\s*$/ ;
612 <           ($name, $value)=split /=/;
613 <           eval "\$self->{ENV}{${name}}=\"$value\"";
614 <        }
615 <        undef $fh;
602 >   use FileHandle;
603 >   my $fh=FileHandle->new();
604 >   open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
605 >          "Environment" ) or
606 >          $self->error("Cannot find Environment file. Area Corrupted? ("
607 >                       .$self->location().")\n $!");
608 >   while ( <$fh> )
609 >      {
610 >      chomp;
611 >      next if /^#/;
612 >      next if /^\s*$/ ;
613 >      ($name, $value)=split /=/;
614 >      eval "\$self->{ENV}{${name}}=\"$value\"";
615 >      }
616 >   undef $fh;
617          
618 <        # -- set internal variables appropriately
619 <        if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) {
620 <          $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
621 <        }
622 <        if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) {
623 <          $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
624 <        }
625 <        if ( defined $self->{ENV}{"projconfigdir"} ) {
626 <          $self->configurationdir($self->{ENV}{projconfigdir});
627 <        }
628 <        if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) {
629 <          $self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc});
630 <        }
631 <        if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
632 <                        ($self->{ENV}{"RELEASETOP"} ne $self->location())) {
633 <          $self->linkto($self->{ENV}{"RELEASETOP"});
634 <        }
635 <        else {
636 <          $self->{ENV}{"RELEASETOP"}=$self->location();
637 <        }
638 < }
618 >   # -- set internal variables appropriately
619 >   if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} )
620 >      {
621 >      $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
622 >      }
623 >   if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} )
624 >      {
625 >      $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
626 >      }
627 >   if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} )
628 >      {
629 >      $self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"});
630 >      }
631 >   if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} )
632 >      {
633 >      $self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"});
634 >      }
635 >   if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} )
636 >      {
637 >      $self->requirementsdoc($self->{ENV}{"SCRAM_ProjReqsDoc"});
638 >      }
639 >   if ( defined $self->{ENV}{"SCRAM_TOOLBOXVERSION"} )
640 >      {
641 >      $self->toolboxversion($self->{ENV}{"SCRAM_TOOLBOXVERSION"});
642 >      }
643 >  
644 >   if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
645 >        ($self->{ENV}{"RELEASETOP"} ne $self->location()))
646 >      {
647 >      $self->linkto($self->{ENV}{"RELEASETOP"});
648 >      }
649 >   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines