ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/ConfigArea.pm
(Generate patch)

Comparing COMP/SCRAM/src/Configuration/ConfigArea.pm (file contents):
Revision 1.11 by williamc, Thu Feb 24 14:24:29 2000 UTC vs.
Revision 1.13.2.6.2.6 by williamc, Tue Aug 15 08:33:15 2000 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines