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.13 by williamc, Mon Mar 13 10:23:19 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 < # storeconfigobject(confiItemobj) : store a ready made ConfigItem in the local
27 < #                                       area
28 < # configitem(@keys)             : return a list of fig items that match
29 < #                                 the keys - all if left blank
30 < # parentstore()                 : set/return the parent ObjectStore
31 < # basearea(ConfigArea)          : Set/Get the base area
32 < # freebase()                    : Remove any link to a base area
33 < # bootstrapfromlocation([location]): bootstrap the object based on location.
34 < #                                 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;
52 use ActiveDoc::ActiveDoc;
49   require 5.004;
50 + use URL::URLcache;
51   use Utilities::AddDir;
52 + use Utilities::Verbose;
53   use ObjectUtilities::ObjectStore;
56 use Configuration::ConfigStore;
57 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");
65 <        $self->newparse("download");
66 <        $self->newparse("setup");
67 <        $self->newparse("setup_tools");
68 <        $self->addarchtags("setup_tools");
69 <        $self->addarchtags("setup");
70 <        $self->addtag("init","project",\&Project_Start,$self,
71 <            \&Project_text,$self,"", $self );
72 <        $self->addurltags("download");
73 <        $self->addtag("download","download",\&Download_Start,$self,
74 <                                                "", $self, "",$self);
75 <        $self->addtag("download","use",\&Use_download_Start,$self,
76 <                                                "", $self, "",$self);
77 <        $self->addurltags("setup");
78 <        $self->addurltags("setup_tools");
79 <        $self->addtag("setup_tools","use",\&Use_Start,$self, "", $self, "",$self);
80 <        $self->addtag("setup","structure",\&Structure_Start,$self,
81 <                         "", $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;
89
90        my $area;
73          if ( @_ ) {
74 <          $area=shift;
93 <          $self->config()->store($area,"BaseArea");
74 >          $self->{cache}=shift;
75          }
76 <        else {
77 <          ($area)=$self->config()->find("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();
110 <        $vers=~s/^$name\_//;
111 <        $name=$name."_".$vers;
112 <        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 ) {
131 <          $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");
140 <        
141 <        # --- and parse the setup file
142 <        $self->parse("setup");
143 <        $self->parse("setup_tools");
144 <        
145 <        # --- store bootstrap info
146 <        $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(),
150 <                                                        $self->version());
151 < }
142 >        # -- Save Environment File
143 >        $self->_SaveEnvFile();
144  
153 sub structure {
154        my $self=shift;
155        my $vr=shift;
156        return $self->{structures}{$vr};
145   }
146  
147 < sub structurelist {
147 > sub configurationdir {
148          my $self=shift;
149 <        return ( keys %{$self->{structures}} );
149 >        if ( @_ ) {
150 >          $self->{configurationdir}=shift;
151 >        }
152 >        return (defined $self->{configurationdir})?$self->{configurationdir}:undef;
153   }
154  
155 < sub _setupstore {
155 > sub toolbox {
156          my $self=shift;
157 <
158 <        # --- make a new ConfigStore at the location and add it to the db list
159 <        my $ad=Configuration::ConfigStore->new($self->location().
160 <                                "/".$self->{admindir}, $self->arch());
170 <
171 <        $self->parentconfig($self->config());
172 < #        $self->config(Configuration::ConfigureStore->new());
173 < #        $self->config()->db("local",$ad);
174 < #        $self->config()->db("parent",$self->parentconfig());
175 < #        $self->config()->policy("cache","local");
176 <        $self->config($ad);
177 <        $self->config()->basedoc($self->parentconfig()->basedoc());
157 >        if ( ! defined $self->{toolbox} ) {
158 >          $self->{toolbox}=BuildSystem::ToolBox->new($self);
159 >        }
160 >        return $self->{toolbox};
161   }
162  
163 < sub bootstrapfromlocation {
163 > sub requirementsdoc {
164          my $self=shift;
165 <        
166 <        if ( ! defined $self->location(@_) ) {
167 <          $self->error("Unable to locate the top of local configuration area");
168 <        }
169 <        $self->verbose("Found top ".$self->location());
187 <        $self->_setupstore();
188 <        my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat";
189 <        if ( -e $infofile ) {
190 <             $self->restore($infofile);
165 >        if ( @_ ) {
166 >          $self->{reqdoc}=shift;
167 >        }
168 >        if ( defined $self->{reqdoc} ) {
169 >          return $self->location()."/".$self->{reqdoc};
170          }
171          else {
172 <             $self->error("Area corrupted - cannot find $infofile");
172 >          return undef;
173          }
174   }
175  
176 < sub parentconfig {
198 <        my $self=shift;
199 <        @_?$self->{parentconfig}=shift
200 <          :$self->{parentconfig};
201 < }
202 <
203 < sub store {
176 > sub scramversion {
177          my $self=shift;
178 <        my $location=shift;
179 <
180 <        my $fh=$self->openfile(">".$location);
181 <        $self->savevar($fh,"location", $self->location());
182 <        $self->savevar($fh,"url", $self->url());
183 <        $self->savevar($fh,"name", $self->name());
184 <        $self->savevar($fh,"version", $self->version());
185 <        $fh->close();
186 <
187 <        $self->_storestructures();
188 < }
189 <
190 < sub satellite {
191 <        my $self=shift;
219 <        my $newarea=$self->copy(@_);
220 <        $newarea->_makesatellites();
221 <        return $newarea;
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 copy {
194 > sub bootstrapfromlocation {
195          my $self=shift;
226        use File::Basename;
227        # create the area
196  
197 <        my $destination;
198 <        if ( @_ ) {
199 <         $destination=shift;
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 <          my($location,$name)=$self->_defaultoptions();
206 <          $destination=$location."/".$name
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 <        #AddDir::adddir(dirname($destination)."/".$self->{admindir});
238 <        #AddDir::adddir($destination."/".$self->{admindir});
239 <        
240 <        # copy across the admin dir
241 <        $temp=$self->location()."/".$self->{admindir};
242 <        AddDir::copydir($temp,"$destination/".$self->{admindir});
243 <        # create a new object based on the new area
244 <        my $newarea=ref($self)->new($self->parentconfig());
245 <        $newarea->bootstrapfromlocation($destination);
246 <        # save it with the new location info
247 <        $newarea->store($self->location()."/".$self->{admindir}.
248 <                                                        "/ConfigArea.dat");
249 <        return $newarea;
250 < }
251 <
252 < sub restore {
253 <        my $self=shift;
254 <        my $location=shift;
255 <
256 <        my $fh=$self->openfile("<".$location);
257 <        my $varhash={};
258 <        $self->restorevars($fh,$varhash);
259 <        if ( ! defined $self->location() ) {
260 <          $self->location($$varhash{"location"});
261 <        }
262 <        $self->_setupstore();
263 <        $self->url($$varhash{"url"});
264 <        $self->name($$varhash{"name"});
265 <        $self->version($$varhash{"version"});
266 <        $fh->close();
267 <
268 <        $self->_restorestructures();
269 < }
270 <
271 < sub name {
272 <        my $self=shift;
273 <
274 <        @_?$self->{name}=shift
275 <          :$self->{name};
276 < }
277 <
278 < sub version {
279 <        my $self=shift;
280 <
281 <        @_?$self->{version}=shift
282 <          :$self->{version};
210 >        return $rv;
211   }
212  
213   sub location {
# Line 300 | 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 318 | Line 254 | sub searchlocation {
254          return $rv?$thispath:undef;
255   }
256  
257 < sub meta {
257 > sub archname {
258          my $self=shift;
259 +        if ( @_ ) {
260 +          $self->{archname}=shift;
261 +        }
262 +        return $self->{archname};
263 + }
264  
265 <        my $string=$self->name()." ".$self->version()." located at :\n  ".
266 <                $self->location;
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 configitem {
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 <        return ($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();
341 <        $docref->save();
342 < #       $self->config()->storepolicy("local");
314 >        # copy across the admin dir
315 >        my $temp=$self->location()."/".$self->{admindir};
316 >        AddDir::copydir($temp,"$destination/".$self->{admindir});
317   }
318  
319 < sub storeconfigobject {
319 > sub align {
320          my $self=shift;
321 <        my $obj=shift;
322 <        $obj->save($self->config());
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 downloadtotop {
347 > sub copysetup {
348          my $self=shift;
349 <        my $url=shift;
350 <        my $dir=shift;
351 <        
352 <        # only download once
353 <        if ( ! -e $self->location()."/".$dir ) {
354 <          $self->{urlhandler}->download($url,$self->location()."/".$dir);
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 _makesatellites {
364 > sub copyenv {
365          my $self=shift;
366 <        foreach $st ( values %{$self->{structures}} ) {
367 <           $st->setupsatellite()
366 >        my $hashref=shift;
367 >        
368 >        foreach $elem ( keys %{$self->{ENV}} ) {
369 >           $$hashref{$elem}=$self->{ENV}{$elem};
370          }
371   }
372  
373 < sub _storestructures {
373 > sub arch {
374          my $self=shift;
375 <        foreach $struct ( values %{$self->{structures}} ) {
372 <          $self->config()->store($struct, "Structures", $struct->name());
373 <        }
375 >        return $ENV{SCRAM_ARCH};
376   }
377  
378 < sub _restorestructures {
378 > sub linkto {
379          my $self=shift;
380 <        my @strs=$self->config()->find("Structures");
381 <        foreach $struct ( @strs ) {
382 <          $struct->parent($self);
383 <          $self->{structures}{$struct->name()}=$struct;
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 _defaultoptions {
392 > sub unlinkarea {
393          my $self=shift;
394 <        my $name;
395 <        my $location;
396 <
390 <        # --- find out the location - default is cwd
391 <        $location=$self->option("ConfigArea_location");
392 <        if ( ! defined $location ) {
393 <                $location=cwd();
394 <        }
395 <        elsif ( $location!~/^\// ) {
396 <                $location=cwd()."/".$location;
397 <        }
398 <
399 <        # --- find area directory name , default name projectname_version
400 <        $name=$self->option("ConfigArea_name");
401 <        if ( ! defined $name ) {
402 <          $name=$self->defaultdirname();
403 <        }
404 <        return ($location,$name);
394 >        undef $self->{linkarea};
395 >        $self->{linkarea}=undef;
396 >        $self->save();
397   }
406 # -------------- Tags ---------------------------------
407 # -- init parse
408 sub Project_Start {
409        my $self=shift;
410        my $name=shift;
411        my $hashref=shift;
412
413        $self->checktag($name,$hashref,'name');
414        $self->checktag($name,$hashref,'version');
398  
399 <        $self->name($$hashref{'name'});
400 <        $self->version($$hashref{'version'});
399 > sub linkarea {
400 >        my $self=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 <
421 < sub Project_text {
409 > sub save {
410          my $self=shift;
411 <        my $name=shift;
424 <        my $string=shift;
425 <
426 <        print $string;
411 >        $self->_SaveEnvFile();
412   }
413  
414 < # ---- download parse
414 > # ---- support routines
415  
416 < sub Download_Start {
416 > sub _SaveEnvFile {
417          my $self=shift;
418 <        my $name=shift;
419 <        my $hashref=shift;
420 <
421 <        $self->checktag($name,$hashref,'url');
422 <        $self->checktag($name,$hashref,'location');
423 <        if ( $$hashref{'location'}!~/^\w/ ) {
424 <          $self->parseerror("location must start with an".
425 <                " alphanumeric character");
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 >          }
434          }
435 <        print "Downloading .... ".$$hashref{'url'}."\n";
443 <        $self->downloadtotop($$hashref{'url'},$$hashref{'location'});
435 >        undef $fh;
436   }
437  
446 sub Use_download_Start {
447        my $self=shift;
448        my $name=shift;
449        my $hashref=shift;
438  
439 <        $self->checktag($name,$hashref,'url');
452 <        print "Downloading .... ".$$hashref{'url'}."\n";
453 <        $self->getfile($$hashref{'url'});
454 < }
455 <
456 < # --- setup parse
457 <
458 < sub Structure_Start {
439 > sub _LoadEnvFile {
440          my $self=shift;
460        my $name=shift;
461        my $hashref=shift;
441  
442 <        $self->checktag($name,$hashref,'name');
443 <        if ( !(( exists $$hashref{'type'}) || ( exists $$hashref{'url'})) ) {
444 <            $self->parseerror("No url or type given in <$name> tag");
445 <        }
446 <        if ( ! exists $self->{structures}{$$hashref{'name'}} ) {
447 <          if ( exists $$hashref{'type'}) {
448 <            # create a new object of the specified type
449 <            eval "require $$hashref{'type'} ";
450 <            if  ( $@ ) {
451 <                $self->parseerror("Unable to instantiate type=".
452 <                        $$hashref{'type'}." in <$name> .".$@);
453 <            }
454 <            $self->{structures}{$$hashref{'name'}}=
455 <                $$hashref{'type'}->new($self->config());
456 <            $self->{structures}{$$hashref{'name'}}->name($$hashref{'name'});
457 <            $self->{structures}{$$hashref{'name'}}->parent($self);
458 <            $self->{structures}{$$hashref{'name'}}->vars($hashref);
459 <            $self->{structures}{$$hashref{'name'}}->arch($self->arch());
460 <          }
461 <          else { # its an activedoc
462 <                $self->{structures}{$$hashref{'name'}}=
463 <                                $self->activatedoc($$hashref{'url'});
464 <          }
465 <          $self->{structures}{$$hashref{'name'}}->setupbase();
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->parseerror("Multiply defined Structure - ".
490 <                                                        $$hashref{'name'});
475 >          $self->{ENV}{"RELEASETOP"}=$self->location();
476          }
477   }
493
494 sub Use_Start {
495        my $self=shift;
496        my $name=shift;
497        my $hashref=shift;
498        
499        $self->checktag($name,$hashref,'url');
500        $self->addconfigitem($$hashref{'url'});
501 }
502

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines