41 |
|
|
42 |
|
=item C<new()> |
43 |
|
|
44 |
< |
Create a new Cache::Cache object. The name of the cache is B<DirCache.db> by default. |
44 |
> |
Create a new Cache::Cache object. The name of the cache is B<DirCache.db.gz> by default. |
45 |
|
|
46 |
|
=cut |
47 |
|
|
60 |
|
my $class=ref($proto) || $proto; |
61 |
|
my $self= |
62 |
|
{ |
63 |
< |
CACHENAME => "DirCache.db", # Name of global file/dir cache; |
63 |
> |
CACHENAME => "DirCache.db.gz", # Name of global file/dir cache; |
64 |
|
BFCACHE => {}, # BuildFile cache; |
65 |
|
DIRCACHE => {}, # Source code cache; |
66 |
|
EXTRASUFFIX => {}, # path with extra suffix; |
232 |
|
} |
233 |
|
|
234 |
|
my $bfcachedir=$ENV{LOCALTOP}."/".$ENV{SCRAM_TMP}."/".$ENV{SCRAM_ARCH}."/cache/bf/${path}"; |
235 |
+ |
my $cbf="${bfcachedir}/$ENV{SCRAM_BUILDFILE}"; |
236 |
|
my $bftime=0; |
237 |
|
my $bf="${path}/$ENV{SCRAM_BUILDFILE}"; |
237 |
– |
if (($self->{convertxml}) && (!-f "${bf}.xml") && (-f "$bf")) |
238 |
– |
{ |
239 |
– |
my $fref; |
240 |
– |
$self->{nonxml} = $self->{nonxml}+1; |
241 |
– |
if (open($fref,">${bf}.xml")) |
242 |
– |
{ |
243 |
– |
print ">> Converting $bf => ${bf}.xml\n"; |
244 |
– |
$self->{convertxml}->clean(); |
245 |
– |
my $xml=$self->{convertxml}->convert($bf); |
246 |
– |
foreach my $line (@$xml){print $fref "$line\n";} |
247 |
– |
close($fref); |
248 |
– |
$self->{convertxml}->clean(); |
249 |
– |
} |
250 |
– |
else |
251 |
– |
{ |
252 |
– |
print STDERR "**** WARNING: Can not open file for writing: ${bf}.xml\n"; |
253 |
– |
} |
254 |
– |
} |
238 |
|
foreach my $ext (".xml","") |
239 |
|
{ |
240 |
|
my $bfn="$bf$ext"; |
244 |
|
{ |
245 |
|
$self->{REMOVEDBF}{$bfn}=1; |
246 |
|
delete $self->{BFCACHE}{$bfn}; |
247 |
< |
AddDir::adddir($bfcachedir); |
248 |
< |
open(BF,">${bfcachedir}/$ENV{SCRAM_BUILDFILE}");close(BF); |
247 |
> |
Utilities::AddDir::adddir($bfcachedir); |
248 |
> |
open(BF,">${cbf}");close(BF); |
249 |
|
$self->cachestatus(1); |
250 |
|
} |
251 |
|
} |
255 |
|
if ((! exists $self->{BFCACHE}{$bfn}) || |
256 |
|
($bftime != $self->{BFCACHE}{$bfn})) |
257 |
|
{ |
258 |
< |
AddDir::adddir($bfcachedir); |
259 |
< |
open(BF,">${bfcachedir}/$ENV{SCRAM_BUILDFILE}");close(BF); |
260 |
< |
$self->{ADDEDBF}{$bfn}=1; |
261 |
< |
delete $self->{BFCACHE}{"${path}/$ENV{SCRAM_BUILDFILE}"}; |
258 |
> |
if ((!-f "${cbf}") || (exists $self->{BFCACHE}{$bfn})) |
259 |
> |
{ |
260 |
> |
Utilities::AddDir::adddir($bfcachedir); |
261 |
> |
open(BF,">${cbf}");close(BF); |
262 |
> |
} |
263 |
> |
$self->{ADDEDBF}{$bfn}=1; |
264 |
> |
delete $self->{BFCACHE}{$bf}; |
265 |
|
$self->{BFCACHE}{$bfn}=$bftime; |
266 |
|
if ($ext eq ""){$self->{nonxml}+=1;} |
267 |
|
$self->cachestatus(1); |
270 |
|
{ |
271 |
|
$self->{ADDEDBF}{$bfn}=1; |
272 |
|
if ($ext eq ""){$self->{nonxml}+=1;} |
273 |
< |
if (!-f "${bfcachedir}/$ENV{SCRAM_BUILDFILE}") |
273 |
> |
if (!-f "${cbf}") |
274 |
|
{ |
275 |
< |
AddDir::adddir($bfcachedir); |
276 |
< |
open(BF,">${bfcachedir}/$ENV{SCRAM_BUILDFILE}");close(BF); |
275 |
> |
Utilities::AddDir::adddir($bfcachedir); |
276 |
> |
open(BF,">${cbf}");close(BF); |
277 |
|
} |
278 |
|
$self->cachestatus(1); |
279 |
|
} |
280 |
|
last; |
281 |
|
} |
282 |
|
} |
283 |
+ |
if (exists $self->{ExtraDirCache}) |
284 |
+ |
{ |
285 |
+ |
eval {$self->{ExtraDirCache}->DirCache($self,$path);}; |
286 |
+ |
} |
287 |
|
# Process sub-directories |
288 |
|
foreach my $item (@items) |
289 |
|
{ |
342 |
|
{ |
343 |
|
my $self=shift; |
344 |
|
$self->{cachereset}=shift || 0; |
355 |
– |
$self->{convertxml}=shift || 0; |
345 |
|
# Scan config dir for top-level data, then start from src: |
346 |
|
my @scandirs=($ENV{SCRAM_CONFIGDIR}, $ENV{SCRAM_SOURCEDIR}); |
347 |
|
# Loop over all directories that need scanning (normally just src and config): |
359 |
– |
if ($self->{convertxml}) |
360 |
– |
{ |
361 |
– |
eval ("use SCRAM::Doc2XML"); |
362 |
– |
if (!$@) |
363 |
– |
{ |
364 |
– |
$self->{convertxml} = SCRAM::Doc2XML->new(); |
365 |
– |
} |
366 |
– |
else |
367 |
– |
{ |
368 |
– |
print STDERR "**** WARNING: Can not convert $ENV{SCRAM_BUILDFILE} in to XML format. Missing SCRAM::Doc2XML perl module.\n"; |
369 |
– |
} |
370 |
– |
} |
348 |
|
$self->{nonxml}=0; |
349 |
+ |
eval ("use SCRAM::Plugins::DirCache;"); |
350 |
+ |
if(!$@) {$self->{ExtraDirCache} = SCRAM::Plugins::DirCache->new();} |
351 |
|
foreach my $scand (@scandirs) |
352 |
|
{ |
353 |
|
$self->logmsg("SCRAM: Scanning $scand [dofiles set to ".$dofiles."]\n"); |
365 |
|
} |
366 |
|
} |
367 |
|
} |
368 |
+ |
delete $self->{ExtraDirCache}; |
369 |
|
if ($self->{nonxml} > 0) |
370 |
|
{ |
371 |
< |
print STDERR "**** WARNING: ",$self->{nonxml}," non-xml based $ENV{SCRAM_BUILDFILE} were read.\n"; |
371 |
> |
#print STDERR "**** WARNING: ",$self->{nonxml}," non-xml based $ENV{SCRAM_BUILDFILE} were read.\n"; |
372 |
|
} |
373 |
|
return $self; |
374 |
|
} |
599 |
|
=item C<name()> |
600 |
|
|
601 |
|
Set or return the name of the cache. Normally set |
602 |
< |
to B<DirCache.db> (and not architecture dependent). |
602 |
> |
to B<DirCache.db.gz> (and not architecture dependent). |
603 |
|
|
604 |
|
=cut |
605 |
|
|