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.9 by williamc, Wed Feb 23 13:24:13 2000 UTC vs.
Revision 1.14 by williamc, Mon Aug 28 08:35:14 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 > # objectstore()         : return the objectStore object of the area
45 > # - temporary
46 > # align()                       : adjust hard paths to suit local loaction
47  
48   package Configuration::ConfigArea;
50 use ActiveDoc::ActiveDoc;
49   require 5.004;
50 + use URL::URLcache;
51   use Utilities::AddDir;
52 + use Utilities::Verbose;
53   use ObjectUtilities::ObjectStore;
54 use Configuration::ConfigStore;
55 use Configuration::ActiveDoc_arch;
54   use Cwd;
55 < @ISA=qw(Configuration::ActiveDoc_arch ObjectUtilities::StorableObject);
55 > @ISA=qw(Utilities::Verbose);
56  
57 < sub init {
58 <        my $self=shift;
59 <
60 <        $self->newparse("init");
63 <        $self->newparse("download");
64 <        $self->newparse("setup");
65 <        $self->addtag("init","project",\&Project_Start,$self,
66 <            \&Project_text,$self,"", $self );
67 <        $self->addurltags("download");
68 <        $self->addtag("download","download",\&Download_Start,$self,
69 <                                                "", $self, "",$self);
70 <        $self->addtag("download","use",\&Use_download_Start,$self,
71 <                                                "", $self, "",$self);
72 <        $self->addurltags("setup");
73 <        $self->addtag("setup","use",\&Use_Start,$self, "", $self, "",$self);
74 <        $self->addtag("setup","structure",\&Structure_Start,$self,
75 <                         "", $self, "",$self);
57 > sub new {
58 >        my $class=shift;
59 >        my $self={};
60 >        bless $self, $class;
61  
62          # data init
63 <        $self->{admindir}=".SCRAM";
63 >        $self->{admindir}=".SCRAM";
64 >        $self->{cachedir}="cache";
65 >        $self->{dbdir}="ObjectDB";
66 >        undef $self->{linkarea};
67 >
68 >        return $self;
69   }
70  
71 < sub basearea {
71 > sub cache {
72          my $self=shift;
83
84        my $area;
73          if ( @_ ) {
74 <          $area=shift;
87 <          $self->config()->store($area,"BaseArea");
74 >          $self->{cache}=shift;
75          }
76 <        else {
77 <          ($area)=$self->config()->restore("BaseArea");
76 >        elsif ( ! defined $self->{cache} ) {
77 >          my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir};
78 >          $self->{cache}=URL::URLcache->new($loc);
79          }
80 <        return $area;
80 >        return $self->{cache};
81   }
82  
83 < sub freebase {
83 > sub objectstore {
84          my $self=shift;
85 <        $self->config()->delete("BaseArea");
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 < sub defaultdirname {
95 > sub name {
96          my $self=shift;
97 <        my $name=$self->name();
98 <        my $vers=$self->version();
104 <        $vers=~s/^$name\_//;
105 <        $name=$name."_".$vers;
106 <        return $name;
97 >        @_?$self->{name}=shift
98 >          :$self->{name};
99   }
100  
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 <        # --- find out the location - default is cwd
113 <        my $location=$self->option("ConfigArea_location");
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 <                $location=cwd();
121 >          $self->error("ConfigArea: Cannot setup new area without a location");
122          }
123 <        elsif ( $location!~/^\// ) {
124 <                $location=cwd()."/".$location;
123 >        if ( @_ ) {
124 >          $areaname=shift;
125          }
126 <
127 <        # --- find area directory name , default name projectname_version
128 <        my $name=$self->option("ConfigArea_name");
129 <        if ( ! defined $name ) {
125 <          $name=$self->defaultdirname();
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 <        $self->location($location."/".$name);
131 >        my $arealoc=$location."/".$areaname;
132 >        my $workloc=$arealoc."/".$self->{admindir};
133 >        $self->verbose("Building at $arealoc");
134 >        $self->location($arealoc);
135  
136 <        # make a new store handler
137 <        $self->_setupstore();
136 >        # -- create top level structure and work area
137 >        AddDir::adddir($workloc);
138  
139 <        # --- download everything first
140 <        $self->parse("download");
134 <        
135 <        # --- and parse the setup file
136 <        $self->parse("setup");
137 <        
138 <        # --- store bootstrap info
139 <        $self->store($self->location()."/".$self->{admindir}."/ConfigArea.dat");
139 >        # -- add a cache
140 >        $self->cache();
141  
142 <        # --- store self in original database
143 <        $self->parentconfig()->store($self,"ConfigArea",$self->name(),
143 <                                                        $self->version());
144 < }
142 >        # -- Save Environment File
143 >        $self->_SaveEnvFile();
144  
146 sub structure {
147        my $self=shift;
148        my $vr=shift;
149        return $self->{structures}{$vr};
145   }
146  
147 < sub structurelist {
147 > sub configurationdir {
148          my $self=shift;
149 <        return ( keys %{$self->{structures}} );
150 < }
156 <
157 < sub _setupstore {
158 <        my $self=shift;
159 <
160 <        # --- make a new ConfigStore at the location and add it to the db list
161 <        my $ad=Configuration::ConfigStore->new($self->location().
162 <                                "/".$self->{admindir}, $self->arch());
163 <
164 <        $self->parentconfig($self->config());
165 < #        $self->config(Configuration::ConfigureStore->new());
166 < #        $self->config()->db("local",$ad);
167 < #        $self->config()->db("parent",$self->parentconfig());
168 < #        $self->config()->policy("cache","local");
169 <        $self->config($ad);
170 <        $self->config()->basedoc($self->parentconfig()->basedoc());
171 < }
172 <
173 < sub bootstrapfromlocation {
174 <        my $self=shift;
175 <        
176 <        if ( ! defined $self->location(@_) ) {
177 <          $self->error("Unable to locate the top of local configuration area");
149 >        if ( @_ ) {
150 >          $self->{configurationdir}=shift;
151          }
152 <        print "Found top ".$self->location()."\n";
180 <        $self->_setupstore();
181 <        $self->restore($self->location()."/".$self->{admindir}.
182 <                                                "/ConfigArea.dat");
152 >        return (defined $self->{configurationdir})?$self->{configurationdir}:undef;
153   }
154  
155 < sub parentconfig {
155 > sub toolbox {
156          my $self=shift;
157 <        @_?$self->{parentconfig}=shift
158 <          :$self->{parentconfig};
159 < }
160 <
191 < sub store {
192 <        my $self=shift;
193 <        my $location=shift;
194 <
195 <        my $fh=$self->openfile(">".$location);
196 <        $self->savevar($fh,"location", $self->location());
197 <        $self->savevar($fh,"url", $self->url());
198 <        $self->savevar($fh,"name", $self->name());
199 <        $self->savevar($fh,"version", $self->version());
200 <        $fh->close();
201 <
202 <        $self->_storestructures();
203 < }
204 <
205 < sub satellite {
206 <        my $self=shift;
207 <        my $newarea=$self->copy(@_);
208 <        $newarea->_makesatellites();
209 <        return $newarea;
157 >        if ( ! defined $self->{toolbox} ) {
158 >          $self->{toolbox}=BuildSystem::ToolBox->new($self);
159 >        }
160 >        return $self->{toolbox};
161   }
162  
163 < sub copy {
163 > sub requirementsdoc {
164          my $self=shift;
214        use File::Basename;
215        # create the area
216
217        my $destination;
165          if ( @_ ) {
166 <         $destination=shift;
166 >          $self->{reqdoc}=shift;
167 >        }
168 >        if ( defined $self->{reqdoc} ) {
169 >          return $self->location()."/".$self->{reqdoc};
170          }
171          else {
172 <          my($location,$name)=$self->_defaultoptions();
223 <          $destination=$location."/".$name
172 >          return undef;
173          }
225        #AddDir::adddir(dirname($destination)."/".$self->{admindir});
226        #AddDir::adddir($destination."/".$self->{admindir});
227        
228        # copy across the admin dir
229        $temp=$self->location()."/".$self->{admindir};
230        AddDir::copydir($temp,"$destination/".$self->{admindir});
231        # create a new object based on the new area
232        my $newarea=ref($self)->new($self->parentconfig());
233        $newarea->bootstrapfromlocation($destination);
234        # save it with the new location info
235        $newarea->store($self->location()."/".$self->{admindir}.
236                                                        "/ConfigArea.dat");
237        return $newarea;
174   }
175  
176 < sub restore {
176 > sub scramversion {
177          my $self=shift;
178 <        my $location=shift;
179 <
180 <        my $fh=$self->openfile("<".$location);
181 <        my $varhash={};
182 <        $self->restorevars($fh,$varhash);
183 <        if ( ! defined $self->location() ) {
184 <          $self->location($$varhash{"location"});
185 <        }
186 <        $self->_setupstore();
187 <        $self->url($$varhash{"url"});
188 <        $self->name($$varhash{"name"});
189 <        $self->version($$varhash{"version"});
190 <        $fh->close();
191 <
256 <        $self->_restorestructures();
257 < }
258 <
259 < sub name {
260 <        my $self=shift;
261 <
262 <        @_?$self->{name}=shift
263 <          :$self->{name};
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 {
# Line 288 | Line 228 | sub searchlocation {
228  
229          #start search in current directory if not specified
230          my $thispath;
231 <        @_?$thispath=shift
232 <          :$thispath=cwd();
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 < #         print "Searching $thispath\n";
246 >          $self->verbose("Searching $thispath");
247            if ( -e "$thispath/".$self->{admindir} ) {
248 < #           print "Found\n";
248 >            $self->verbose("Found\n");
249              $rv=1;
250              last Sloop;
251            }
# Line 306 | Line 254 | sub searchlocation {
254          return $rv?$thispath:undef;
255   }
256  
257 < sub meta {
257 > sub archname {
258          my $self=shift;
259 <
260 <        my $string=$self->name()." ".$self->version()." located at :\n  ".
261 <                $self->location;
259 >        if ( @_ ) {
260 >          $self->{archname}=shift;
261 >        }
262 >        return $self->{archname};
263   }
264  
265 < sub configitem {
265 > sub archdir {
266          my $self=shift;
267 <        
268 <        return ($self->config()->find("ConfigItem",@_));
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 addconfigitem {
283 > sub satellite {
284          my $self=shift;
324        my $url=shift;
285  
286 <        my $docref=$self->activatedoc($url);
287 <        # Set up the document
288 <        $docref->setup();
289 <        $docref->save();
290 < #       $self->config()->storepolicy("local");
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 >        # -- save it
305 >        $sat->save();
306 >
307 >        return $sat;
308   }
309  
310 < sub downloadtotop {
310 > sub copy {
311          my $self=shift;
312 <        my $url=shift;
313 <        my $dir=shift;
314 <        
315 <        # only download once
316 <        if ( ! -e $self->location()."/".$dir ) {
340 <          $self->{urlhandler}->download($url,$self->location()."/".$dir);
341 <        }
312 >        my $destination=shift;
313 >
314 >        # copy across the admin dir
315 >        my $temp=$self->location()."/".$self->{admindir};
316 >        AddDir::copydir($temp,"$destination/".$self->{admindir});
317   }
318  
319 < sub _makesatellites {
319 > sub align {
320          my $self=shift;
321 <        foreach $st ( values %{$self->{structures}} ) {
322 <           $st->setupsatellite()
323 <        }
321 >        use File::Copy;
322 >
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 >        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 _storestructures {
347 > sub copysetup {
348          my $self=shift;
349 <        foreach $struct ( values %{$self->{structures}} ) {
350 <          $self->config()->store($struct, "Structures", $struct->name());
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 _restorestructures {
364 > sub copyenv {
365          my $self=shift;
366 <        my @strs=$self->config()->find("Structures");
367 <        foreach $struct ( @strs ) {
368 <          $struct->parent($self);
369 <          $self->{structures}{$struct->name()}=$struct;
366 >        my $hashref=shift;
367 >        
368 >        foreach $elem ( keys %{$self->{ENV}} ) {
369 >           $$hashref{$elem}=$self->{ENV}{$elem};
370          }
371   }
372  
373 < sub _defaultoptions {
373 > sub arch {
374          my $self=shift;
375 <        my $name;
370 <        my $location;
371 <
372 <        # --- find out the location - default is cwd
373 <        $location=$self->option("ConfigArea_location");
374 <        if ( ! defined $location ) {
375 <                $location=cwd();
376 <        }
377 <        elsif ( $location!~/^\// ) {
378 <                $location=cwd()."/".$location;
379 <        }
380 <
381 <        # --- find area directory name , default name projectname_version
382 <        $name=$self->option("ConfigArea_name");
383 <        if ( ! defined $name ) {
384 <          $name=$self->defaultdirname();
385 <        }
386 <        return ($location,$name);
375 >        return $ENV{SCRAM_ARCH};
376   }
388 # -------------- Tags ---------------------------------
389 # -- init parse
390 sub Project_Start {
391        my $self=shift;
392        my $name=shift;
393        my $hashref=shift;
394
395        $self->checktag($name,$hashref,'name');
396        $self->checktag($name,$hashref,'version');
377  
378 <        $self->name($$hashref{'name'});
379 <        $self->version($$hashref{'version'});
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 <
403 < sub Project_text {
392 > sub unlinkarea {
393          my $self=shift;
394 <        my $name=shift;
395 <        my $string=shift;
396 <
408 <        print $string;
394 >        undef $self->{linkarea};
395 >        $self->{linkarea}=undef;
396 >        $self->save();
397   }
398  
399 < # ---- download parse
412 <
413 < sub Download_Start {
399 > sub linkarea {
400          my $self=shift;
401 <        my $name=shift;
402 <        my $hashref=shift;
403 <
418 <        $self->checktag($name,$hashref,'url');
419 <        $self->checktag($name,$hashref,'location');
420 <        if ( $$hashref{'location'}!~/^\w/ ) {
421 <          $self->parseerror("location must start with an".
422 <                " alphanumeric character");
401 >        my $area=shift;
402 >        if ( defined $area ) {
403 >          $self->{linkarea}=$area;
404          }
405 <        print "Downloading .... ".$$hashref{'url'}."\n";
406 <        $self->downloadtotop($$hashref{'url'},$$hashref{'location'});
405 >        return (defined $self->{linkarea} && $self->{linkarea} ne "")?
406 >                        $self->{linkarea}:undef;
407   }
408  
409 < sub Use_download_Start {
409 > sub save {
410          my $self=shift;
411 <        my $name=shift;
431 <        my $hashref=shift;
432 <
433 <        $self->checktag($name,$hashref,'url');
434 <        print "Downloading .... ".$$hashref{'url'}."\n";
435 <        $self->getfile($$hashref{'url'});
411 >        $self->_SaveEnvFile();
412   }
413  
414 < # --- setup parse
414 > # ---- support routines
415  
416 < sub Structure_Start {
416 > sub _SaveEnvFile {
417          my $self=shift;
418 <        my $name=shift;
419 <        my $hashref=shift;
420 <
421 <        $self->checktag($name,$hashref,'name');
422 <        if ( !( exists $$hashref{'type'}) || ( exists $$hashref{'url'}) ) {
423 <            $self->parseerror("No url or type given in <$name> tag");
424 <        }
425 <        if ( ! exists $self->{structures}{$$hashref{'name'}} ) {
426 <          if ( exists $$hashref{'type'}) {
427 <            # create a new object of the specified type
428 <            eval "require $$hashref{'type'} ";
429 <            if  ( $@ ) {
430 <                $self->parseerror("Unable to instantiate type=".
431 <                        $$hashref{'type'}." in <$name> .".$@);
432 <            }
457 <            $self->{structures}{$$hashref{'name'}}=
458 <                $$hashref{'type'}->new($self->config());
459 <            $self->{structures}{$$hashref{'name'}}->name($$hashref{'name'});
460 <            $self->{structures}{$$hashref{'name'}}->parent($self);
461 <            $self->{structures}{$$hashref{'name'}}->vars($hashref);
462 <          }
463 <          else { # its an activedoc
464 <                $self->{structures}{$$hashref{'name'}}=
465 <                                $self->activatedoc($$hashref{'url'});
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 >        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            }
467          $self->{structures}{$$hashref{'name'}}->setupbase();
468        }
469        else {
470             $self->parseerror("Multiply defined Structure - ".
471                                                        $$hashref{'name'});
434          }
435 +        undef $fh;
436   }
437  
438 < sub Use_Start {
438 >
439 > sub _LoadEnvFile {
440          my $self=shift;
441 <        my $name=shift;
442 <        my $hashref=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 <        $self->checktag($name,$hashref,'url');
458 <        $self->addconfigitem($$hashref{'url'});
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   }
483

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines