1 |
– |
# |
2 |
– |
# ConfigArea.pm |
3 |
– |
# |
4 |
– |
# Written by Christopher Williams |
5 |
– |
# |
6 |
– |
# Description |
7 |
– |
# ----------- |
8 |
– |
# creates and manages a configuration area |
9 |
– |
# |
10 |
– |
# Notes |
11 |
– |
# ------- |
12 |
– |
# Persistency - remember to call the save method to make changes persistent |
13 |
– |
# |
14 |
– |
# Interface |
15 |
– |
# --------- |
16 |
– |
# new() : A new ConfigArea object |
17 |
– |
# name() : get/set project name |
18 |
– |
# setup(dir[,areaname]) : setup a fresh area in dir |
19 |
– |
# satellite(dir[,areaname]) : setup a satellite area in dir |
20 |
– |
# version() : get/set project version |
21 |
– |
# location([dir]) : set/return the location of the work area |
22 |
– |
# bootstrapfromlocation([location]) : bootstrap the object based on location. |
23 |
– |
# no location specified - cwd used |
24 |
– |
# return 0 if succesful 1 otherwise |
25 |
– |
# requirementsdoc() : get set the requirements doc |
26 |
– |
# searchlocation([startdir]) : returns the location directory. search starts |
27 |
– |
# from cwd if not specified |
28 |
– |
# scramversion() : return the scram version associated with |
29 |
– |
# area |
30 |
– |
# configurationdir() : return the location of the project |
31 |
– |
# configuration directory |
32 |
– |
# copy(location) : copy a configuration |
33 |
– |
# copysetup(location) : copy the architecture specific tool setup |
34 |
– |
# returns 0 if successful, 1 otherwise |
35 |
– |
# copyenv($ref) : copy the areas environment into the hashref |
36 |
– |
# toolbox() : return the areas toolbox object |
37 |
– |
# save() : save changes permanently |
38 |
– |
# linkto(location) : link the current area to that at location |
39 |
– |
# unlinkarea() : destroy link (autosave) |
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 |
– |
# - temporary |
46 |
– |
# align() : adjust hard paths to suit local loaction |
47 |
– |
|
1 |
|
package Configuration::ConfigArea; |
2 |
|
require 5.004; |
50 |
– |
use URL::URLcache; |
3 |
|
use Utilities::AddDir; |
4 |
|
use Utilities::Verbose; |
53 |
– |
use ObjectUtilities::ObjectStore; |
5 |
|
use Cwd; |
6 |
|
@ISA=qw(Utilities::Verbose); |
7 |
|
|
9 |
|
my $class=shift; |
10 |
|
my $self={}; |
11 |
|
bless $self, $class; |
61 |
– |
|
62 |
– |
# data init |
12 |
|
$self->{admindir}=".SCRAM"; |
13 |
< |
$self->{cachedir}="cache"; |
14 |
< |
$self->{dbdir}="ObjectDB"; |
66 |
< |
undef $self->{linkarea}; |
67 |
< |
|
13 |
> |
$self->{configurationdir} = "config"; |
14 |
> |
$self->archname($ENV{SCRAM_ARCH}); |
15 |
|
return $self; |
16 |
|
} |
17 |
|
|
18 |
< |
sub cache { |
19 |
< |
my $self=shift; |
18 |
> |
sub toolcachename |
19 |
> |
{ |
20 |
> |
my $self=shift; |
21 |
> |
return ($self->archdir()."/ToolCache.db.gz"); |
22 |
> |
} |
23 |
|
|
24 |
< |
if ( @_ ) { |
25 |
< |
$self->{cache}=shift; |
26 |
< |
} |
27 |
< |
if ( ! defined $self->{cache} ) { |
28 |
< |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir}; |
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 |
< |
} |
24 |
> |
sub projectcachename |
25 |
> |
{ |
26 |
> |
my $self=shift; |
27 |
> |
return ($self->archdir()."/ProjectCache.db.gz"); |
28 |
> |
} |
29 |
|
|
30 |
< |
sub _newcache { |
30 |
> |
sub symlinks { |
31 |
|
my $self=shift; |
32 |
< |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir}; |
33 |
< |
$self->{cache}=URL::URLcache->new($loc); |
93 |
< |
return $self->{cache}; |
32 |
> |
if (@_) {$self->{symlinks}=shift;} |
33 |
> |
return $self->{symlinks}; |
34 |
|
} |
35 |
|
|
36 |
< |
sub _newobjectstore { |
37 |
< |
my $self=shift; |
38 |
< |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir}; |
39 |
< |
$self->{dbstore}=ObjectUtilities::ObjectStore->new($loc); |
40 |
< |
return $self->{dbstore}; |
36 |
> |
sub calchksum { |
37 |
> |
my $self=shift; |
38 |
> |
my $dir=$self->location()."/".$self->configurationdir(); |
39 |
> |
push @INC,$dir; |
40 |
> |
require SCRAM::Plugins::ProjectChkSum; |
41 |
> |
my $sum=&SCRAM::Plugins::ProjectChkSum::chksum($dir); |
42 |
> |
pop @INC; |
43 |
> |
return $sum; |
44 |
|
} |
45 |
|
|
46 |
< |
sub objectstore { |
46 |
> |
sub configchksum { |
47 |
|
my $self=shift; |
48 |
< |
|
49 |
< |
if ( @_ ) { |
107 |
< |
$self->{dbstore}=shift; |
108 |
< |
} |
109 |
< |
if ( ! defined $self->{dbstore} ) { |
110 |
< |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir}; |
111 |
< |
if ( -e $loc ) { |
112 |
< |
$self->{dbstore}=ObjectUtilities::ObjectStore->new($loc); |
113 |
< |
} |
114 |
< |
else { |
115 |
< |
$self->{dbstore}=undef; |
116 |
< |
} |
117 |
< |
} |
118 |
< |
return $self->{dbstore} |
48 |
> |
if (@_) {$self->{configchksum}=shift;} |
49 |
> |
return $self->{configchksum}; |
50 |
|
} |
51 |
|
|
52 |
+ |
|
53 |
|
sub name { |
54 |
|
my $self=shift; |
55 |
|
@_?$self->{name}=shift |
65 |
|
sub setup { |
66 |
|
my $self=shift; |
67 |
|
my $location=shift; |
68 |
< |
my $areaname; |
69 |
< |
|
70 |
< |
# -- check we have a project name and version |
139 |
< |
my $name=$self->name(); |
140 |
< |
my $vers=$self->version(); |
141 |
< |
if ( ( ! defined $name ) && ( ! defined $version )) { |
142 |
< |
$self->error("Set ConfigArea name and version before setup"); |
143 |
< |
} |
144 |
< |
|
145 |
< |
# -- check arguments and set location |
146 |
< |
if ( ! defined $location ) { |
147 |
< |
$self->error("ConfigArea: Cannot setup new area without a location"); |
148 |
< |
} |
149 |
< |
if ( @_ ) { |
150 |
< |
$areaname=shift; |
151 |
< |
} |
68 |
> |
my $areaname=shift || undef; |
69 |
> |
my $symlinks=shift || 0; |
70 |
> |
my $locarea = shift || undef; |
71 |
|
if ( (! defined $areaname) || ( $areaname eq "" ) ) { |
72 |
< |
# -- make up a name from the project name and version |
154 |
< |
$vers=~s/^$name\_//; |
155 |
< |
$areaname=$name."_".$vers; |
72 |
> |
$areaname=$self->version(); |
73 |
|
} |
74 |
< |
my $arealoc=$location."/".$areaname; |
75 |
< |
my $workloc=$arealoc."/".$self->{admindir}; |
76 |
< |
$self->verbose("Building at $arealoc"); |
77 |
< |
$self->location($arealoc); |
78 |
< |
|
79 |
< |
# -- create top level structure and work area |
80 |
< |
AddDir::adddir($workloc); |
81 |
< |
|
82 |
< |
# -- add a cache |
83 |
< |
$self->_newcache(); |
84 |
< |
|
85 |
< |
# -- add an Objectstore |
86 |
< |
$self->_newobjectstore(); |
87 |
< |
|
88 |
< |
# -- Save Environment File |
89 |
< |
$self->_SaveEnvFile(); |
90 |
< |
|
74 |
> |
$self->location($location."/".$areaname); |
75 |
> |
$self->symlinks($symlinks); |
76 |
> |
if ($self->configchksum() ne "") |
77 |
> |
{ |
78 |
> |
if ((!-defined $locarea) && (-f "${location}/${areaname}/".$self->admindir()."/Environment")) |
79 |
> |
{ |
80 |
> |
$locarea=Configuration::ConfigArea->new(); |
81 |
> |
$locarea->bootstrapfromlocation("${location}/${areaname}"); |
82 |
> |
} |
83 |
> |
if ((defined $locarea) && ($locarea->configchksum() != $self->configchksum())) |
84 |
> |
{ |
85 |
> |
print "ERROR: Can not setup your current working area for SCRAM_ARCH:$ENV{SCRAM_ARCH}.\n", |
86 |
> |
"Your current development area ${location}/${areaname}\n", |
87 |
> |
"is using a different ${areaname}/config then the one used for\n", |
88 |
> |
$self->releasetop(),".\n"; |
89 |
> |
exit 1; |
90 |
> |
} |
91 |
> |
} |
92 |
> |
Utilities::AddDir::adddir($self->archdir()); |
93 |
|
} |
94 |
|
|
95 |
|
sub configurationdir { |
100 |
|
return (defined $self->{configurationdir})?$self->{configurationdir}:undef; |
101 |
|
} |
102 |
|
|
103 |
< |
sub toolbox { |
185 |
< |
my $self=shift; |
186 |
< |
if ( ! defined $self->{toolbox} ) { |
187 |
< |
$self->{toolbox}=BuildSystem::ToolBox->new($self, $ENV{SCRAM_ARCH}); |
188 |
< |
} |
189 |
< |
return $self->{toolbox}; |
190 |
< |
} |
191 |
< |
|
192 |
< |
sub requirementsdoc { |
103 |
> |
sub sourcedir { |
104 |
|
my $self=shift; |
105 |
|
if ( @_ ) { |
106 |
< |
$self->{reqdoc}=shift; |
196 |
< |
} |
197 |
< |
if ( defined $self->{reqdoc} ) { |
198 |
< |
return $self->location()."/".$self->{reqdoc}; |
199 |
< |
} |
200 |
< |
else { |
201 |
< |
return undef; |
106 |
> |
$self->{sourcedir}=shift; |
107 |
|
} |
108 |
+ |
return (defined $self->{sourcedir})?$self->{sourcedir}:undef; |
109 |
|
} |
110 |
|
|
111 |
< |
sub scramversion { |
111 |
> |
sub releasetop { |
112 |
|
my $self=shift; |
113 |
< |
if ( ! defined $self->{scramversion} ) { |
114 |
< |
my $filename=$self->location()."/".$self->configurationdir()."/". |
209 |
< |
"scram_version"; |
210 |
< |
if ( -f $filename ) { |
211 |
< |
use FileHandle; |
212 |
< |
$fh=FileHandle->new(); |
213 |
< |
open ($fh, "<".$filename); |
214 |
< |
my $version=<$fh>; |
215 |
< |
chomp $version; |
216 |
< |
$self->{scramversion}=$version; |
217 |
< |
undef $fh; |
218 |
< |
} |
113 |
> |
if ( @_ ) { |
114 |
> |
$self->{releasetop}=shift; |
115 |
|
} |
116 |
< |
return $self->{scramversion}; |
116 |
> |
return (defined $self->{releasetop})?$self->{releasetop}:undef; |
117 |
|
} |
118 |
|
|
119 |
< |
sub sitename |
119 |
> |
sub admindir() |
120 |
|
{ |
121 |
< |
############################################################### |
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 |
< |
# Be verbose and print file we're going to read: |
247 |
< |
$self->verbose(">> Going to try to get sitename from: ".$sitefile." "); |
248 |
< |
|
249 |
< |
# See if we can read from the file. If not, just |
250 |
< |
# use default site name: |
251 |
< |
open($sitefh,"<".$sitefile) || |
252 |
< |
do |
253 |
< |
{ |
254 |
< |
$self->verbose(">> Unable to read a site name definition file. Using \'CERN\' as the site name."); |
255 |
< |
return $self->{sitename}; |
256 |
< |
}; |
121 |
> |
my $self=shift; |
122 |
|
|
123 |
< |
$sitename = <$sitefh>; |
124 |
< |
chomp($sitename); |
260 |
< |
$self->{sitename} = $sitename; |
261 |
< |
|
262 |
< |
# Close the file (be tidy!); |
263 |
< |
close($sitefile); |
264 |
< |
# Return: |
265 |
< |
return $self->{sitename}; |
123 |
> |
@_ ? $self->{admindir} = shift |
124 |
> |
: $self->{admindir}; |
125 |
|
} |
126 |
|
|
268 |
– |
|
127 |
|
sub bootstrapfromlocation { |
128 |
|
my $self=shift; |
129 |
< |
|
129 |
> |
my $location = $self->searchlocation(shift); |
130 |
|
my $rv=0; |
131 |
< |
|
274 |
< |
my $location; |
275 |
< |
if ( ! defined ($location=$self->searchlocation(@_)) ) { |
131 |
> |
if ( ! defined $location) { |
132 |
|
$rv=1; |
277 |
– |
$self->verbose("Unable to locate the top of local configuration area"); |
133 |
|
} |
134 |
|
else { |
135 |
|
$self->location($location); |
281 |
– |
$self->verbose("Found top ".$self->location()); |
282 |
– |
my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat"; |
136 |
|
$self->_LoadEnvFile(); |
137 |
|
} |
138 |
|
return $rv; |
143 |
|
|
144 |
|
if ( @_ ) { |
145 |
|
$self->{location}=shift; |
146 |
+ |
$self->archname($ENV{SCRAM_ARCH}); |
147 |
|
} |
148 |
|
elsif ( ! defined $self->{location} ) { |
149 |
|
# try and find the release location |
150 |
|
$self->{location}=$self->searchlocation(); |
151 |
+ |
if (defined $self->{location}) |
152 |
+ |
{ |
153 |
+ |
$self->archname($ENV{SCRAM_ARCH}); |
154 |
+ |
} |
155 |
|
} |
156 |
|
return $self->{location}; |
157 |
|
} |
190 |
|
sub archname { |
191 |
|
my $self=shift; |
192 |
|
if ( @_ ) { |
193 |
< |
$self->{archname}=shift; |
193 |
> |
if (defined $self->{location}) { |
194 |
> |
$self->archdir($self->{location}."/".$self->{admindir}."/".$ENV{SCRAM_ARCH}); |
195 |
> |
} |
196 |
|
} |
197 |
< |
return $self->{archname}; |
197 |
> |
return $ENV{SCRAM_ARCH}; |
198 |
|
} |
199 |
|
|
200 |
|
sub archdir { |
202 |
|
if ( @_ ) { |
203 |
|
$self->{archdir}=shift; |
204 |
|
} |
345 |
– |
if ( ! defined $self->{archdir} ) { |
346 |
– |
if ( defined $self->{archname} ) { |
347 |
– |
$self->{archdir}=$self->location()."/".$self->{admindir}."/". |
348 |
– |
$self->{archname}; |
349 |
– |
} |
350 |
– |
else { |
351 |
– |
$self->error("ConfigArea : cannot create arch directory - ". |
352 |
– |
"architecture name not set") |
353 |
– |
} |
354 |
– |
} |
205 |
|
return $self->{archdir}; |
206 |
|
} |
207 |
|
|
208 |
|
sub satellite { |
209 |
|
my $self=shift; |
210 |
< |
|
361 |
< |
# -- create the sat object |
210 |
> |
my $relloc = $self->location(); |
211 |
|
my $sat=Configuration::ConfigArea->new(); |
212 |
|
$sat->name($self->name()); |
213 |
|
$sat->version($self->version()); |
365 |
– |
$sat->requirementsdoc($self->{reqdoc}); |
214 |
|
$sat->configurationdir($self->configurationdir()); |
215 |
+ |
$sat->sourcedir($self->sourcedir()); |
216 |
+ |
$sat->releasetop($relloc); |
217 |
+ |
$sat->configchksum($self->configchksum()); |
218 |
|
$sat->setup(@_); |
219 |
< |
|
220 |
< |
# -- copy across the cache and ObjectStore |
221 |
< |
# -- make sure we dont try building new caches in release areas |
222 |
< |
my $rcache=$self->cache(); |
223 |
< |
if ( defined $rcache ) { |
224 |
< |
copy($rcache->location(),$sat->cache()->location()); |
225 |
< |
} |
226 |
< |
|
227 |
< |
# -- make sure we dont try building new objectstores in release areas |
228 |
< |
my $rostore=$self->objectstore(); |
229 |
< |
if ( defined $rostore ) { |
230 |
< |
copy($rostore->location(),$sat->objectstore()->location()); |
231 |
< |
} |
232 |
< |
|
233 |
< |
# and make sure in reinitialises |
234 |
< |
undef ($sat->{cache}); |
235 |
< |
|
236 |
< |
# -- link it to this area |
386 |
< |
$sat->linkarea($self); |
387 |
< |
|
388 |
< |
# -- save it |
389 |
< |
$sat->save(); |
390 |
< |
|
219 |
> |
$self->copywithskip($self->archdir(),$sat->archdir(),["InstalledTools","ProjectCache.db.gz","RuntimeCache.db.gz","DirCache.db.gz","MakeData/DirCache","MakeData/DirCache.mk","MakeData/src.mk"]); |
220 |
> |
$envfile = $sat->archdir()."/Environment"; |
221 |
> |
open ( $fh, "> $envfile" ) or $sat->error("Cannot Open \"$envfile\" file to Save\n $!"); |
222 |
> |
print $fh "RELEASETOP=$relloc\n"; |
223 |
> |
close($fh); |
224 |
> |
my $devconf = $sat->location()."/".$sat->configurationdir(); |
225 |
> |
my $relconf = $self->location()."/".$self->configurationdir(); |
226 |
> |
if (!-d $devconf) |
227 |
> |
{ |
228 |
> |
$self->copywithskip($relconf,$devconf,['toolbox']); |
229 |
> |
} |
230 |
> |
$envfile = $sat->location()."/".$self->{admindir}."/Environment"; |
231 |
> |
if (! -f $envfile) |
232 |
> |
{ |
233 |
> |
$sat->save (); |
234 |
> |
} |
235 |
> |
Utilities::AddDir::copydir("${relconf}/toolbox/$ENV{SCRAM_ARCH}","${devconf}/toolbox/$ENV{SCRAM_ARCH}"); |
236 |
> |
Utilities::AddDir::adddir ($sat->location()."/".$sat->sourcedir()); |
237 |
|
return $sat; |
238 |
|
} |
239 |
|
|
240 |
< |
sub copy { |
395 |
< |
my $self=shift; |
396 |
< |
my $destination=shift; |
397 |
< |
|
398 |
< |
# copy across the admin dir |
399 |
< |
my $temp=$self->location()."/".$self->{admindir}; |
400 |
< |
AddDir::copydir($temp,"$destination/".$self->{admindir}); |
401 |
< |
} |
402 |
< |
|
403 |
< |
sub align { |
404 |
< |
my $self=shift; |
405 |
< |
use File::Copy; |
406 |
< |
|
407 |
< |
$self->_LoadEnvFile(); |
408 |
< |
my $Envfile=$self->location()."/".$self->{admindir}."/Environment"; |
409 |
< |
my $tmpEnvfile=$Envfile.".bak"; |
410 |
< |
my $rel=$self->{ENV}{RELEASETOP}; |
411 |
< |
my $local=$self->location(); |
412 |
< |
|
413 |
< |
rename( $Envfile, $tmpEnvfile ); |
414 |
< |
use FileHandle; |
415 |
< |
my $fh=FileHandle->new(); |
416 |
< |
my $fout=FileHandle->new(); |
417 |
< |
open ( $fh, "<".$tmpEnvfile ) or |
418 |
< |
$self->error("Cannot find Environment file. Area Corrupted? (" |
419 |
< |
.$self->location().")\n $!"); |
420 |
< |
open ( $fout, ">".$Envfile ) or |
421 |
< |
$self->error("Cannot find Environment file. Area Corrupted? (" |
422 |
< |
.$self->location().")\n $!"); |
423 |
< |
while ( <$fh> ) { |
424 |
< |
$_=~s/\Q$rel\L/$local/g; |
425 |
< |
print $fout $_; |
426 |
< |
} |
427 |
< |
undef $fh; |
428 |
< |
undef $fout; |
429 |
< |
} |
430 |
< |
|
431 |
< |
sub copysetup { |
240 |
> |
sub copywithskip { |
241 |
|
my $self=shift; |
242 |
< |
my $dest=shift; |
243 |
< |
|
242 |
> |
my $src=shift; |
243 |
> |
my $des=shift; |
244 |
> |
my $filetoskip=shift || []; |
245 |
|
my $rv=1; |
246 |
< |
# copy across the admin dir |
247 |
< |
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
248 |
< |
my $temp2=$dest."/".$self->{admindir}."/".$self->arch(); |
249 |
< |
if ( $temp ne $temp2 ) { |
250 |
< |
if ( -d $temp ) { |
251 |
< |
AddDir::copydir($temp,$temp2); |
252 |
< |
$rv=0; |
253 |
< |
} |
254 |
< |
} |
246 |
> |
if ( $src ne $des ) |
247 |
> |
{ |
248 |
> |
if ( -d $src ) |
249 |
> |
{ |
250 |
> |
my $fs=[]; |
251 |
> |
foreach my $f (@$filetoskip) {push @$fs,"${src}/${f}";} |
252 |
> |
Utilities::AddDir::copydirwithskip($src,$des,$fs); |
253 |
> |
$rv=0; |
254 |
> |
} |
255 |
> |
} |
256 |
|
return $rv; |
257 |
|
} |
258 |
|
|
270 |
|
return $ENV{SCRAM_ARCH}; |
271 |
|
} |
272 |
|
|
462 |
– |
sub linkto { |
463 |
– |
my $self=shift; |
464 |
– |
my $location=shift; |
465 |
– |
if ( -d $location ) { |
466 |
– |
my $area=Configuration::ConfigArea->new(); |
467 |
– |
$area->bootstrapfromlocation($location); |
468 |
– |
$self->linkarea($area); |
469 |
– |
} |
470 |
– |
else { |
471 |
– |
$self->error("ConfigArea : Unable to link to non existing directory ". |
472 |
– |
$location); |
473 |
– |
} |
474 |
– |
} |
475 |
– |
|
476 |
– |
sub unlinkarea { |
477 |
– |
my $self=shift; |
478 |
– |
undef $self->{linkarea}; |
479 |
– |
$self->{linkarea}=undef; |
480 |
– |
$self->save(); |
481 |
– |
} |
482 |
– |
|
483 |
– |
sub linkarea { |
484 |
– |
my $self=shift; |
485 |
– |
my $area=shift; |
486 |
– |
if ( defined $area ) { |
487 |
– |
$self->{linkarea}=$area; |
488 |
– |
} |
489 |
– |
return (defined $self->{linkarea} && $self->{linkarea} ne "")? |
490 |
– |
$self->{linkarea}:undef; |
491 |
– |
} |
492 |
– |
|
273 |
|
sub save { |
274 |
|
my $self=shift; |
275 |
|
$self->_SaveEnvFile(); |
277 |
|
|
278 |
|
# ---- support routines |
279 |
|
|
280 |
< |
sub _SaveEnvFile { |
281 |
< |
my $self=shift; |
282 |
< |
use FileHandle; |
283 |
< |
my $fh=FileHandle->new(); |
284 |
< |
open ( $fh, ">".$self->location()."/".$self->{admindir}."/". |
285 |
< |
"Environment" ) or |
286 |
< |
$self->error("Cannot Open Environment file to Save (" |
507 |
< |
.$self->location().")\n $!"); |
280 |
> |
sub _SaveEnvFile |
281 |
> |
{ |
282 |
> |
my $self=shift; |
283 |
> |
|
284 |
> |
my $fh; |
285 |
> |
my $envfile = $self->location()."/".$self->{admindir}."/Environment"; |
286 |
> |
open ( $fh, "> $envfile" ) or $self->error("Cannot Open \"$envfile\" file to Save\n $!"); |
287 |
|
|
288 |
< |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
289 |
< |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
290 |
< |
print $fh "projconfigdir=".$self->configurationdir()."\n"; |
291 |
< |
print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n"; |
292 |
< |
if ( defined $self->linkarea() ) { |
293 |
< |
my $area=$self->linkarea()->location(); |
294 |
< |
if ( $area ne "" ) { |
295 |
< |
print $fh "RELEASETOP=".$area."\n"; |
296 |
< |
} |
297 |
< |
} |
298 |
< |
undef $fh; |
299 |
< |
} |
521 |
< |
|
288 |
> |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
289 |
> |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
290 |
> |
print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n"; |
291 |
> |
print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n"; |
292 |
> |
print $fh "SCRAM_SYMLINKS=",$self->symlinks(),"\n"; |
293 |
> |
print $fh "SCRAM_CONFIGCHKSUM=",$self->configchksum(),"\n"; |
294 |
> |
close($fh); |
295 |
> |
|
296 |
> |
# Set the default permissions (-rw-r--r--): |
297 |
> |
my $filemode = 0644; |
298 |
> |
chmod $filemode, $self->location()."/".$self->{admindir}."/Environment"; |
299 |
> |
} |
300 |
|
|
301 |
< |
sub _LoadEnvFile { |
302 |
< |
my $self=shift; |
301 |
> |
sub _LoadEnvFile |
302 |
> |
{ |
303 |
> |
my $self=shift; |
304 |
|
|
305 |
< |
use FileHandle; |
306 |
< |
my $fh=FileHandle->new(); |
307 |
< |
open ( $fh, "<".$self->location()."/".$self->{admindir}."/". |
308 |
< |
"Environment" ) or |
309 |
< |
$self->error("Cannot find Environment file. Area Corrupted? (" |
310 |
< |
.$self->location().")\n $!"); |
311 |
< |
while ( <$fh> ) { |
312 |
< |
chomp; |
313 |
< |
next if /^#/; |
314 |
< |
next if /^\s*$/ ; |
315 |
< |
($name, $value)=split /=/; |
316 |
< |
eval "\$self->{ENV}{${name}}=\"$value\""; |
317 |
< |
} |
318 |
< |
undef $fh; |
305 |
> |
my $fh; |
306 |
> |
my $envfile = $self->location()."/".$self->{admindir}."/Environment"; |
307 |
> |
open ( $fh, "< $envfile" ) or $self->error("Cannot open \"$envfile\" file for reading.\n $!"); |
308 |
> |
while ( <$fh> ) |
309 |
> |
{ |
310 |
> |
chomp; |
311 |
> |
next if /^#/; |
312 |
> |
next if /^\s*$/ ; |
313 |
> |
($name, $value)=split /=/; |
314 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
315 |
> |
} |
316 |
> |
close($fh); |
317 |
> |
$envfile = $self->archdir()."/Environment"; |
318 |
> |
if (-f $envfile) |
319 |
> |
{ |
320 |
> |
open ( $fh, "< $envfile" ) or $self->error("Cannot open \"$envfile\" file for reading.\n $!"); |
321 |
> |
while ( <$fh> ) |
322 |
> |
{ |
323 |
> |
chomp; |
324 |
> |
next if /^#/; |
325 |
> |
next if /^\s*$/ ; |
326 |
> |
($name, $value)=split /=/; |
327 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
328 |
> |
} |
329 |
> |
close($fh); |
330 |
> |
} |
331 |
|
|
332 |
< |
# -- set internal variables appropriately |
333 |
< |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) { |
334 |
< |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
335 |
< |
} |
336 |
< |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) { |
337 |
< |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
338 |
< |
} |
339 |
< |
if ( defined $self->{ENV}{"projconfigdir"} ) { |
340 |
< |
$self->configurationdir($self->{ENV}{projconfigdir}); |
341 |
< |
} |
342 |
< |
if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) { |
343 |
< |
$self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc}); |
344 |
< |
} |
345 |
< |
if ( ( defined $self->{ENV}{"RELEASETOP"} ) && |
346 |
< |
($self->{ENV}{"RELEASETOP"} ne $self->location())) { |
347 |
< |
$self->linkto($self->{ENV}{"RELEASETOP"}); |
348 |
< |
} |
349 |
< |
else { |
350 |
< |
$self->{ENV}{"RELEASETOP"}=$self->location(); |
351 |
< |
} |
352 |
< |
} |
332 |
> |
# -- set internal variables appropriately |
333 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) |
334 |
> |
{ |
335 |
> |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
336 |
> |
} |
337 |
> |
if ( defined $self->{ENV}{"SCRAM_SYMLINKS"} ) |
338 |
> |
{ |
339 |
> |
$self->symlinks($self->{ENV}{"SCRAM_SYMLINKS"}); |
340 |
> |
} |
341 |
> |
if ( defined $self->{ENV}{"SCRAM_CONFIGCHKSUM"} ) |
342 |
> |
{ |
343 |
> |
$self->configchksum($self->{ENV}{"SCRAM_CONFIGCHKSUM"}); |
344 |
> |
} |
345 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) |
346 |
> |
{ |
347 |
> |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
348 |
> |
} |
349 |
> |
if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} ) |
350 |
> |
{ |
351 |
> |
$self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"}); |
352 |
> |
} |
353 |
> |
if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} ) |
354 |
> |
{ |
355 |
> |
$self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"}); |
356 |
> |
} |
357 |
> |
if ( defined $self->{ENV}{"RELEASETOP"} ) |
358 |
> |
{ |
359 |
> |
$self->releasetop($self->{ENV}{"RELEASETOP"}); |
360 |
> |
} |
361 |
> |
} |
362 |
> |
1; |