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.21 by sashby, Mon Dec 3 19:02:05 2001 UTC

# Line 70 | Line 70 | sub new {
70  
71   sub cache {
72          my $self=shift;
73 +
74          if ( @_ ) {
75 <          $self->{cache}=shift;
75 >           $self->{cache}=shift;
76          }
77 <        elsif ( ! defined $self->{cache} ) {
77 >        if ( ! defined $self->{cache} ) {
78            my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
79 <          $self->{cache}=URL::URLcache->new($loc);
79 >          if ( -e $loc  ) {
80 >            $self->{cache}=URL::URLcache->new($loc);
81 >          }
82 >          else {
83 >            $self->{cache}=undef;
84 >          }
85          }
86          return $self->{cache};
87   }
88  
89 + sub _newcache {
90 +        my $self=shift;
91 +        my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
92 +        $self->{cache}=URL::URLcache->new($loc);
93 +        return $self->{cache};
94 + }
95 +
96 + sub _newobjectstore {
97 +        my $self=shift;
98 +        my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir};
99 +        $self->{dbstore}=ObjectUtilities::ObjectStore->new($loc);
100 +        return $self->{dbstore};
101 + }
102 +
103   sub objectstore {
104          my $self=shift;
105 +
106          if ( @_ ) {
107 <          $self->{dbstore}=shift;
107 >            $self->{dbstore}=shift;
108          }
109 <        elsif ( ! defined $self->{dbstore} ) {
109 >        if ( ! defined $self->{dbstore} ) {
110            my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir};
111 <          $self->{dbstore}=ObjectUtilities::ObjectStore->new($loc);
111 >          if ( -e $loc ) {
112 >            $self->{dbstore}=ObjectUtilities::ObjectStore->new($loc);
113 >          }
114 >          else {
115 >            $self->{dbstore}=undef;
116 >          }
117          }
118          return $self->{dbstore}
119   }
# Line 137 | Line 163 | sub setup {
163          AddDir::adddir($workloc);
164  
165          # -- add a cache
166 <        $self->cache();
166 >        $self->_newcache();
167 >
168 >        # -- add an Objectstore
169 >        $self->_newobjectstore();
170  
171          # -- Save Environment File
172          $self->_SaveEnvFile();
# Line 155 | Line 184 | sub configurationdir {
184   sub toolbox {
185          my $self=shift;
186          if ( ! defined $self->{toolbox} ) {
187 <          $self->{toolbox}=BuildSystem::ToolBox->new($self);
187 >          $self->{toolbox}=BuildSystem::ToolBox->new($self, $ENV{SCRAM_ARCH});
188          }
189          return $self->{toolbox};
190   }
# Line 191 | Line 220 | sub scramversion {
220          return $self->{scramversion};
221   }
222  
223 + sub sitename
224 +   {
225 +   ###############################################################
226 +   # sitename()                                                  #
227 +   ###############################################################
228 +   # modified : Mon Dec  3 15:45:35 2001 / SFA                   #
229 +   # params   :                                                  #
230 +   #          :                                                  #
231 +   #          :                                                  #
232 +   #          :                                                  #
233 +   # function : Read the site name from config/site/sitename and #
234 +   #          : export it.                                       #
235 +   #          :                                                  #
236 +   #          :                                                  #
237 +   ###############################################################
238 +   my $self = shift;
239 +   my $sitefile = $self->location()."/".$self->configurationdir()."/site/sitename";
240 +
241 +   $self->{sitename} = 'CERN'; # Use CERN as the default site name
242 +
243 +   use FileHandle;
244 +   my $sitefh = FileHandle->new();
245 +  
246 +   # See if we can read from the file. If not, just
247 +   # use default site name:
248 +   open($sitefh,"<".$sitefile) ||
249 +      do
250 +         {
251 +         $self->verbose("Unable to read a site name definition file. Using \'CERN\' as the site name.");
252 +         return $self->{sitename};
253 +         };
254 +  
255 +   $sitename = <$sitefh>;
256 +   chomp($sitename);
257 +   $self->{sitename} = $sitename;
258 +  
259 +   # Close the file (be tidy!);
260 +   close($sitefile);
261 +   # Return:
262 +   return $self->{sitename};
263 +   }
264 +
265 +
266   sub bootstrapfromlocation {
267          my $self=shift;
268  
# Line 225 | Line 297 | sub location {
297  
298   sub searchlocation {
299          my $self=shift;
300 <
300 >        
301          #start search in current directory if not specified
302          my $thispath;
303          if ( @_ ) {
# Line 234 | Line 306 | sub searchlocation {
306          else {
307            $thispath=cwd();
308          }
309 <
309 >        
310          my $rv=0;
311  
312          # chop off any files - we only want dirs
# Line 250 | Line 322 | sub searchlocation {
322              last Sloop;
323            }
324          } while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) };
325 <
325 >      
326          return $rv?$thispath:undef;
327   }
328  
# Line 292 | Line 364 | sub satellite {
364          $sat->setup(@_);
365  
366          # -- copy across the cache and ObjectStore
367 <        copy($self->cache()->location(),$sat->cache()->location());
368 <        copy($self->objectstore()->location(),$sat->objectstore()->location());
367 >        # -- make sure we dont try building new caches in release areas
368 >        my $rcache=$self->cache();
369 >        if ( defined $rcache ) {
370 >          copy($rcache->location(),$sat->cache()->location());
371 >        }
372 >
373 >        # -- make sure we dont try building new objectstores in release areas
374 >        my $rostore=$self->objectstore();
375 >        if ( defined $rostore ) {
376 >          copy($rostore->location(),$sat->objectstore()->location());
377 >        }
378  
379          # and make sure in reinitialises
380          undef ($sat->{cache});

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines