1 |
|
# |
2 |
|
# ConfigArea.pm |
3 |
|
# |
4 |
< |
# Originally Written by Christopher Williams |
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(ActiveConfig) : A new ConfigArea object |
17 |
< |
# setup() : setup the configuration area |
18 |
< |
# location([dir]) : set/return the location of the area |
19 |
< |
# version([version]) : set/return the version of the area |
20 |
< |
# name([name]) : set/return the name of the area |
21 |
< |
# store(location) : store data in file location |
22 |
< |
# restore(location) : restore data from file location |
23 |
< |
# meta() : return a description string of the area |
24 |
< |
# addconfigitem(url) : add a new item to the area |
25 |
< |
# configitem(@keys) : return a list of fig items that match |
26 |
< |
# the keys - all if left blank |
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 |
|
|
48 |
|
package Configuration::ConfigArea; |
23 |
– |
use ActiveDoc::ActiveDoc; |
49 |
|
require 5.004; |
50 |
+ |
use URL::URLcache; |
51 |
|
use Utilities::AddDir; |
52 |
+ |
use Utilities::Verbose; |
53 |
|
use ObjectUtilities::ObjectStore; |
54 |
< |
@ISA=qw(ActiveDoc::ActiveDoc ObjectUtilities::StorableObject); |
54 |
> |
use Cwd; |
55 |
> |
@ISA=qw(Utilities::Verbose); |
56 |
> |
|
57 |
> |
sub new { |
58 |
> |
my $class=shift; |
59 |
> |
my $self={}; |
60 |
> |
bless $self, $class; |
61 |
|
|
62 |
< |
sub init { |
62 |
> |
# data init |
63 |
> |
$self->{admindir}=".SCRAM"; |
64 |
> |
$self->{cachedir}="cache"; |
65 |
> |
$self->{dbdir}="ObjectDB"; |
66 |
> |
undef $self->{linkarea}; |
67 |
> |
|
68 |
> |
return $self; |
69 |
> |
} |
70 |
> |
|
71 |
> |
sub cache { |
72 |
|
my $self=shift; |
73 |
< |
$self->newparse("init"); |
74 |
< |
$self->newparse("download"); |
75 |
< |
$self->newparse("setup"); |
76 |
< |
$self->addtag("init","project",\&Project_Start,$self, |
77 |
< |
\&Project_text,$self,"", $self ); |
78 |
< |
$self->addurltags("download"); |
79 |
< |
$self->addtag("download","use",\&Use_download_Start,$self, |
80 |
< |
"", $self, "",$self); |
39 |
< |
$self->addurltags("setup"); |
40 |
< |
$self->addtag("setup","use",\&Use_Start,$self, "", $self, "",$self); |
73 |
> |
if ( @_ ) { |
74 |
> |
$self->{cache}=shift; |
75 |
> |
} |
76 |
> |
elsif ( ! defined $self->{cache} ) { |
77 |
> |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir}; |
78 |
> |
$self->{cache}=URL::URLcache->new($loc); |
79 |
> |
} |
80 |
> |
return $self->{cache}; |
81 |
|
} |
82 |
|
|
83 |
< |
sub setup { |
83 |
> |
sub objectstore { |
84 |
|
my $self=shift; |
85 |
+ |
if ( @_ ) { |
86 |
+ |
$self->{dbstore}=shift; |
87 |
+ |
} |
88 |
+ |
elsif ( ! defined $self->{dbstore} ) { |
89 |
+ |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir}; |
90 |
+ |
$self->{dbstore}=ObjectUtilities::ObjectStore->new($loc); |
91 |
+ |
} |
92 |
+ |
return $self->{dbstore} |
93 |
+ |
} |
94 |
|
|
95 |
< |
# --- find out the location |
96 |
< |
my $location=$self->requestoption("area_location", |
97 |
< |
"Please Enter the location of the directory"); |
98 |
< |
|
50 |
< |
# --- find area directory name , default name projectname_version |
51 |
< |
my $name=$self->option("area_name"); |
52 |
< |
my $vers=$self->version; |
53 |
< |
if ( ! defined $name ) { |
54 |
< |
$name=$self->name(); |
55 |
< |
$vers=~s/^$name_//; |
56 |
< |
$name=$name."_".$vers; |
57 |
< |
} |
58 |
< |
$self->location($location."/".$name); |
59 |
< |
|
60 |
< |
# --- make a new ActiveStore at the location and add it to the db list |
61 |
< |
my $ad=ActiveDoc::ActiveConfig->new($self->location()."/\.SCRAM"); |
62 |
< |
|
63 |
< |
# make a new store handler |
64 |
< |
my $parentconfig=$self->config; |
65 |
< |
$self->config(Configuration::ConfigureStore); |
66 |
< |
$self->config()->db("local",$ad); |
67 |
< |
$self->config()->db("parent",$parentconfig); |
68 |
< |
$self->config()->policy("cache","local"); |
69 |
< |
$self->config()->basedoc($parentconfig->basedoc()); |
70 |
< |
|
71 |
< |
# --- download everything first |
72 |
< |
# FIX-ME --- cacheing is broken |
73 |
< |
# $self->parse("download"); |
74 |
< |
|
75 |
< |
# --- and parse the setup file |
76 |
< |
$self->parse("setup"); |
95 |
> |
sub name { |
96 |
> |
my $self=shift; |
97 |
> |
@_?$self->{name}=shift |
98 |
> |
:$self->{name}; |
99 |
|
} |
100 |
|
|
101 |
< |
sub store { |
101 |
> |
sub version { |
102 |
> |
my $self=shift; |
103 |
> |
@_?$self->{version}=shift |
104 |
> |
:$self->{version}; |
105 |
> |
} |
106 |
> |
|
107 |
> |
sub setup { |
108 |
|
my $self=shift; |
109 |
|
my $location=shift; |
110 |
+ |
my $areaname; |
111 |
+ |
|
112 |
+ |
# -- check we have a project name and version |
113 |
+ |
my $name=$self->name(); |
114 |
+ |
my $vers=$self->version(); |
115 |
+ |
if ( ( ! defined $name ) && ( ! defined $version )) { |
116 |
+ |
$self->error("Set ConfigArea name and version before setup"); |
117 |
+ |
} |
118 |
+ |
|
119 |
+ |
# -- check arguments and set location |
120 |
+ |
if ( ! defined $location ) { |
121 |
+ |
$self->error("ConfigArea: Cannot setup new area without a location"); |
122 |
+ |
} |
123 |
+ |
if ( @_ ) { |
124 |
+ |
$areaname=shift; |
125 |
+ |
} |
126 |
+ |
if ( (! defined $areaname) || ( $areaname eq "" ) ) { |
127 |
+ |
# -- make up a name from the project name and version |
128 |
+ |
$vers=~s/^$name\_//; |
129 |
+ |
$areaname=$name."_".$vers; |
130 |
+ |
} |
131 |
+ |
my $arealoc=$location."/".$areaname; |
132 |
+ |
my $workloc=$arealoc."/".$self->{admindir}; |
133 |
+ |
$self->verbose("Building at $arealoc"); |
134 |
+ |
$self->location($arealoc); |
135 |
+ |
|
136 |
+ |
# -- create top level structure and work area |
137 |
+ |
AddDir::adddir($workloc); |
138 |
+ |
|
139 |
+ |
# -- add a cache |
140 |
+ |
$self->cache(); |
141 |
+ |
|
142 |
+ |
# -- Save Environment File |
143 |
+ |
$self->_SaveEnvFile(); |
144 |
|
|
83 |
– |
my $fh=$self->openfile(">".$location); |
84 |
– |
print $fh $self->location()."\n"; |
85 |
– |
$fh->close(); |
145 |
|
} |
146 |
|
|
147 |
< |
sub restore { |
147 |
> |
sub configurationdir { |
148 |
|
my $self=shift; |
149 |
+ |
if ( @_ ) { |
150 |
+ |
$self->{configurationdir}=shift; |
151 |
+ |
} |
152 |
+ |
return (defined $self->{configurationdir})?$self->{configurationdir}:undef; |
153 |
+ |
} |
154 |
|
|
155 |
< |
my $fh=$self->openfile("<".$location); |
156 |
< |
$self->{location}=<$fh>; |
157 |
< |
chomp $self->{location}; |
158 |
< |
$fh->close(); |
159 |
< |
|
155 |
> |
sub toolbox { |
156 |
> |
my $self=shift; |
157 |
> |
if ( ! defined $self->{toolbox} ) { |
158 |
> |
$self->{toolbox}=BuildSystem::ToolBox->new($self); |
159 |
> |
} |
160 |
> |
return $self->{toolbox}; |
161 |
|
} |
162 |
|
|
163 |
< |
sub name { |
163 |
> |
sub requirementsdoc { |
164 |
|
my $self=shift; |
165 |
+ |
if ( @_ ) { |
166 |
+ |
$self->{reqdoc}=shift; |
167 |
+ |
} |
168 |
+ |
if ( defined $self->{reqdoc} ) { |
169 |
+ |
return $self->location()."/".$self->{reqdoc}; |
170 |
+ |
} |
171 |
+ |
else { |
172 |
+ |
return undef; |
173 |
+ |
} |
174 |
+ |
} |
175 |
|
|
176 |
< |
@_?$self->{name}=shift |
177 |
< |
:$self->{name}; |
176 |
> |
sub scramversion { |
177 |
> |
my $self=shift; |
178 |
> |
if ( ! defined $self->{scramversion} ) { |
179 |
> |
my $filename=$self->location()."/".$self->configurationdir()."/". |
180 |
> |
"scram_version"; |
181 |
> |
if ( -f $filename ) { |
182 |
> |
use FileHandle; |
183 |
> |
$fh=FileHandle->new(); |
184 |
> |
open ($fh, "<".$filename); |
185 |
> |
my $version=<$fh>; |
186 |
> |
chomp $version; |
187 |
> |
$self->{scramversion}=$version; |
188 |
> |
undef $fh; |
189 |
> |
} |
190 |
> |
} |
191 |
> |
return $self->{scramversion}; |
192 |
|
} |
193 |
|
|
194 |
< |
sub version { |
194 |
> |
sub bootstrapfromlocation { |
195 |
|
my $self=shift; |
196 |
|
|
197 |
< |
@_?$self->{version}=shift |
198 |
< |
:$self->{version}; |
197 |
> |
my $rv=0; |
198 |
> |
|
199 |
> |
my $location; |
200 |
> |
if ( ! defined ($location=$self->searchlocation(@_)) ) { |
201 |
> |
$rv=1; |
202 |
> |
$self->verbose("Unable to locate the top of local configuration area"); |
203 |
> |
} |
204 |
> |
else { |
205 |
> |
$self->location($location); |
206 |
> |
$self->verbose("Found top ".$self->location()); |
207 |
> |
my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat"; |
208 |
> |
$self->_LoadEnvFile(); |
209 |
> |
} |
210 |
> |
return $rv; |
211 |
|
} |
212 |
|
|
213 |
|
sub location { |
214 |
|
my $self=shift; |
215 |
|
|
216 |
< |
@_?$self->{location}=shift |
217 |
< |
:$self->{location}; |
216 |
> |
if ( @_ ) { |
217 |
> |
$self->{location}=shift; |
218 |
> |
} |
219 |
> |
elsif ( ! defined $self->{location} ) { |
220 |
> |
# try and find the release location |
221 |
> |
$self->{location}=$self->searchlocation(); |
222 |
> |
} |
223 |
> |
return $self->{location}; |
224 |
|
} |
225 |
|
|
226 |
< |
sub meta { |
226 |
> |
sub searchlocation { |
227 |
|
my $self=shift; |
228 |
|
|
229 |
< |
my $string=$self->name()." ".$self->version()." located at :\n ". |
230 |
< |
$self->location; |
229 |
> |
#start search in current directory if not specified |
230 |
> |
my $thispath; |
231 |
> |
if ( @_ ) { |
232 |
> |
$thispath=shift |
233 |
> |
} |
234 |
> |
else { |
235 |
> |
$thispath=cwd(); |
236 |
> |
} |
237 |
> |
|
238 |
> |
my $rv=0; |
239 |
> |
|
240 |
> |
# chop off any files - we only want dirs |
241 |
> |
if ( -f $thispath ) { |
242 |
> |
$thispath=~s/(.*)\/.*/$1/; |
243 |
> |
} |
244 |
> |
Sloop:{ |
245 |
> |
do { |
246 |
> |
$self->verbose("Searching $thispath"); |
247 |
> |
if ( -e "$thispath/".$self->{admindir} ) { |
248 |
> |
$self->verbose("Found\n"); |
249 |
> |
$rv=1; |
250 |
> |
last Sloop; |
251 |
> |
} |
252 |
> |
} while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) }; |
253 |
> |
|
254 |
> |
return $rv?$thispath:undef; |
255 |
|
} |
256 |
|
|
257 |
< |
sub configitem { |
257 |
> |
sub archname { |
258 |
|
my $self=shift; |
259 |
< |
my $location=shift; |
259 |
> |
if ( @_ ) { |
260 |
> |
$self->{archname}=shift; |
261 |
> |
} |
262 |
> |
return $self->{archname}; |
263 |
> |
} |
264 |
> |
|
265 |
> |
sub archdir { |
266 |
> |
my $self=shift; |
267 |
> |
if ( @_ ) { |
268 |
> |
$self->{archdir}=shift; |
269 |
> |
} |
270 |
> |
if ( ! defined $self->{archdir} ) { |
271 |
> |
if ( defined $self->{archname} ) { |
272 |
> |
$self->{archdir}=$self->location()."/".$self->{admindir}."/". |
273 |
> |
$self->{archname}; |
274 |
> |
} |
275 |
> |
else { |
276 |
> |
$self->error("ConfigArea : cannot create arch directory - ". |
277 |
> |
"architecture name not set") |
278 |
> |
} |
279 |
> |
} |
280 |
> |
return $self->{archdir}; |
281 |
> |
} |
282 |
> |
|
283 |
> |
sub satellite { |
284 |
> |
my $self=shift; |
285 |
> |
|
286 |
> |
# -- create the sat object |
287 |
> |
my $sat=Configuration::ConfigArea->new(); |
288 |
> |
$sat->name($self->name()); |
289 |
> |
$sat->version($self->version()); |
290 |
> |
$sat->requirementsdoc($self->{reqdoc}); |
291 |
> |
$sat->configurationdir($self->configurationdir()); |
292 |
> |
$sat->setup(@_); |
293 |
> |
|
294 |
> |
# -- copy across the cache and ObjectStore |
295 |
> |
copy($self->cache()->location(),$sat->cache()->location()); |
296 |
> |
copy($self->objectstore()->location(),$sat->objectstore()->location()); |
297 |
> |
|
298 |
> |
# and make sure in reinitialises |
299 |
> |
undef ($sat->{cache}); |
300 |
> |
|
301 |
> |
# -- link it to this area |
302 |
> |
$sat->linkarea($self); |
303 |
|
|
304 |
< |
$self->config()->find("ConfigItem",@_); |
304 |
> |
# -- save it |
305 |
> |
$sat->save(); |
306 |
> |
|
307 |
> |
return $sat; |
308 |
|
} |
309 |
|
|
310 |
< |
sub addconfigitem { |
310 |
> |
sub copy { |
311 |
|
my $self=shift; |
312 |
< |
my $url=shift; |
312 |
> |
my $destination=shift; |
313 |
|
|
314 |
< |
my $docref=$self->activatedoc($url); |
315 |
< |
# Set up the document |
316 |
< |
$docref->setup(); |
140 |
< |
$self->config()->savepolicy("local"); |
141 |
< |
$docref->save(); |
314 |
> |
# copy across the admin dir |
315 |
> |
my $temp=$self->location()."/".$self->{admindir}; |
316 |
> |
AddDir::copydir($temp,"$destination/".$self->{admindir}); |
317 |
|
} |
318 |
|
|
319 |
< |
# -------------- Tags --------------------------------- |
145 |
< |
# -- init parse |
146 |
< |
sub Project_Start { |
319 |
> |
sub align { |
320 |
|
my $self=shift; |
321 |
< |
my $name=shift; |
149 |
< |
my $hashref=shift; |
321 |
> |
use File::Copy; |
322 |
|
|
323 |
< |
$self->checktag($name,$hashref,'name'); |
324 |
< |
$self->checktag($name,$hashref,'version'); |
323 |
> |
$self->_LoadEnvFile(); |
324 |
> |
my $Envfile=$self->location()."/".$self->{admindir}."/Environment"; |
325 |
> |
my $tmpEnvfile=$Envfile.".bak"; |
326 |
> |
my $rel=$self->{ENV}{RELEASETOP}; |
327 |
> |
my $local=$self->location(); |
328 |
|
|
329 |
< |
$self->name($$hashref{'name'}); |
330 |
< |
$self->version($$hashref{'version'}); |
329 |
> |
rename( $Envfile, $tmpEnvfile ); |
330 |
> |
use FileHandle; |
331 |
> |
my $fh=FileHandle->new(); |
332 |
> |
my $fout=FileHandle->new(); |
333 |
> |
open ( $fh, "<".$tmpEnvfile ) or |
334 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
335 |
> |
.$self->location().")\n $!"); |
336 |
> |
open ( $fout, ">".$Envfile ) or |
337 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
338 |
> |
.$self->location().")\n $!"); |
339 |
> |
while ( <$fh> ) { |
340 |
> |
$_=~s/\Q$rel\L/$local/g; |
341 |
> |
print $fout $_; |
342 |
> |
} |
343 |
> |
undef $fh; |
344 |
> |
undef $fout; |
345 |
|
} |
346 |
|
|
347 |
+ |
sub copysetup { |
348 |
+ |
my $self=shift; |
349 |
+ |
my $dest=shift; |
350 |
+ |
|
351 |
+ |
my $rv=1; |
352 |
+ |
# copy across the admin dir |
353 |
+ |
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
354 |
+ |
my $temp2=$dest."/".$self->{admindir}."/".$self->arch(); |
355 |
+ |
if ( $temp ne $temp2 ) { |
356 |
+ |
if ( -d $temp ) { |
357 |
+ |
AddDir::copydir($temp,$temp2); |
358 |
+ |
$rv=0; |
359 |
+ |
} |
360 |
+ |
} |
361 |
+ |
return $rv; |
362 |
+ |
} |
363 |
|
|
364 |
< |
sub Project_text { |
364 |
> |
sub copyenv { |
365 |
|
my $self=shift; |
366 |
< |
my $name=shift; |
367 |
< |
my $string=shift; |
366 |
> |
my $hashref=shift; |
367 |
> |
|
368 |
> |
foreach $elem ( keys %{$self->{ENV}} ) { |
369 |
> |
$$hashref{$elem}=$self->{ENV}{$elem}; |
370 |
> |
} |
371 |
> |
} |
372 |
|
|
373 |
< |
print $string; |
373 |
> |
sub arch { |
374 |
> |
my $self=shift; |
375 |
> |
return $ENV{SCRAM_ARCH}; |
376 |
|
} |
377 |
|
|
378 |
< |
# ---- download parse |
378 |
> |
sub linkto { |
379 |
> |
my $self=shift; |
380 |
> |
my $location=shift; |
381 |
> |
if ( -d $location ) { |
382 |
> |
my $area=Configuration::ConfigArea->new(); |
383 |
> |
$area->bootstrapfromlocation($location); |
384 |
> |
$self->linkarea($area); |
385 |
> |
} |
386 |
> |
else { |
387 |
> |
$self->error("ConfigArea : Unable to link to non existing directory ". |
388 |
> |
$location); |
389 |
> |
} |
390 |
> |
} |
391 |
> |
|
392 |
> |
sub unlinkarea { |
393 |
> |
my $self=shift; |
394 |
> |
undef $self->{linkarea}; |
395 |
> |
$self->{linkarea}=undef; |
396 |
> |
$self->save(); |
397 |
> |
} |
398 |
|
|
399 |
< |
sub Use_download_Start { |
399 |
> |
sub linkarea { |
400 |
|
my $self=shift; |
401 |
< |
my $name=shift; |
402 |
< |
my $hashref=shift; |
401 |
> |
my $area=shift; |
402 |
> |
if ( defined $area ) { |
403 |
> |
$self->{linkarea}=$area; |
404 |
> |
} |
405 |
> |
return (defined $self->{linkarea} && $self->{linkarea} ne "")? |
406 |
> |
$self->{linkarea}:undef; |
407 |
> |
} |
408 |
|
|
409 |
< |
$self->checktag($name,$hashref,'url'); |
410 |
< |
print "Downloading .... ".$$hashref{'url'}."\n"; |
411 |
< |
$self->getfile($$hashref{'url'}); |
409 |
> |
sub save { |
410 |
> |
my $self=shift; |
411 |
> |
$self->_SaveEnvFile(); |
412 |
|
} |
413 |
|
|
414 |
< |
# --- setup parse |
414 |
> |
# ---- support routines |
415 |
|
|
416 |
< |
sub Use_Start { |
416 |
> |
sub _SaveEnvFile { |
417 |
|
my $self=shift; |
418 |
< |
my $name=shift; |
419 |
< |
my $hashref=shift; |
418 |
> |
use FileHandle; |
419 |
> |
my $fh=FileHandle->new(); |
420 |
> |
open ( $fh, ">".$self->location()."/".$self->{admindir}."/". |
421 |
> |
"Environment" ) or |
422 |
> |
$self->error("Cannot Open Environment file to Save (" |
423 |
> |
.$self->location().")\n $!"); |
424 |
|
|
425 |
< |
$self->checktag($name,$hashref,'url'); |
426 |
< |
$self->addconfigitem($$hashref{'url'}); |
425 |
> |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
426 |
> |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
427 |
> |
print $fh "projconfigdir=".$self->configurationdir()."\n"; |
428 |
> |
print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n"; |
429 |
> |
if ( defined $self->linkarea() ) { |
430 |
> |
my $area=$self->linkarea()->location(); |
431 |
> |
if ( $area ne "" ) { |
432 |
> |
print $fh "RELEASETOP=".$area."\n"; |
433 |
> |
} |
434 |
> |
} |
435 |
> |
undef $fh; |
436 |
|
} |
437 |
|
|
438 |
+ |
|
439 |
+ |
sub _LoadEnvFile { |
440 |
+ |
my $self=shift; |
441 |
+ |
|
442 |
+ |
use FileHandle; |
443 |
+ |
my $fh=FileHandle->new(); |
444 |
+ |
open ( $fh, "<".$self->location()."/".$self->{admindir}."/". |
445 |
+ |
"Environment" ) or |
446 |
+ |
$self->error("Cannot find Environment file. Area Corrupted? (" |
447 |
+ |
.$self->location().")\n $!"); |
448 |
+ |
while ( <$fh> ) { |
449 |
+ |
chomp; |
450 |
+ |
next if /^#/; |
451 |
+ |
next if /^\s*$/ ; |
452 |
+ |
($name, $value)=split /=/; |
453 |
+ |
eval "\$self->{ENV}{${name}}=\"$value\""; |
454 |
+ |
} |
455 |
+ |
undef $fh; |
456 |
+ |
|
457 |
+ |
# -- set internal variables appropriately |
458 |
+ |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) { |
459 |
+ |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
460 |
+ |
} |
461 |
+ |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) { |
462 |
+ |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
463 |
+ |
} |
464 |
+ |
if ( defined $self->{ENV}{"projconfigdir"} ) { |
465 |
+ |
$self->configurationdir($self->{ENV}{projconfigdir}); |
466 |
+ |
} |
467 |
+ |
if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) { |
468 |
+ |
$self->requirementsdoc($self->{ENV}{SCRAM_ProjReqsDoc}); |
469 |
+ |
} |
470 |
+ |
if ( ( defined $self->{ENV}{"RELEASETOP"} ) && |
471 |
+ |
($self->{ENV}{"RELEASETOP"} ne $self->location())) { |
472 |
+ |
$self->linkto($self->{ENV}{"RELEASETOP"}); |
473 |
+ |
} |
474 |
+ |
else { |
475 |
+ |
$self->{ENV}{"RELEASETOP"}=$self->location(); |
476 |
+ |
} |
477 |
+ |
} |