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.17 by williamc, Thu Sep 21 14:25:06 2000 UTC vs.
Revision 1.23 by sashby, Fri Dec 10 13:41:40 2004 UTC

# Line 37 | Line 37
37   # save()                        : save changes permanently
38   # linkto(location)              : link the current area to that at location
39   # unlinkarea()                  : destroy link (autosave)
40 < # linkarea([ConfigArea])        : get/set a link from the current area to the apec Area Object
40 > # linkarea([ConfigArea])        : link the current area to the apec Area Object
41   # archname()            : get/set a string to indicate architecture
42   # archdir()             : return the location of the administration arch dep
43   #                         directory
44 < # objectstore(["<"])            : return the objectStore object of the area
45 < #                                 if called with temp - will set as undef
46 < #                                 if it dosnt already exist - otherwise will
47 < #                                 attempt to create it.
44 > # objectstore()         : return the objectStore object of the area
45   # - temporary
46   # align()                       : adjust hard paths to suit local loaction
47  
# Line 66 | 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 74 | Line 72 | sub new {
72   sub cache {
73          my $self=shift;
74  
77        my $exist=0;
75          if ( @_ ) {
76 <          my $cache=shift;
80 <          if ( $cache!~/^</ ) {
81 <            $self->{cache}=$cache;
82 <          }
83 <          $exist=1;
76 >           $self->{cache}=shift;
77          }
78          if ( ! defined $self->{cache} ) {
79            my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
80 <          if (  !$exist || ( -e $loc ) ) {
80 >          if ( -e $loc  ) {
81              $self->{cache}=URL::URLcache->new($loc);
82            }
83            else {
# Line 94 | 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};
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  
100        my $exist="";
135          if ( @_ ) {
136 <          my $db=shift;
103 <          if ( $db!~/^</ ) {
104 <            $self->{dbstore}=cache;
105 <          }
106 <          $exist="<";
136 >            $self->{dbstore}=shift;
137          }
138          if ( ! defined $self->{dbstore} ) {
139            my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir};
140 <          $self->{dbstore}=ObjectUtilities::ObjectStore->new($exist.$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 132 | 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 157 | 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 172 | 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 211 | 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 224 | Line 325 | sub bootstrapfromlocation {
325          else {
326           $self->location($location);
327           $self->verbose("Found top ".$self->location());
227         my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat";
328           $self->_LoadEnvFile();
329          }
330          return $rv;
# Line 245 | 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 254 | 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 270 | Line 370 | sub searchlocation {
370              last Sloop;
371            }
372          } while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) };
373 <
373 >      
374          return $rv?$thispath:undef;
375   }
376  
# Line 309 | 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          # -- make sure we dont try building new caches in release areas
418 <        my $rcache=$self->cache("<");
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("<");
424 >        my $rostore=$self->objectstore();
425          if ( defined $rostore ) {
426            copy($rostore->location(),$sat->objectstore()->location());
427          }
# Line 407 | Line 509 | sub arch {
509   sub linkto {
510          my $self=shift;
511          my $location=shift;
512 +
513          if ( -d $location ) {
514          my $area=Configuration::ConfigArea->new();
515          $area->bootstrapfromlocation($location);
# Line 453 | Line 556 | sub _SaveEnvFile {
556          
557          print $fh "SCRAM_PROJECTNAME=".$self->name()."\n";
558          print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n";
559 <        print $fh "projconfigdir=".$self->configurationdir()."\n";
559 >        print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n";
560 >        print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n";
561          print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n";
562 +        print $fh "SCRAM_TOOLBOXVERSION=".$self->{toolboxversion}."\n";
563          if ( defined $self->linkarea() ) {
564            my $area=$self->linkarea()->location();
565            if ( $area ne "" ) {
# Line 465 | Line 570 | sub _SaveEnvFile {
570   }
571  
572  
573 < sub _LoadEnvFile {
574 <        my $self=shift;
575 <
576 <        use FileHandle;
577 <        my $fh=FileHandle->new();
578 <        open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
579 <                "Environment" ) or
580 <                $self->error("Cannot find Environment file. Area Corrupted? ("
581 <                                .$self->location().")\n $!");
582 <        while ( <$fh> ) {
583 <           chomp;
584 <           next if /^#/;
585 <           next if /^\s*$/ ;
586 <           ($name, $value)=split /=/;
587 <           eval "\$self->{ENV}{${name}}=\"$value\"";
588 <        }
589 <        undef $fh;
573 > sub _LoadEnvFile
574 >   {
575 >   my $self=shift;
576 >
577 >   use FileHandle;
578 >   my $fh=FileHandle->new();
579 >   open ( $fh, "<".$self->location()."/".$self->{admindir}."/".
580 >          "Environment" ) or
581 >          $self->error("Cannot find Environment file. Area Corrupted? ("
582 >                       .$self->location().")\n $!");
583 >   while ( <$fh> )
584 >      {
585 >      chomp;
586 >      next if /^#/;
587 >      next if /^\s*$/ ;
588 >      ($name, $value)=split /=/;
589 >      eval "\$self->{ENV}{${name}}=\"$value\"";
590 >      }
591 >   undef $fh;
592          
593 <        # -- set internal variables appropriately
594 <        if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) {
595 <          $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
596 <        }
597 <        if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) {
598 <          $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
599 <        }
600 <        if ( defined $self->{ENV}{"projconfigdir"} ) {
601 <          $self->configurationdir($self->{ENV}{projconfigdir});
602 <        }
603 <        if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) {
604 <          $self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc});
605 <        }
606 <        if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
607 <                        ($self->{ENV}{"RELEASETOP"} ne $self->location())) {
608 <          $self->linkto($self->{ENV}{"RELEASETOP"});
609 <        }
610 <        else {
611 <          $self->{ENV}{"RELEASETOP"}=$self->location();
612 <        }
613 < }
593 >   # -- set internal variables appropriately
594 >   if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} )
595 >      {
596 >      $self->name($self->{ENV}{"SCRAM_PROJECTNAME"});
597 >      }
598 >   if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} )
599 >      {
600 >      $self->version($self->{ENV}{"SCRAM_PROJECTVERSION"});
601 >      }
602 >   if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} )
603 >      {
604 >      $self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"});
605 >      }
606 >   if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} )
607 >      {
608 >      $self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"});
609 >      }
610 >   if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} )
611 >      {
612 >      $self->requirementsdoc($self->{ENV}{"SCRAM_ProjReqsDoc"});
613 >      }
614 >   if ( defined $self->{ENV}{"SCRAM_TOOLBOXVERSION"} )
615 >      {
616 >      $self->toolboxversion($self->{ENV}{"SCRAM_TOOLBOXVERSION"});
617 >      }
618 >  
619 >   if ( ( defined $self->{ENV}{"RELEASETOP"} ) &&
620 >        ($self->{ENV}{"RELEASETOP"} ne $self->location()))
621 >      {
622 >      $self->linkto($self->{ENV}{"RELEASETOP"});
623 >      }
624 >   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines