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