1 |
|
# |
2 |
|
# ConfigArea.pm |
3 |
|
# |
4 |
< |
# Originally Written by Christopher Williams |
4 |
> |
# Written by Christopher Williams |
5 |
|
# |
6 |
|
# Description |
7 |
|
# ----------- |
14 |
|
# |
15 |
|
# Interface |
16 |
|
# --------- |
17 |
< |
# new(ActiveConfig) : A new ConfigArea object |
18 |
< |
# setup() : setup the configuration area |
19 |
< |
# location([dir]) : set/return the location of the area |
20 |
< |
# version([version]) : set/return the version of the area |
21 |
< |
# name([name]) : set/return the name of the area |
22 |
< |
# store(location) : store data in file location |
23 |
< |
# restore(location) : restore data from file location |
24 |
< |
# meta() : return a description string of the area |
25 |
< |
# addconfigitem(url) : add a new item to the area |
26 |
< |
# 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 |
17 |
> |
# new() : A new ConfigArea object |
18 |
> |
# location([dir]) : set/return the location of the work area |
19 |
> |
# bootstrapfromlocation([location]) : bootstrap the object based on location. |
20 |
> |
# no location specified - cwd used |
21 |
> |
# return 0 if succesful 1 otherwise |
22 |
> |
# requirementsdoc() : get set the requirements doc |
23 |
|
# searchlocation([startdir]) : returns the location directory. search starts |
24 |
|
# from cwd if not specified |
25 |
|
# defaultdirname() : return the default directory name string |
26 |
< |
# copy(location) : make a copy of the current area at the |
27 |
< |
# specified location - defaults to cwd/default |
28 |
< |
# if not specified . ConfigArea_name, |
29 |
< |
# ConfigArea_location also override . |
30 |
< |
# Return an object representing the area |
31 |
< |
# satellite() : make a satellite area based on $self |
32 |
< |
# arch([archobj]) : Set/get the architecture object |
33 |
< |
# structure(name) : return the object corresponding to the |
34 |
< |
# structure name |
35 |
< |
# structurelist() : return list of structure objectS |
36 |
< |
# downloadtotop(dir,url) : download the url to a dir in the config area |
47 |
< |
# |
26 |
> |
# scramversion() : return the scram version associated with |
27 |
> |
# area |
28 |
> |
# configurationdir() : return the location of the project |
29 |
> |
# configuration directory |
30 |
> |
# copy(location) : copy a configuration |
31 |
> |
# copysetup(location) : copy the architecture specific tool setup |
32 |
> |
# returns 0 if successful, 1 otherwise |
33 |
> |
# copyenv($ref) : copy the areas environment into the hashref |
34 |
> |
# toolbox() : return the areas toolbox object |
35 |
> |
# - temporary |
36 |
> |
# align() : adjust hard paths to suit local loaction |
37 |
|
|
38 |
|
package Configuration::ConfigArea; |
50 |
– |
use ActiveDoc::ActiveDoc; |
39 |
|
require 5.004; |
40 |
|
use Utilities::AddDir; |
41 |
< |
use ObjectUtilities::ObjectStore; |
54 |
< |
use Configuration::ConfigStore; |
55 |
< |
use Configuration::ActiveDoc_arch; |
41 |
> |
use Utilities::Verbose; |
42 |
|
use Cwd; |
43 |
< |
@ISA=qw(Configuration::ActiveDoc_arch ObjectUtilities::StorableObject); |
43 |
> |
@ISA=qw(Utilities::Verbose); |
44 |
|
|
45 |
< |
sub init { |
46 |
< |
my $self=shift; |
47 |
< |
|
48 |
< |
$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->addurltags("setup_tools"); |
77 |
< |
$self->addtag("setup_tools","use",\&Use_Start,$self, "", $self, "",$self); |
78 |
< |
$self->addtag("setup","structure",\&Structure_Start,$self, |
79 |
< |
"", $self, "",$self); |
45 |
> |
sub new { |
46 |
> |
my $class=shift; |
47 |
> |
my $self={}; |
48 |
> |
bless $self, $class; |
49 |
|
|
50 |
|
# data init |
51 |
< |
$self->{admindir}=".SCRAM"; |
51 |
> |
$self->{admindir}=".SCRAM"; |
52 |
> |
|
53 |
> |
return $self; |
54 |
|
} |
55 |
|
|
56 |
< |
sub basearea { |
56 |
> |
sub configurationdir { |
57 |
|
my $self=shift; |
87 |
– |
|
88 |
– |
my $area; |
58 |
|
if ( @_ ) { |
59 |
< |
$area=shift; |
91 |
< |
$self->config()->store($area,"BaseArea"); |
59 |
> |
$self->{configurationdir}=shift; |
60 |
|
} |
61 |
< |
else { |
62 |
< |
($area)=$self->config()->find("BaseArea"); |
61 |
> |
if ( ! defined $self->{configurationdir} ) { |
62 |
> |
$self->_LoadEnvFile(); |
63 |
> |
$self->{configurationdir}=$self->{ENV}{projconfigdir}; |
64 |
|
} |
65 |
< |
return $area; |
65 |
> |
return $self->{configurationdir}; |
66 |
|
} |
67 |
|
|
68 |
< |
sub freebase { |
68 |
> |
sub toolbox { |
69 |
|
my $self=shift; |
70 |
< |
$self->config()->delete("BaseArea"); |
71 |
< |
} |
103 |
< |
|
104 |
< |
sub defaultdirname { |
105 |
< |
my $self=shift; |
106 |
< |
my $name=$self->name(); |
107 |
< |
my $vers=$self->version(); |
108 |
< |
$vers=~s/^$name\_//; |
109 |
< |
$name=$name."_".$vers; |
110 |
< |
return $name; |
111 |
< |
} |
112 |
< |
|
113 |
< |
|
114 |
< |
sub setup { |
115 |
< |
my $self=shift; |
116 |
< |
|
117 |
< |
# --- find out the location - default is cwd |
118 |
< |
my $location=$self->option("ConfigArea_location"); |
119 |
< |
if ( ! defined $location ) { |
120 |
< |
$location=cwd(); |
70 |
> |
if ( ! defined $self->{toolbox} ) { |
71 |
> |
$self->{toolbox}=BuildSystem::ToolBox->new($self); |
72 |
|
} |
73 |
< |
elsif ( $location!~/^\// ) { |
123 |
< |
$location=cwd()."/".$location; |
124 |
< |
} |
125 |
< |
|
126 |
< |
# --- find area directory name , default name projectname_version |
127 |
< |
my $name=$self->option("ConfigArea_name"); |
128 |
< |
if ( ! defined $name ) { |
129 |
< |
$name=$self->defaultdirname(); |
130 |
< |
} |
131 |
< |
$self->location($location."/".$name); |
132 |
< |
|
133 |
< |
# make a new store handler |
134 |
< |
$self->_setupstore(); |
135 |
< |
|
136 |
< |
# --- download everything first |
137 |
< |
$self->parse("download"); |
138 |
< |
|
139 |
< |
# --- and parse the setup file |
140 |
< |
$self->parse("setup"); |
141 |
< |
$self->parse("setup_tools"); |
142 |
< |
|
143 |
< |
# --- store bootstrap info |
144 |
< |
$self->store($self->location()."/".$self->{admindir}."/ConfigArea.dat"); |
145 |
< |
|
146 |
< |
# --- store self in original database |
147 |
< |
$self->parentconfig()->store($self,"ConfigArea",$self->name(), |
148 |
< |
$self->version()); |
73 |
> |
return $self->{toolbox}; |
74 |
|
} |
75 |
|
|
76 |
< |
sub structure { |
76 |
> |
sub requirementsdoc { |
77 |
|
my $self=shift; |
78 |
< |
my $vr=shift; |
79 |
< |
return $self->{structures}{$vr}; |
80 |
< |
} |
81 |
< |
|
82 |
< |
sub structurelist { |
83 |
< |
my $self=shift; |
84 |
< |
return ( keys %{$self->{structures}} ); |
85 |
< |
} |
86 |
< |
|
87 |
< |
sub _setupstore { |
88 |
< |
my $self=shift; |
89 |
< |
|
90 |
< |
# --- make a new ConfigStore at the location and add it to the db list |
91 |
< |
my $ad=Configuration::ConfigStore->new($self->location(). |
92 |
< |
"/".$self->{admindir}, $self->arch()); |
93 |
< |
|
94 |
< |
$self->parentconfig($self->config()); |
95 |
< |
# $self->config(Configuration::ConfigureStore->new()); |
96 |
< |
# $self->config()->db("local",$ad); |
97 |
< |
# $self->config()->db("parent",$self->parentconfig()); |
98 |
< |
# $self->config()->policy("cache","local"); |
99 |
< |
$self->config($ad); |
100 |
< |
$self->config()->basedoc($self->parentconfig()->basedoc()); |
101 |
< |
} |
177 |
< |
|
178 |
< |
sub bootstrapfromlocation { |
179 |
< |
my $self=shift; |
180 |
< |
|
181 |
< |
if ( ! defined $self->location(@_) ) { |
182 |
< |
$self->error("Unable to locate the top of local configuration area"); |
183 |
< |
} |
184 |
< |
$self->verbose("Found top ".$self->location()); |
185 |
< |
$self->_setupstore(); |
186 |
< |
my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat"; |
187 |
< |
if ( -e $infofile ) { |
188 |
< |
$self->restore($infofile); |
189 |
< |
} |
190 |
< |
else { |
191 |
< |
$self->error("Area corrupted - cannot find $infofile"); |
78 |
> |
if ( @_ ) { |
79 |
> |
$self->{reqdoc}=shift; |
80 |
> |
} |
81 |
> |
if ( ! defined $self->{reqdoc} ) { |
82 |
> |
$self->_LoadEnvFile(); |
83 |
> |
$self->{reqdoc}=$self->{ENV}{SCRAM_ProjReqsDoc}; |
84 |
> |
} |
85 |
> |
return $self->{reqdoc}; |
86 |
> |
} |
87 |
> |
|
88 |
> |
sub scramversion { |
89 |
> |
my $self=shift; |
90 |
> |
if ( ! defined $self->{scramversion} ) { |
91 |
> |
my $filename=$self->location()."/".$self->configurationdir()."/". |
92 |
> |
"scram_version"; |
93 |
> |
if ( -f $filename ) { |
94 |
> |
use FileHandle; |
95 |
> |
$fh=FileHandle->new(); |
96 |
> |
open ($fh, "<".$filename); |
97 |
> |
my $version=<$fh>; |
98 |
> |
chomp $version; |
99 |
> |
$self->{scramversion}=$version; |
100 |
> |
undef $fh; |
101 |
> |
} |
102 |
|
} |
103 |
+ |
return $self->{scramversion}; |
104 |
|
} |
105 |
|
|
106 |
< |
sub parentconfig { |
196 |
< |
my $self=shift; |
197 |
< |
@_?$self->{parentconfig}=shift |
198 |
< |
:$self->{parentconfig}; |
199 |
< |
} |
200 |
< |
|
201 |
< |
sub store { |
202 |
< |
my $self=shift; |
203 |
< |
my $location=shift; |
204 |
< |
|
205 |
< |
my $fh=$self->openfile(">".$location); |
206 |
< |
$self->savevar($fh,"location", $self->location()); |
207 |
< |
$self->savevar($fh,"url", $self->url()); |
208 |
< |
$self->savevar($fh,"name", $self->name()); |
209 |
< |
$self->savevar($fh,"version", $self->version()); |
210 |
< |
$fh->close(); |
211 |
< |
|
212 |
< |
$self->_storestructures(); |
213 |
< |
} |
214 |
< |
|
215 |
< |
sub satellite { |
216 |
< |
my $self=shift; |
217 |
< |
my $newarea=$self->copy(@_); |
218 |
< |
$newarea->_makesatellites(); |
219 |
< |
return $newarea; |
220 |
< |
} |
221 |
< |
|
222 |
< |
sub copy { |
106 |
> |
sub bootstrapfromlocation { |
107 |
|
my $self=shift; |
224 |
– |
use File::Basename; |
225 |
– |
# create the area |
108 |
|
|
109 |
< |
my $destination; |
110 |
< |
if ( @_ ) { |
111 |
< |
$destination=shift; |
109 |
> |
my $rv=0; |
110 |
> |
|
111 |
> |
my $location; |
112 |
> |
if ( ! defined ($location=$self->searchlocation(@_)) ) { |
113 |
> |
$rv=1; |
114 |
> |
$self->verbose("Unable to locate the top of local configuration area"); |
115 |
|
} |
116 |
|
else { |
117 |
< |
my($location,$name)=$self->_defaultoptions(); |
118 |
< |
$destination=$location."/".$name |
119 |
< |
} |
120 |
< |
#AddDir::adddir(dirname($destination)."/".$self->{admindir}); |
236 |
< |
#AddDir::adddir($destination."/".$self->{admindir}); |
237 |
< |
|
238 |
< |
# copy across the admin dir |
239 |
< |
$temp=$self->location()."/".$self->{admindir}; |
240 |
< |
AddDir::copydir($temp,"$destination/".$self->{admindir}); |
241 |
< |
# create a new object based on the new area |
242 |
< |
my $newarea=ref($self)->new($self->parentconfig()); |
243 |
< |
$newarea->bootstrapfromlocation($destination); |
244 |
< |
# save it with the new location info |
245 |
< |
$newarea->store($self->location()."/".$self->{admindir}. |
246 |
< |
"/ConfigArea.dat"); |
247 |
< |
return $newarea; |
248 |
< |
} |
249 |
< |
|
250 |
< |
sub restore { |
251 |
< |
my $self=shift; |
252 |
< |
my $location=shift; |
253 |
< |
|
254 |
< |
my $fh=$self->openfile("<".$location); |
255 |
< |
my $varhash={}; |
256 |
< |
$self->restorevars($fh,$varhash); |
257 |
< |
if ( ! defined $self->location() ) { |
258 |
< |
$self->location($$varhash{"location"}); |
117 |
> |
$self->location($location); |
118 |
> |
$self->verbose("Found top ".$self->location()); |
119 |
> |
my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat"; |
120 |
> |
$self->_LoadEnvFile(); |
121 |
|
} |
122 |
< |
$self->_setupstore(); |
261 |
< |
$self->url($$varhash{"url"}); |
262 |
< |
$self->name($$varhash{"name"}); |
263 |
< |
$self->version($$varhash{"version"}); |
264 |
< |
$fh->close(); |
265 |
< |
|
266 |
< |
$self->_restorestructures(); |
267 |
< |
} |
268 |
< |
|
269 |
< |
sub name { |
270 |
< |
my $self=shift; |
271 |
< |
|
272 |
< |
@_?$self->{name}=shift |
273 |
< |
:$self->{name}; |
274 |
< |
} |
275 |
< |
|
276 |
< |
sub version { |
277 |
< |
my $self=shift; |
278 |
< |
|
279 |
< |
@_?$self->{version}=shift |
280 |
< |
:$self->{version}; |
122 |
> |
return $rv; |
123 |
|
} |
124 |
|
|
125 |
|
sub location { |
140 |
|
|
141 |
|
#start search in current directory if not specified |
142 |
|
my $thispath; |
143 |
< |
@_?$thispath=shift |
144 |
< |
:$thispath=cwd(); |
143 |
> |
if ( @_ ) { |
144 |
> |
$thispath=shift |
145 |
> |
} |
146 |
> |
else { |
147 |
> |
$thispath=cwd(); |
148 |
> |
} |
149 |
|
|
150 |
|
my $rv=0; |
151 |
|
|
152 |
+ |
# chop off any files - we only want dirs |
153 |
+ |
if ( -f $thispath ) { |
154 |
+ |
$thispath=~s/(.*)\/.*/$1/; |
155 |
+ |
} |
156 |
|
Sloop:{ |
157 |
|
do { |
158 |
< |
# print "Searching $thispath\n"; |
158 |
> |
$self->verbose("Searching $thispath"); |
159 |
|
if ( -e "$thispath/".$self->{admindir} ) { |
160 |
< |
# print "Found\n"; |
160 |
> |
$self->verbose("Found\n"); |
161 |
|
$rv=1; |
162 |
|
last Sloop; |
163 |
|
} |
166 |
|
return $rv?$thispath:undef; |
167 |
|
} |
168 |
|
|
169 |
< |
sub meta { |
320 |
< |
my $self=shift; |
321 |
< |
|
322 |
< |
my $string=$self->name()." ".$self->version()." located at :\n ". |
323 |
< |
$self->location; |
324 |
< |
} |
325 |
< |
|
326 |
< |
sub configitem { |
327 |
< |
my $self=shift; |
328 |
< |
|
329 |
< |
return ($self->config()->find("ConfigItem",@_)); |
330 |
< |
} |
331 |
< |
|
332 |
< |
sub addconfigitem { |
169 |
> |
sub copy { |
170 |
|
my $self=shift; |
171 |
< |
my $url=shift; |
171 |
> |
my $destination=shift; |
172 |
|
|
173 |
< |
my $docref=$self->activatedoc($url); |
174 |
< |
# Set up the document |
175 |
< |
$docref->setup(); |
339 |
< |
$docref->save(); |
340 |
< |
# $self->config()->storepolicy("local"); |
173 |
> |
# copy across the admin dir |
174 |
> |
my $temp=$self->location()."/".$self->{admindir}; |
175 |
> |
AddDir::copydir($temp,"$destination/".$self->{admindir}); |
176 |
|
} |
177 |
|
|
178 |
< |
sub downloadtotop { |
178 |
> |
sub align { |
179 |
|
my $self=shift; |
180 |
< |
my $url=shift; |
346 |
< |
my $dir=shift; |
347 |
< |
|
348 |
< |
# only download once |
349 |
< |
if ( ! -e $self->location()."/".$dir ) { |
350 |
< |
$self->{urlhandler}->download($url,$self->location()."/".$dir); |
351 |
< |
} |
352 |
< |
} |
180 |
> |
use File::Copy; |
181 |
|
|
182 |
< |
sub _makesatellites { |
183 |
< |
my $self=shift; |
184 |
< |
foreach $st ( values %{$self->{structures}} ) { |
185 |
< |
$st->setupsatellite() |
186 |
< |
} |
182 |
> |
$self->_LoadEnvFile(); |
183 |
> |
my $Envfile=$self->location()."/".$self->{admindir}."/Environment"; |
184 |
> |
my $tmpEnvfile=$Envfile.".bak"; |
185 |
> |
my $rel=$self->{ENV}{RELEASETOP}; |
186 |
> |
my $local=$self->location(); |
187 |
> |
|
188 |
> |
rename( $Envfile, $tmpEnvfile ); |
189 |
> |
use FileHandle; |
190 |
> |
my $fh=FileHandle->new(); |
191 |
> |
my $fout=FileHandle->new(); |
192 |
> |
open ( $fh, "<".$tmpEnvfile ) or |
193 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
194 |
> |
.$self->location().")\n $!"); |
195 |
> |
open ( $fout, ">".$Envfile ) or |
196 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
197 |
> |
.$self->location().")\n $!"); |
198 |
> |
while ( <$fh> ) { |
199 |
> |
$_=~s/\Q$rel\L/$local/g; |
200 |
> |
print $fout $_; |
201 |
> |
} |
202 |
> |
undef $fh; |
203 |
> |
undef $fout; |
204 |
|
} |
205 |
|
|
206 |
< |
sub _storestructures { |
206 |
> |
sub copysetup { |
207 |
|
my $self=shift; |
208 |
< |
foreach $struct ( values %{$self->{structures}} ) { |
364 |
< |
$self->config()->store($struct, "Structures", $struct->name()); |
365 |
< |
} |
366 |
< |
} |
208 |
> |
my $dest=shift; |
209 |
|
|
210 |
< |
sub _restorestructures { |
211 |
< |
my $self=shift; |
212 |
< |
my @strs=$self->config()->find("Structures"); |
213 |
< |
foreach $struct ( @strs ) { |
214 |
< |
$struct->parent($self); |
215 |
< |
$self->{structures}{$struct->name()}=$struct; |
210 |
> |
my $rv=1; |
211 |
> |
# copy across the admin dir |
212 |
> |
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
213 |
> |
my $temp2=$dest."/".$self->{admindir}."/".$self->arch(); |
214 |
> |
if ( $temp ne $temp2 ) { |
215 |
> |
if ( -d $temp ) { |
216 |
> |
AddDir::copydir($temp,$temp2); |
217 |
> |
$rv=0; |
218 |
> |
} |
219 |
|
} |
220 |
+ |
return $rv; |
221 |
|
} |
222 |
|
|
223 |
< |
sub _defaultoptions { |
378 |
< |
my $self=shift; |
379 |
< |
my $name; |
380 |
< |
my $location; |
381 |
< |
|
382 |
< |
# --- find out the location - default is cwd |
383 |
< |
$location=$self->option("ConfigArea_location"); |
384 |
< |
if ( ! defined $location ) { |
385 |
< |
$location=cwd(); |
386 |
< |
} |
387 |
< |
elsif ( $location!~/^\// ) { |
388 |
< |
$location=cwd()."/".$location; |
389 |
< |
} |
390 |
< |
|
391 |
< |
# --- find area directory name , default name projectname_version |
392 |
< |
$name=$self->option("ConfigArea_name"); |
393 |
< |
if ( ! defined $name ) { |
394 |
< |
$name=$self->defaultdirname(); |
395 |
< |
} |
396 |
< |
return ($location,$name); |
397 |
< |
} |
398 |
< |
# -------------- Tags --------------------------------- |
399 |
< |
# -- init parse |
400 |
< |
sub Project_Start { |
223 |
> |
sub copyenv { |
224 |
|
my $self=shift; |
402 |
– |
my $name=shift; |
225 |
|
my $hashref=shift; |
226 |
< |
|
227 |
< |
$self->checktag($name,$hashref,'name'); |
228 |
< |
$self->checktag($name,$hashref,'version'); |
407 |
< |
|
408 |
< |
$self->name($$hashref{'name'}); |
409 |
< |
$self->version($$hashref{'version'}); |
410 |
< |
} |
411 |
< |
|
412 |
< |
|
413 |
< |
sub Project_text { |
414 |
< |
my $self=shift; |
415 |
< |
my $name=shift; |
416 |
< |
my $string=shift; |
417 |
< |
|
418 |
< |
print $string; |
419 |
< |
} |
420 |
< |
|
421 |
< |
# ---- download parse |
422 |
< |
|
423 |
< |
sub Download_Start { |
424 |
< |
my $self=shift; |
425 |
< |
my $name=shift; |
426 |
< |
my $hashref=shift; |
427 |
< |
|
428 |
< |
$self->checktag($name,$hashref,'url'); |
429 |
< |
$self->checktag($name,$hashref,'location'); |
430 |
< |
if ( $$hashref{'location'}!~/^\w/ ) { |
431 |
< |
$self->parseerror("location must start with an". |
432 |
< |
" alphanumeric character"); |
226 |
> |
|
227 |
> |
foreach $elem ( keys %{$self->{ENV}} ) { |
228 |
> |
$$hashref{$elem}=$self->{ENV}{$elem}; |
229 |
|
} |
434 |
– |
print "Downloading .... ".$$hashref{'url'}."\n"; |
435 |
– |
$self->downloadtotop($$hashref{'url'},$$hashref{'location'}); |
230 |
|
} |
231 |
|
|
232 |
< |
sub Use_download_Start { |
232 |
> |
sub arch { |
233 |
|
my $self=shift; |
234 |
< |
my $name=shift; |
441 |
< |
my $hashref=shift; |
442 |
< |
|
443 |
< |
$self->checktag($name,$hashref,'url'); |
444 |
< |
print "Downloading .... ".$$hashref{'url'}."\n"; |
445 |
< |
$self->getfile($$hashref{'url'}); |
234 |
> |
return $ENV{SCRAM_ARCH}; |
235 |
|
} |
236 |
|
|
237 |
< |
# --- setup parse |
238 |
< |
|
450 |
< |
sub Structure_Start { |
237 |
> |
# ---- support routines |
238 |
> |
sub _LoadEnvFile { |
239 |
|
my $self=shift; |
452 |
– |
my $name=shift; |
453 |
– |
my $hashref=shift; |
454 |
– |
|
455 |
– |
$self->checktag($name,$hashref,'name'); |
456 |
– |
if ( !(( exists $$hashref{'type'}) || ( exists $$hashref{'url'})) ) { |
457 |
– |
$self->parseerror("No url or type given in <$name> tag"); |
458 |
– |
} |
459 |
– |
if ( ! exists $self->{structures}{$$hashref{'name'}} ) { |
460 |
– |
if ( exists $$hashref{'type'}) { |
461 |
– |
# create a new object of the specified type |
462 |
– |
eval "require $$hashref{'type'} "; |
463 |
– |
if ( $@ ) { |
464 |
– |
$self->parseerror("Unable to instantiate type=". |
465 |
– |
$$hashref{'type'}." in <$name> .".$@); |
466 |
– |
} |
467 |
– |
$self->{structures}{$$hashref{'name'}}= |
468 |
– |
$$hashref{'type'}->new($self->config()); |
469 |
– |
$self->{structures}{$$hashref{'name'}}->name($$hashref{'name'}); |
470 |
– |
$self->{structures}{$$hashref{'name'}}->parent($self); |
471 |
– |
$self->{structures}{$$hashref{'name'}}->vars($hashref); |
472 |
– |
$self->{structures}{$$hashref{'name'}}->arch($self->arch()); |
473 |
– |
} |
474 |
– |
else { # its an activedoc |
475 |
– |
$self->{structures}{$$hashref{'name'}}= |
476 |
– |
$self->activatedoc($$hashref{'url'}); |
477 |
– |
} |
478 |
– |
$self->{structures}{$$hashref{'name'}}->setupbase(); |
479 |
– |
} |
480 |
– |
else { |
481 |
– |
$self->parseerror("Multiply defined Structure - ". |
482 |
– |
$$hashref{'name'}); |
483 |
– |
} |
484 |
– |
} |
240 |
|
|
241 |
< |
sub Use_Start { |
242 |
< |
my $self=shift; |
243 |
< |
my $name=shift; |
244 |
< |
my $hashref=shift; |
245 |
< |
|
246 |
< |
$self->checktag($name,$hashref,'url'); |
247 |
< |
$self->addconfigitem($$hashref{'url'}); |
241 |
> |
use FileHandle; |
242 |
> |
my $fh=FileHandle->new(); |
243 |
> |
open ( $fh, "<".$self->location()."/".$self->{admindir}."/". |
244 |
> |
"Environment" ) or |
245 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
246 |
> |
.$self->location().")\n $!"); |
247 |
> |
while ( <$fh> ) { |
248 |
> |
chomp; |
249 |
> |
next if /^#/; |
250 |
> |
next if /^\s*$/ ; |
251 |
> |
($name, $value)=split /=/; |
252 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
253 |
> |
} |
254 |
> |
undef $fh; |
255 |
|
} |
494 |
– |
|