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.14 by williamc, Mon Aug 28 08:35:14 2000 UTC vs.
Revision 1.24 by sashby, Wed Feb 2 11:10:17 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 70 | Line 71 | sub new {
71  
72   sub cache {
73          my $self=shift;
74 +
75          if ( @_ ) {
76 <          $self->{cache}=shift;
76 >           $self->{cache}=shift;
77          }
78 <        elsif ( ! defined $self->{cache} ) {
78 >        if ( ! defined $self->{cache} ) {
79            my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
80 <          $self->{cache}=URL::URLcache->new($loc);
80 >          if ( -e $loc  ) {
81 >            $self->{cache}=URL::URLcache->new($loc);
82 >          }
83 >          else {
84 >            $self->{cache}=undef;
85 >          }
86          }
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};
121 +        $self->{cache}=URL::URLcache->new($loc);
122 +        return $self->{cache};
123 + }
124 +
125 + sub _newobjectstore {
126 +        my $self=shift;
127 +        my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir};
128 +        $self->{dbstore}=ObjectUtilities::ObjectStore->new($loc);
129 +        return $self->{dbstore};
130 + }
131 +
132   sub objectstore {
133          my $self=shift;
134 +
135          if ( @_ ) {
136 <          $self->{dbstore}=shift;
136 >            $self->{dbstore}=shift;
137          }
138 <        elsif ( ! defined $self->{dbstore} ) {
138 >        if ( ! defined $self->{dbstore} ) {
139            my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir};
140 <          $self->{dbstore}=ObjectUtilities::ObjectStore->new($loc);
140 >          if ( -e $loc ) {
141 >            $self->{dbstore}=ObjectUtilities::ObjectStore->new($loc);
142 >          }
143 >          else {
144 >            $self->{dbstore}=undef;
145 >          }
146          }
147          return $self->{dbstore}
148   }
# Line 112 | 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 137 | Line 193 | sub setup {
193          AddDir::adddir($workloc);
194  
195          # -- add a cache
196 <        $self->cache();
196 >        $self->_newcache();
197 >
198 >        # -- add an Objectstore
199 >        $self->_newobjectstore();
200  
201          # -- Save Environment File
202          $self->_SaveEnvFile();
# Line 152 | 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} ) {
225 <          $self->{toolbox}=BuildSystem::ToolBox->new($self);
225 >          $self->{toolbox}=BuildSystem::ToolBox->new($self, $ENV{SCRAM_ARCH});
226          }
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 191 | Line 266 | sub scramversion {
266          return $self->{scramversion};
267   }
268  
269 + sub sitename
270 +   {
271 +   ###############################################################
272 +   # sitename()                                                  #
273 +   ###############################################################
274 +   # modified : Mon Dec  3 15:45:35 2001 / SFA                   #
275 +   # params   :                                                  #
276 +   #          :                                                  #
277 +   #          :                                                  #
278 +   #          :                                                  #
279 +   # function : Read the site name from config/site/sitename and #
280 +   #          : export it.                                       #
281 +   #          :                                                  #
282 +   #          :                                                  #
283 +   ###############################################################
284 +   my $self = shift;
285 +   my $sitefile = $self->location()."/".$self->configurationdir()."/site/sitename";
286 +
287 +   $self->{sitename} = 'CERN'; # Use CERN as the default site name
288 +
289 +   use FileHandle;
290 +   my $sitefh = FileHandle->new();
291 +
292 +   # Be verbose and print file we're going to read:
293 +   $self->verbose(">> Going to try to get sitename from: ".$sitefile." ");
294 +  
295 +   # See if we can read from the file. If not, just
296 +   # use default site name:
297 +   open($sitefh,"<".$sitefile) ||
298 +      do
299 +         {
300 +         $self->verbose(">> Unable to read a site name definition file. Using \'CERN\' as the site name.");
301 +         return $self->{sitename};
302 +         };
303 +  
304 +   $sitename = <$sitefh>;
305 +   chomp($sitename);
306 +   $self->{sitename} = $sitename;
307 +  
308 +   # Close the file (be tidy!);
309 +   close($sitefile);
310 +   # Return:
311 +   return $self->{sitename};
312 +   }
313 +
314 +
315   sub bootstrapfromlocation {
316          my $self=shift;
317  
# Line 204 | Line 325 | sub bootstrapfromlocation {
325          else {
326           $self->location($location);
327           $self->verbose("Found top ".$self->location());
207         my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat";
328           $self->_LoadEnvFile();
329          }
330          return $rv;
# Line 225 | Line 345 | sub location {
345  
346   sub searchlocation {
347          my $self=shift;
348 <
348 >        
349          #start search in current directory if not specified
350          my $thispath;
351          if ( @_ ) {
# Line 234 | Line 354 | sub searchlocation {
354          else {
355            $thispath=cwd();
356          }
357 <
357 >        
358          my $rv=0;
359  
360          # chop off any files - we only want dirs
# Line 250 | Line 370 | sub searchlocation {
370              last Sloop;
371            }
372          } while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) };
373 <
373 >      
374          return $rv?$thispath:undef;
375   }
376  
# Line 289 | 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
417 <        copy($self->cache()->location(),$sat->cache()->location());
418 <        copy($self->objectstore()->location(),$sat->objectstore()->location());
417 >        # -- make sure we dont try building new caches in release areas
418 >        my $rcache=$self->cache();
419 >        if ( defined $rcache ) {
420 >          copy($rcache->location(),$sat->cache()->location());
421 >        }
422 >
423 >        # -- make sure we dont try building new objectstores in release areas
424 >        my $rostore=$self->objectstore();
425 >        if ( defined $rostore ) {
426 >          copy($rostore->location(),$sat->objectstore()->location());
427 >        }
428  
429          # and make sure in reinitialises
430          undef ($sat->{cache});
# Line 346 | Line 477 | sub align {
477  
478   sub copysetup {
479          my $self=shift;
480 <        my $dest=shift;
350 <
480 >        my $dest=shift;
481          my $rv=1;
482          # copy across the admin dir
483          my $temp=$self->location()."/".$self->{admindir}."/".$self->arch();
# Line 361 | 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 378 | 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 424 | Line 572 | sub _SaveEnvFile {
572          
573          print $fh "SCRAM_PROJECTNAME=".$self->name()."\n";
574          print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n";
575 <        print $fh "projconfigdir=".$self->configurationdir()."\n";
575 >        print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n";
576 >        print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n";
577          print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n";
578 +        print $fh "SCRAM_TOOLBOXVERSION=".$self->{toolboxversion}."\n";
579          if ( defined $self->linkarea() ) {
580            my $area=$self->linkarea()->location();
581            if ( $area ne "" ) {
# Line 436 | Line 586 | sub _SaveEnvFile {
586   }
587  
588  
589 < sub _LoadEnvFile {
590 <        my $self=shift;
591 <
592 <        use FileHandle;
593 <        my $fh=FileHandle->new();
594 <        open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
595 <                "Environment" ) or
596 <                $self->error("Cannot find Environment file. Area Corrupted? ("
597 <                                .$self->location().")\n $!");
598 <        while ( <$fh> ) {
599 <           chomp;
600 <           next if /^#/;
601 <           next if /^\s*$/ ;
602 <           ($name, $value)=split /=/;
603 <           eval "\$self->{ENV}{${name}}=\"$value\"";
604 <        }
605 <        undef $fh;
589 > sub _LoadEnvFile
590 >   {
591 >   my $self=shift;
592 >
593 >   use FileHandle;
594 >   my $fh=FileHandle->new();
595 >   open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
596 >          "Environment" ) or
597 >          $self->error("Cannot find Environment file. Area Corrupted? ("
598 >                       .$self->location().")\n $!");
599 >   while ( <$fh> )
600 >      {
601 >      chomp;
602 >      next if /^#/;
603 >      next if /^\s*$/ ;
604 >      ($name, $value)=split /=/;
605 >      eval "\$self->{ENV}{${name}}=\"$value\"";
606 >      }
607 >   undef $fh;
608          
609 <        # -- set internal variables appropriately
610 <        if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) {
611 <          $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
612 <        }
613 <        if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) {
614 <          $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
615 <        }
616 <        if ( defined $self->{ENV}{"projconfigdir"} ) {
617 <          $self->configurationdir($self->{ENV}{projconfigdir});
618 <        }
619 <        if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) {
620 <          $self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc});
621 <        }
622 <        if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
623 <                        ($self->{ENV}{"RELEASETOP"} ne $self->location())) {
624 <          $self->linkto($self->{ENV}{"RELEASETOP"});
625 <        }
626 <        else {
627 <          $self->{ENV}{"RELEASETOP"}=$self->location();
628 <        }
629 < }
609 >   # -- set internal variables appropriately
610 >   if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} )
611 >      {
612 >      $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
613 >      }
614 >   if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} )
615 >      {
616 >      $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
617 >      }
618 >   if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} )
619 >      {
620 >      $self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"});
621 >      }
622 >   if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} )
623 >      {
624 >      $self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"});
625 >      }
626 >   if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} )
627 >      {
628 >      $self->requirementsdoc($self->{ENV}{"SCRAM_ProjReqsDoc"});
629 >      }
630 >   if ( defined $self->{ENV}{"SCRAM_TOOLBOXVERSION"} )
631 >      {
632 >      $self->toolboxversion($self->{ENV}{"SCRAM_TOOLBOXVERSION"});
633 >      }
634 >  
635 >   if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
636 >        ($self->{ENV}{"RELEASETOP"} ne $self->location()))
637 >      {
638 >      $self->linkto($self->{ENV}{"RELEASETOP"});
639 >      }
640 >   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines