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 |
|
|
63 |
|
$self->{admindir}=".SCRAM"; |
64 |
|
$self->{cachedir}="cache"; |
65 |
|
$self->{dbdir}="ObjectDB"; |
66 |
+ |
$self->{tbupdate}=0; |
67 |
|
undef $self->{linkarea}; |
68 |
|
|
69 |
|
return $self; |
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 |
< |
elsif ( ! defined $self->{cache} ) { |
78 |
> |
if ( ! defined $self->{cache} ) { |
79 |
|
my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir}; |
80 |
< |
if ( ! $exist ) { |
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 |
|
|
97 |
– |
my $exist=""; |
135 |
|
if ( @_ ) { |
136 |
< |
my $db=shift; |
100 |
< |
if ( $db!~/^</ ) { |
101 |
< |
$self->{dbstore}=cache; |
102 |
< |
} |
103 |
< |
$exist="<"; |
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($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 |
|
} |
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 |
|
} |
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(); |
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 ( @_ ) { |
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 |
|
|
325 |
|
else { |
326 |
|
$self->location($location); |
327 |
|
$self->verbose("Found top ".$self->location()); |
224 |
– |
my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat"; |
328 |
|
$self->_LoadEnvFile(); |
329 |
|
} |
330 |
|
return $rv; |
345 |
|
|
346 |
|
sub searchlocation { |
347 |
|
my $self=shift; |
348 |
< |
|
348 |
> |
|
349 |
|
#start search in current directory if not specified |
350 |
|
my $thispath; |
351 |
|
if ( @_ ) { |
354 |
|
else { |
355 |
|
$thispath=cwd(); |
356 |
|
} |
357 |
< |
|
357 |
> |
|
358 |
|
my $rv=0; |
359 |
|
|
360 |
|
# chop off any files - we only want dirs |
370 |
|
last Sloop; |
371 |
|
} |
372 |
|
} while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) }; |
373 |
< |
|
373 |
> |
|
374 |
|
return $rv?$thispath:undef; |
375 |
|
} |
376 |
|
|
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 |
|
} |
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); |
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 "" ) { |
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 |
> |
} |