63 |
|
$self->{admindir}=".SCRAM"; |
64 |
|
$self->{cachedir}="cache"; |
65 |
|
$self->{dbdir}="ObjectDB"; |
66 |
+ |
$self->{tbupdate}=0; |
67 |
|
undef $self->{linkarea}; |
68 |
|
|
69 |
|
return $self; |
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}; |
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 |
|
} |
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} ) { |
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()); |
236 |
– |
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 |
477 |
|
|
478 |
|
sub copysetup { |
479 |
|
my $self=shift; |
480 |
< |
my $dest=shift; |
388 |
< |
|
480 |
> |
my $dest=shift; |
481 |
|
my $rv=1; |
482 |
|
# copy across the admin dir |
483 |
|
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
491 |
|
return $rv; |
492 |
|
} |
493 |
|
|
494 |
+ |
sub copyurlcache { |
495 |
+ |
my $self=shift; |
496 |
+ |
my $dest=shift; |
497 |
+ |
my $rv=1; |
498 |
+ |
# copy across the admin dir |
499 |
+ |
my $temp=$self->location()."/".$self->{admindir}."/cache"; |
500 |
+ |
my $temp2=$dest."/".$self->{admindir}."/cache"; |
501 |
+ |
if ( $temp ne $temp2 ) { |
502 |
+ |
if ( -d $temp ) { |
503 |
+ |
AddDir::copydir($temp,$temp2); |
504 |
+ |
$rv=0; |
505 |
+ |
} |
506 |
+ |
} |
507 |
+ |
return $rv; |
508 |
+ |
} |
509 |
+ |
|
510 |
+ |
sub copywithskip { |
511 |
+ |
my $self=shift; |
512 |
+ |
my $dest=shift; |
513 |
+ |
my ($filetoskip)=@_; |
514 |
+ |
my $rv=1; |
515 |
+ |
# copy across the admin dir |
516 |
+ |
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
517 |
+ |
my $temp2=$dest."/".$self->{admindir}."/".$self->arch(); |
518 |
+ |
if ( $temp ne $temp2 ) { |
519 |
+ |
if ( -d $temp ) { |
520 |
+ |
AddDir::copydirwithskip($temp,$temp2,$filetoskip); |
521 |
+ |
$rv=0; |
522 |
+ |
} |
523 |
+ |
} |
524 |
+ |
return $rv; |
525 |
+ |
} |
526 |
+ |
|
527 |
|
sub copyenv { |
528 |
|
my $self=shift; |
529 |
|
my $hashref=shift; |
541 |
|
sub linkto { |
542 |
|
my $self=shift; |
543 |
|
my $location=shift; |
544 |
+ |
|
545 |
|
if ( -d $location ) { |
546 |
|
my $area=Configuration::ConfigArea->new(); |
547 |
|
$area->bootstrapfromlocation($location); |
575 |
|
$self->_SaveEnvFile(); |
576 |
|
} |
577 |
|
|
578 |
+ |
sub reqdoc() |
579 |
+ |
{ |
580 |
+ |
my $self=shift; |
581 |
+ |
my ($path)=@_; |
582 |
+ |
return $path."/".$self->{reqdoc}; |
583 |
+ |
} |
584 |
+ |
|
585 |
+ |
sub creationtime() |
586 |
+ |
{ |
587 |
+ |
my $self=shift; |
588 |
+ |
my ($location)= @_; |
589 |
+ |
$location||=$self->location(); |
590 |
+ |
my $requirementsdoc = $self->reqdoc($location); |
591 |
+ |
my ($mode, $time) = (stat($requirementsdoc))[2, 9]; |
592 |
+ |
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); |
593 |
+ |
|
594 |
+ |
($sec < 10) ? ($sec = "0".$sec) : $sec; |
595 |
+ |
($min < 10) ? ($min = "0".$min) : $min; |
596 |
+ |
|
597 |
+ |
$year += 1900; |
598 |
+ |
my $months = |
599 |
+ |
{ |
600 |
+ |
0 => "Jan", 1 => "Feb", |
601 |
+ |
2 => "Mar", 3 => "Apr", |
602 |
+ |
4 => "May", 5 => "Jun", |
603 |
+ |
6 => "Jul", 7 => "Aug", |
604 |
+ |
8 => "Sept", 9 => "Oct", |
605 |
+ |
10 => "Nov", 11 => "Dec" }; |
606 |
+ |
|
607 |
+ |
my $days = { 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat", 7 => "Sun"}; |
608 |
+ |
|
609 |
+ |
# Return the timestamp (as string) of the requirementsdoc: |
610 |
+ |
return $days->{$wday}."-".$mday."-".$months->{$mon}."-".$year." ".$hour.":".$min.":".$sec; |
611 |
+ |
} |
612 |
+ |
|
613 |
|
# ---- support routines |
614 |
|
|
615 |
< |
sub _SaveEnvFile { |
616 |
< |
my $self=shift; |
617 |
< |
use FileHandle; |
618 |
< |
my $fh=FileHandle->new(); |
619 |
< |
open ( $fh, ">".$self->location()."/".$self->{admindir}."/". |
620 |
< |
"Environment" ) or |
621 |
< |
$self->error("Cannot Open Environment file to Save (" |
622 |
< |
.$self->location().")\n $!"); |
615 |
> |
sub _SaveEnvFile |
616 |
> |
{ |
617 |
> |
my $self=shift; |
618 |
> |
my $filemode = 0644; |
619 |
> |
|
620 |
> |
use FileHandle; |
621 |
> |
my $fh=FileHandle->new(); |
622 |
> |
open ( $fh, ">".$self->location()."/".$self->{admindir}."/". |
623 |
> |
"Environment" ) or |
624 |
> |
$self->error("Cannot Open Environment file to Save (" |
625 |
> |
.$self->location().")\n $!"); |
626 |
|
|
627 |
< |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
628 |
< |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
629 |
< |
print $fh "projconfigdir=".$self->configurationdir()."\n"; |
630 |
< |
print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n"; |
631 |
< |
if ( defined $self->linkarea() ) { |
632 |
< |
my $area=$self->linkarea()->location(); |
633 |
< |
if ( $area ne "" ) { |
634 |
< |
print $fh "RELEASETOP=".$area."\n"; |
635 |
< |
} |
636 |
< |
} |
637 |
< |
undef $fh; |
638 |
< |
} |
639 |
< |
|
640 |
< |
|
641 |
< |
sub _LoadEnvFile { |
642 |
< |
my $self=shift; |
643 |
< |
|
644 |
< |
use FileHandle; |
645 |
< |
my $fh=FileHandle->new(); |
646 |
< |
open ( $fh, "<".$self->location()."/".$self->{admindir}."/". |
647 |
< |
"Environment" ) or |
648 |
< |
$self->error("Cannot find Environment file. Area Corrupted? (" |
649 |
< |
.$self->location().")\n $!"); |
650 |
< |
while ( <$fh> ) { |
651 |
< |
chomp; |
652 |
< |
next if /^#/; |
653 |
< |
next if /^\s*$/ ; |
654 |
< |
($name, $value)=split /=/; |
655 |
< |
eval "\$self->{ENV}{${name}}=\"$value\""; |
656 |
< |
} |
657 |
< |
undef $fh; |
627 |
> |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
628 |
> |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
629 |
> |
print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n"; |
630 |
> |
print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n"; |
631 |
> |
print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n"; |
632 |
> |
print $fh "SCRAM_TOOLBOXVERSION=".$self->{toolboxversion}."\n"; |
633 |
> |
|
634 |
> |
if ( defined $self->linkarea() ) |
635 |
> |
{ |
636 |
> |
my $area=$self->linkarea()->location(); |
637 |
> |
if ( $area ne "" ) |
638 |
> |
{ |
639 |
> |
print $fh "RELEASETOP=".$area."\n"; |
640 |
> |
} |
641 |
> |
} |
642 |
> |
|
643 |
> |
undef $fh; |
644 |
> |
|
645 |
> |
# Set the default permissions (-rw-r--r--): |
646 |
> |
chmod $filemode, $self->location()."/".$self->{admindir}."/Environment"; |
647 |
> |
} |
648 |
> |
|
649 |
> |
sub _LoadEnvFile |
650 |
> |
{ |
651 |
> |
my $self=shift; |
652 |
> |
|
653 |
> |
use FileHandle; |
654 |
> |
my $fh=FileHandle->new(); |
655 |
> |
open ( $fh, "<".$self->location()."/".$self->{admindir}."/". |
656 |
> |
"Environment" ) or |
657 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
658 |
> |
.$self->location().")\n $!"); |
659 |
> |
while ( <$fh> ) |
660 |
> |
{ |
661 |
> |
chomp; |
662 |
> |
next if /^#/; |
663 |
> |
next if /^\s*$/ ; |
664 |
> |
($name, $value)=split /=/; |
665 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
666 |
> |
} |
667 |
> |
undef $fh; |
668 |
|
|
669 |
< |
# -- set internal variables appropriately |
670 |
< |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) { |
671 |
< |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
672 |
< |
} |
673 |
< |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) { |
674 |
< |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
675 |
< |
} |
676 |
< |
if ( defined $self->{ENV}{"projconfigdir"} ) { |
677 |
< |
$self->configurationdir($self->{ENV}{projconfigdir}); |
678 |
< |
} |
679 |
< |
if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) { |
680 |
< |
$self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc}); |
681 |
< |
} |
682 |
< |
if ( ( defined $self->{ENV}{"RELEASETOP"} ) && |
683 |
< |
($self->{ENV}{"RELEASETOP"} ne $self->location())) { |
684 |
< |
$self->linkto($self->{ENV}{"RELEASETOP"}); |
685 |
< |
} |
686 |
< |
else { |
687 |
< |
$self->{ENV}{"RELEASETOP"}=$self->location(); |
688 |
< |
} |
689 |
< |
} |
669 |
> |
# -- set internal variables appropriately |
670 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) |
671 |
> |
{ |
672 |
> |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
673 |
> |
} |
674 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) |
675 |
> |
{ |
676 |
> |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
677 |
> |
} |
678 |
> |
if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} ) |
679 |
> |
{ |
680 |
> |
$self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"}); |
681 |
> |
} |
682 |
> |
if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} ) |
683 |
> |
{ |
684 |
> |
$self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"}); |
685 |
> |
} |
686 |
> |
if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) |
687 |
> |
{ |
688 |
> |
$self->requirementsdoc($self->{ENV}{"SCRAM_ProjReqsDoc"}); |
689 |
> |
} |
690 |
> |
if ( defined $self->{ENV}{"SCRAM_TOOLBOXVERSION"} ) |
691 |
> |
{ |
692 |
> |
$self->toolboxversion($self->{ENV}{"SCRAM_TOOLBOXVERSION"}); |
693 |
> |
} |
694 |
> |
|
695 |
> |
if ( ( defined $self->{ENV}{"RELEASETOP"} ) && |
696 |
> |
($self->{ENV}{"RELEASETOP"} ne $self->location())) |
697 |
> |
{ |
698 |
> |
$self->linkto($self->{ENV}{"RELEASETOP"}); |
699 |
> |
} |
700 |
> |
} |