1 |
< |
# |
2 |
< |
# ConfigArea.pm |
3 |
< |
# |
4 |
< |
# Originally Written by Christopher Williams |
5 |
< |
# |
6 |
< |
# Description |
7 |
< |
# ----------- |
8 |
< |
# creates and manages a configuration area |
9 |
< |
# |
10 |
< |
# Options |
11 |
< |
# ------- |
12 |
< |
# ConfigArea_location |
13 |
< |
# ConfigArea_name |
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 |
< |
# 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 |
35 |
< |
# searchlocation([startdir]) : returns the location directory. search starts |
36 |
< |
# from cwd if not specified |
37 |
< |
# defaultdirname() : return the default directory name string |
38 |
< |
# copy(location) : make a copy of the current area at the |
39 |
< |
# specified location - defaults to cwd/default |
40 |
< |
# if not specified . ConfigArea_name, |
41 |
< |
# ConfigArea_location also override . |
42 |
< |
# Return an object representing the area |
43 |
< |
# satellite() : make a satellite area based on $self |
44 |
< |
# arch([archobj]) : Set/get the architecture object |
45 |
< |
# structure(name) : return the object corresponding to the |
46 |
< |
# structure name |
47 |
< |
# structurelist() : return list of structure objectS |
48 |
< |
# downloadtotop(dir,url) : download the url to a dir in the config area |
49 |
< |
# |
1 |
> |
=head1 NAME |
2 |
> |
|
3 |
> |
Configuration::ConfigArea - Creates and manages a configuration area (i.e. a project area). |
4 |
> |
|
5 |
> |
=head1 SYNOPSIS |
6 |
> |
|
7 |
> |
my $obj = Configuration::ConfigArea->new(); |
8 |
> |
|
9 |
> |
=head1 DESCRIPTION |
10 |
> |
|
11 |
> |
Create and manage SCRAM project configuration areas. |
12 |
> |
|
13 |
> |
=head1 METHODS |
14 |
> |
|
15 |
> |
=over |
16 |
> |
|
17 |
> |
=cut |
18 |
> |
|
19 |
> |
=item C<new()> |
20 |
> |
|
21 |
> |
Create a new Configuration::ConfigArea object. |
22 |
> |
|
23 |
> |
=item C<name()> |
24 |
> |
|
25 |
> |
Get/set project name. |
26 |
> |
|
27 |
> |
=item C<setup($dir[,$areaname])> |
28 |
> |
|
29 |
> |
Set up a fresh area in $dir. |
30 |
> |
|
31 |
> |
=item C<satellite($dir[,$areaname])> |
32 |
> |
|
33 |
> |
Set up a satellite area in $dir. |
34 |
> |
|
35 |
> |
=item C<version()> |
36 |
> |
|
37 |
> |
Get/set project version. |
38 |
> |
|
39 |
> |
=item C<location([$dir])> |
40 |
> |
|
41 |
> |
Set/return the location of the work area. |
42 |
> |
|
43 |
> |
=item C<bootstrapfromlocation([$location])> |
44 |
> |
|
45 |
> |
Bootstrap the object based on location. |
46 |
> |
No location specified - current directory used |
47 |
> |
Return 0 if succesful, 1 otherwise. |
48 |
> |
|
49 |
> |
=item C<requirementsdoc()> |
50 |
> |
|
51 |
> |
Get or set the requirements document. |
52 |
> |
|
53 |
> |
=item C<searchlocation([$startdir])> |
54 |
> |
|
55 |
> |
Returns the location directory. search starts |
56 |
> |
from current directory if not specified. |
57 |
> |
|
58 |
> |
=item C<scramversion()> |
59 |
> |
|
60 |
> |
Return the scram version associated with the area. |
61 |
> |
|
62 |
> |
=item C<configurationdir()> |
63 |
> |
|
64 |
> |
Return the location of the project configuration directory. |
65 |
> |
|
66 |
> |
=item C<copy($location)> |
67 |
> |
|
68 |
> |
Copy a configuration from $location. |
69 |
> |
|
70 |
> |
=item C<copysetup($location)> |
71 |
> |
|
72 |
> |
Copy the architecture-specific tool setup. |
73 |
> |
Returns 0 if successful, 1 otherwise. |
74 |
> |
|
75 |
> |
=item C<copyenv($ref)> |
76 |
> |
|
77 |
> |
Copy the area environment into the hashref $ref. |
78 |
> |
|
79 |
> |
=item C<toolbox()> |
80 |
> |
|
81 |
> |
Return the area toolbox object. |
82 |
> |
|
83 |
> |
=item C<save()> |
84 |
> |
|
85 |
> |
Save changes permanently. |
86 |
> |
|
87 |
> |
=item C<linkto($location)> |
88 |
> |
|
89 |
> |
Link the current area to that at location. |
90 |
> |
|
91 |
> |
=item C<unlinkarea()> |
92 |
> |
|
93 |
> |
Destroy link ($autosave). |
94 |
> |
|
95 |
> |
=item C<linkarea([Configuration::ConfigArea])> |
96 |
> |
|
97 |
> |
Link the current area to the specified area object. |
98 |
> |
|
99 |
> |
=item C<archname()> |
100 |
> |
|
101 |
> |
Get/set a string to indicate architecture. |
102 |
> |
|
103 |
> |
=item C<archdir()> |
104 |
> |
|
105 |
> |
Return the location of the administration |
106 |
> |
architecture-dependent directory. |
107 |
> |
|
108 |
> |
=item C<objectstore()> |
109 |
> |
|
110 |
> |
Return the B<objectStore> object of the area temporary. |
111 |
> |
|
112 |
> |
=item C<align()> |
113 |
> |
|
114 |
> |
Adjust hard paths to suit local location. |
115 |
> |
|
116 |
> |
|
117 |
> |
=back |
118 |
> |
|
119 |
> |
=head1 AUTHOR |
120 |
> |
|
121 |
> |
Originally written by Christopher Williams. |
122 |
> |
|
123 |
> |
=head1 MAINTAINER |
124 |
> |
|
125 |
> |
Shaun ASHBY |
126 |
> |
|
127 |
> |
=cut |
128 |
|
|
129 |
|
package Configuration::ConfigArea; |
52 |
– |
use ActiveDoc::ActiveDoc; |
130 |
|
require 5.004; |
131 |
+ |
use URL::URLcache; |
132 |
|
use Utilities::AddDir; |
133 |
+ |
use Utilities::Verbose; |
134 |
|
use ObjectUtilities::ObjectStore; |
56 |
– |
use Configuration::ConfigStore; |
57 |
– |
use Configuration::ActiveDoc_arch; |
135 |
|
use Cwd; |
136 |
< |
@ISA=qw(Configuration::ActiveDoc_arch ObjectUtilities::StorableObject); |
136 |
> |
@ISA=qw(Utilities::Verbose); |
137 |
|
|
138 |
< |
sub init { |
139 |
< |
my $self=shift; |
140 |
< |
|
141 |
< |
$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); |
138 |
> |
sub new { |
139 |
> |
my $class=shift; |
140 |
> |
my $self={}; |
141 |
> |
bless $self, $class; |
142 |
|
|
143 |
|
# data init |
144 |
< |
$self->{admindir}=".SCRAM"; |
144 |
> |
$self->{admindir}=".SCRAM"; |
145 |
> |
$self->{cachedir}="cache"; |
146 |
> |
$self->{dbdir}="ObjectDB"; |
147 |
> |
$self->{tbupdate}=0; |
148 |
> |
undef $self->{linkarea}; |
149 |
> |
|
150 |
> |
return $self; |
151 |
|
} |
152 |
|
|
153 |
< |
sub basearea { |
153 |
> |
sub cache { |
154 |
|
my $self=shift; |
155 |
|
|
90 |
– |
my $area; |
156 |
|
if ( @_ ) { |
157 |
< |
$area=shift; |
93 |
< |
$self->config()->store($area,"BaseArea"); |
157 |
> |
$self->{cache}=shift; |
158 |
|
} |
159 |
< |
else { |
160 |
< |
($area)=$self->config()->find("BaseArea"); |
159 |
> |
if ( ! defined $self->{cache} ) { |
160 |
> |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir}; |
161 |
> |
if ( -e $loc ) { |
162 |
> |
$self->{cache}=URL::URLcache->new($loc); |
163 |
> |
} |
164 |
> |
else { |
165 |
> |
$self->{cache}=undef; |
166 |
> |
} |
167 |
|
} |
168 |
< |
return $area; |
168 |
> |
return $self->{cache}; |
169 |
|
} |
170 |
|
|
171 |
< |
sub freebase { |
171 |
> |
# Tool and project cache info: |
172 |
> |
sub cacheinfo |
173 |
> |
{ |
174 |
> |
my $self=shift; |
175 |
> |
print "\n","<ConfigArea> cacheinfo: ToolCache = ",$self->{toolcachefile}, |
176 |
> |
", ProjectCache = ",$self->{projectcachefile},"\n"; |
177 |
> |
} |
178 |
> |
|
179 |
> |
sub toolcachename |
180 |
> |
{ |
181 |
> |
my $self=shift; |
182 |
> |
return ($self->location()."/".$self->{admindir}."/".$ENV{SCRAM_ARCH}."/ToolCache.db"); |
183 |
> |
} |
184 |
> |
|
185 |
> |
sub projectcachename |
186 |
> |
{ |
187 |
> |
my $self=shift; |
188 |
> |
return ($self->location()."/".$self->{admindir}."/".$ENV{SCRAM_ARCH}."/ProjectCache.db"); |
189 |
> |
} |
190 |
> |
|
191 |
> |
sub _tbupdate |
192 |
> |
{ |
193 |
> |
# Update toolbox relative to new RequirementsDoc: |
194 |
> |
my $self=shift; |
195 |
> |
@_?$self->{tbupdate}=shift |
196 |
> |
:$self->{tbupdate}; |
197 |
> |
} |
198 |
> |
|
199 |
> |
sub _newcache { |
200 |
|
my $self=shift; |
201 |
< |
$self->config()->delete("BaseArea"); |
201 |
> |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{cachedir}; |
202 |
> |
$self->{cache}=URL::URLcache->new($loc); |
203 |
> |
return $self->{cache}; |
204 |
|
} |
205 |
|
|
206 |
< |
sub defaultdirname { |
206 |
> |
sub _newobjectstore { |
207 |
|
my $self=shift; |
208 |
< |
my $name=$self->name(); |
209 |
< |
my $vers=$self->version(); |
210 |
< |
$vers=~s/^$name\_//; |
111 |
< |
$name=$name."_".$vers; |
112 |
< |
return $name; |
208 |
> |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir}; |
209 |
> |
$self->{dbstore}=ObjectUtilities::ObjectStore->new($loc); |
210 |
> |
return $self->{dbstore}; |
211 |
|
} |
212 |
|
|
213 |
< |
|
116 |
< |
sub setup { |
213 |
> |
sub objectstore { |
214 |
|
my $self=shift; |
215 |
|
|
216 |
< |
# --- find out the location - default is cwd |
217 |
< |
my $location=$self->option("ConfigArea_location"); |
121 |
< |
if ( ! defined $location ) { |
122 |
< |
$location=cwd(); |
123 |
< |
} |
124 |
< |
elsif ( $location!~/^\// ) { |
125 |
< |
$location=cwd()."/".$location; |
216 |
> |
if ( @_ ) { |
217 |
> |
$self->{dbstore}=shift; |
218 |
|
} |
219 |
< |
|
220 |
< |
# --- find area directory name , default name projectname_version |
221 |
< |
my $name=$self->option("ConfigArea_name"); |
222 |
< |
if ( ! defined $name ) { |
223 |
< |
$name=$self->defaultdirname(); |
219 |
> |
if ( ! defined $self->{dbstore} ) { |
220 |
> |
my $loc=$self->location()."/".$self->{admindir}."/".$self->{dbdir}; |
221 |
> |
if ( -e $loc ) { |
222 |
> |
$self->{dbstore}=ObjectUtilities::ObjectStore->new($loc); |
223 |
> |
} |
224 |
> |
else { |
225 |
> |
$self->{dbstore}=undef; |
226 |
> |
} |
227 |
|
} |
228 |
< |
$self->location($location."/".$name); |
134 |
< |
|
135 |
< |
# make a new store handler |
136 |
< |
$self->_setupstore(); |
137 |
< |
|
138 |
< |
# --- download everything first |
139 |
< |
$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"); |
147 |
< |
|
148 |
< |
# --- store self in original database |
149 |
< |
$self->parentconfig()->store($self,"ConfigArea",$self->name(), |
150 |
< |
$self->version()); |
228 |
> |
return $self->{dbstore} |
229 |
|
} |
230 |
|
|
231 |
< |
sub structure { |
231 |
> |
sub symlinks { |
232 |
|
my $self=shift; |
233 |
< |
my $vr=shift; |
234 |
< |
return $self->{structures}{$vr}; |
233 |
> |
if (@_) {$self->{symlinks}=shift;} |
234 |
> |
return $self->{symlinks}; |
235 |
|
} |
236 |
|
|
237 |
< |
sub structurelist { |
237 |
> |
sub name { |
238 |
|
my $self=shift; |
239 |
< |
return ( keys %{$self->{structures}} ); |
239 |
> |
@_?$self->{name}=shift |
240 |
> |
:$self->{name}; |
241 |
|
} |
242 |
|
|
243 |
< |
sub _setupstore { |
243 |
> |
sub version { |
244 |
|
my $self=shift; |
245 |
< |
|
246 |
< |
# --- make a new ConfigStore at the location and add it to the db list |
168 |
< |
my $ad=Configuration::ConfigStore->new($self->location(). |
169 |
< |
"/".$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()); |
245 |
> |
@_?$self->{version}=shift |
246 |
> |
:$self->{version}; |
247 |
|
} |
248 |
|
|
249 |
< |
sub bootstrapfromlocation { |
249 |
> |
sub setup { |
250 |
|
my $self=shift; |
251 |
+ |
my $location=shift; |
252 |
+ |
my $areaname; |
253 |
+ |
my $symlinks=0; |
254 |
+ |
|
255 |
+ |
# -- check we have a project name and version |
256 |
+ |
my $name=$self->name(); |
257 |
+ |
my $vers=$self->version(); |
258 |
|
|
259 |
< |
if ( ! defined $self->location(@_) ) { |
260 |
< |
$self->error("Unable to locate the top of local configuration area"); |
259 |
> |
if ( ( ! defined $name ) && ( ! defined $version )) { |
260 |
> |
$self->error("Set ConfigArea name and version before setup"); |
261 |
|
} |
262 |
< |
$self->verbose("Found top ".$self->location()); |
263 |
< |
$self->_setupstore(); |
264 |
< |
my $infofile=$self->location()."/".$self->{admindir}."/ConfigArea.dat"; |
265 |
< |
if ( -e $infofile ) { |
190 |
< |
$self->restore($infofile); |
262 |
> |
|
263 |
> |
# -- check arguments and set location |
264 |
> |
if ( ! defined $location ) { |
265 |
> |
$self->error("ConfigArea: Cannot setup new area without a location"); |
266 |
|
} |
267 |
< |
else { |
268 |
< |
$self->error("Area corrupted - cannot find $infofile"); |
267 |
> |
if ( @_ ) { |
268 |
> |
$areaname=shift; |
269 |
> |
} |
270 |
> |
if ( @_ ) { |
271 |
> |
$symlinks=shift || 0; |
272 |
> |
} |
273 |
> |
if ( (! defined $areaname) || ( $areaname eq "" ) ) { |
274 |
> |
$areaname=$vers; |
275 |
|
} |
276 |
+ |
my $arealoc=$location."/".$areaname; |
277 |
+ |
my $workloc=$arealoc."/".$self->{admindir}; |
278 |
+ |
$self->verbose("Building at $arealoc"); |
279 |
+ |
$self->location($arealoc); |
280 |
+ |
$self->symlinks($symlinks); |
281 |
+ |
|
282 |
+ |
# -- create top level structure and work area |
283 |
+ |
AddDir::adddir($workloc); |
284 |
+ |
|
285 |
+ |
# -- add a cache |
286 |
+ |
$self->_newcache(); |
287 |
+ |
|
288 |
+ |
# -- add an Objectstore |
289 |
+ |
$self->_newobjectstore(); |
290 |
+ |
|
291 |
+ |
# -- Save Environment File |
292 |
+ |
$self->_SaveEnvFile(); |
293 |
+ |
|
294 |
|
} |
295 |
|
|
296 |
< |
sub parentconfig { |
296 |
> |
sub configurationdir { |
297 |
|
my $self=shift; |
298 |
< |
@_?$self->{parentconfig}=shift |
299 |
< |
:$self->{parentconfig}; |
298 |
> |
if ( @_ ) { |
299 |
> |
$self->{configurationdir}=shift; |
300 |
> |
} |
301 |
> |
return (defined $self->{configurationdir})?$self->{configurationdir}:undef; |
302 |
|
} |
303 |
|
|
304 |
< |
sub store { |
304 |
> |
sub sourcedir { |
305 |
|
my $self=shift; |
306 |
< |
my $location=shift; |
307 |
< |
|
308 |
< |
my $fh=$self->openfile(">".$location); |
309 |
< |
$self->savevar($fh,"location", $self->location()); |
209 |
< |
$self->savevar($fh,"url", $self->url()); |
210 |
< |
$self->savevar($fh,"name", $self->name()); |
211 |
< |
$self->savevar($fh,"version", $self->version()); |
212 |
< |
$fh->close(); |
213 |
< |
|
214 |
< |
$self->_storestructures(); |
306 |
> |
if ( @_ ) { |
307 |
> |
$self->{sourcedir}=shift; |
308 |
> |
} |
309 |
> |
return (defined $self->{sourcedir})?$self->{sourcedir}:undef; |
310 |
|
} |
311 |
|
|
312 |
< |
sub satellite { |
312 |
> |
sub toolbox { |
313 |
|
my $self=shift; |
314 |
< |
my $newarea=$self->copy(@_); |
315 |
< |
$newarea->_makesatellites(); |
316 |
< |
return $newarea; |
314 |
> |
if ( ! defined $self->{toolbox} ) { |
315 |
> |
$self->{toolbox}=BuildSystem::ToolBox->new($self, $ENV{SCRAM_ARCH}); |
316 |
> |
} |
317 |
> |
return $self->{toolbox}; |
318 |
|
} |
319 |
|
|
320 |
< |
sub copy { |
320 |
> |
sub toolboxversion { |
321 |
|
my $self=shift; |
322 |
< |
use File::Basename; |
323 |
< |
# create the area |
322 |
> |
if ( @_ ) { |
323 |
> |
$self->{toolboxversion}=shift; |
324 |
> |
} |
325 |
> |
return (defined $self->{toolboxversion})?$self->{toolboxversion}:undef; |
326 |
> |
} |
327 |
|
|
328 |
< |
my $destination; |
328 |
> |
sub requirementsdoc { |
329 |
> |
my $self=shift; |
330 |
|
if ( @_ ) { |
331 |
< |
$destination=shift; |
331 |
> |
$self->{reqdoc}=shift; |
332 |
> |
} |
333 |
> |
if ( defined $self->{reqdoc} ) { |
334 |
> |
return $self->location()."/".$self->{reqdoc}; |
335 |
|
} |
336 |
|
else { |
337 |
< |
my($location,$name)=$self->_defaultoptions(); |
235 |
< |
$destination=$location."/".$name |
337 |
> |
return undef; |
338 |
|
} |
237 |
– |
#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; |
339 |
|
} |
340 |
|
|
341 |
< |
sub restore { |
341 |
> |
sub scramversion { |
342 |
|
my $self=shift; |
343 |
< |
my $location=shift; |
344 |
< |
|
345 |
< |
my $fh=$self->openfile("<".$location); |
346 |
< |
my $varhash={}; |
347 |
< |
$self->restorevars($fh,$varhash); |
348 |
< |
if ( ! defined $self->location() ) { |
349 |
< |
$self->location($$varhash{"location"}); |
350 |
< |
} |
351 |
< |
$self->_setupstore(); |
352 |
< |
$self->url($$varhash{"url"}); |
353 |
< |
$self->name($$varhash{"name"}); |
354 |
< |
$self->version($$varhash{"version"}); |
355 |
< |
$fh->close(); |
356 |
< |
|
268 |
< |
$self->_restorestructures(); |
343 |
> |
if ( ! defined $self->{scramversion} ) { |
344 |
> |
my $filename=$self->location()."/".$self->configurationdir()."/". |
345 |
> |
"scram_version"; |
346 |
> |
if ( -f $filename ) { |
347 |
> |
use FileHandle; |
348 |
> |
$fh=FileHandle->new(); |
349 |
> |
open ($fh, "<".$filename); |
350 |
> |
my $version=<$fh>; |
351 |
> |
chomp $version; |
352 |
> |
$self->{scramversion}=$version; |
353 |
> |
undef $fh; |
354 |
> |
} |
355 |
> |
} |
356 |
> |
return $self->{scramversion}; |
357 |
|
} |
358 |
|
|
359 |
< |
sub name { |
360 |
< |
my $self=shift; |
359 |
> |
sub sitename |
360 |
> |
{ |
361 |
> |
############################################################### |
362 |
> |
# sitename() # |
363 |
> |
############################################################### |
364 |
> |
# modified : Mon Dec 3 15:45:35 2001 / SFA # |
365 |
> |
# params : # |
366 |
> |
# : # |
367 |
> |
# : # |
368 |
> |
# : # |
369 |
> |
# function : Read the site name from config/site/sitename and # |
370 |
> |
# : export it. # |
371 |
> |
# : # |
372 |
> |
# : # |
373 |
> |
############################################################### |
374 |
> |
my $self = shift; |
375 |
> |
my $sitefile = $self->location()."/".$self->configurationdir()."/site/sitename"; |
376 |
> |
|
377 |
> |
$self->{sitename} = 'CERN'; # Use CERN as the default site name |
378 |
> |
|
379 |
> |
use FileHandle; |
380 |
> |
my $sitefh = FileHandle->new(); |
381 |
> |
|
382 |
> |
# Be verbose and print file we're going to read: |
383 |
> |
$self->verbose(">> Going to try to get sitename from: ".$sitefile." "); |
384 |
> |
|
385 |
> |
# See if we can read from the file. If not, just |
386 |
> |
# use default site name: |
387 |
> |
open($sitefh,"<".$sitefile) || |
388 |
> |
do |
389 |
> |
{ |
390 |
> |
$self->verbose(">> Unable to read a site name definition file. Using \'CERN\' as the site name."); |
391 |
> |
return $self->{sitename}; |
392 |
> |
}; |
393 |
> |
|
394 |
> |
$sitename = <$sitefh>; |
395 |
> |
chomp($sitename); |
396 |
> |
$self->{sitename} = $sitename; |
397 |
> |
|
398 |
> |
# Close the file (be tidy!); |
399 |
> |
close($sitefile); |
400 |
> |
# Return: |
401 |
> |
return $self->{sitename}; |
402 |
> |
} |
403 |
> |
|
404 |
> |
sub admindir() |
405 |
> |
{ |
406 |
> |
my $self=shift; |
407 |
> |
|
408 |
> |
@_ ? $self->{admindir} = shift |
409 |
> |
: $self->{admindir}; |
410 |
> |
} |
411 |
|
|
412 |
< |
@_?$self->{name}=shift |
275 |
< |
:$self->{name}; |
276 |
< |
} |
277 |
< |
|
278 |
< |
sub version { |
412 |
> |
sub bootstrapfromlocation { |
413 |
|
my $self=shift; |
414 |
|
|
415 |
< |
@_?$self->{version}=shift |
416 |
< |
:$self->{version}; |
415 |
> |
my $rv=0; |
416 |
> |
|
417 |
> |
my $location; |
418 |
> |
if ( ! defined ($location=$self->searchlocation(@_)) ) { |
419 |
> |
$rv=1; |
420 |
> |
$self->verbose("Unable to locate the top of local configuration area"); |
421 |
> |
} |
422 |
> |
else { |
423 |
> |
$self->location($location); |
424 |
> |
$self->verbose("Found top ".$self->location()); |
425 |
> |
$self->_LoadEnvFile(); |
426 |
> |
} |
427 |
> |
return $rv; |
428 |
|
} |
429 |
|
|
430 |
|
sub location { |
442 |
|
|
443 |
|
sub searchlocation { |
444 |
|
my $self=shift; |
445 |
< |
|
445 |
> |
|
446 |
|
#start search in current directory if not specified |
447 |
|
my $thispath; |
448 |
< |
@_?$thispath=shift |
449 |
< |
:$thispath=cwd(); |
450 |
< |
|
448 |
> |
if ( @_ ) { |
449 |
> |
$thispath=shift |
450 |
> |
} |
451 |
> |
else { |
452 |
> |
$thispath=cwd(); |
453 |
> |
} |
454 |
> |
|
455 |
|
my $rv=0; |
456 |
|
|
457 |
+ |
# chop off any files - we only want dirs |
458 |
+ |
if ( -f $thispath ) { |
459 |
+ |
$thispath=~s/(.*)\/.*/$1/; |
460 |
+ |
} |
461 |
|
Sloop:{ |
462 |
|
do { |
463 |
< |
# print "Searching $thispath\n"; |
463 |
> |
$self->verbose("Searching $thispath"); |
464 |
|
if ( -e "$thispath/".$self->{admindir} ) { |
465 |
< |
# print "Found\n"; |
465 |
> |
$self->verbose("Found\n"); |
466 |
|
$rv=1; |
467 |
|
last Sloop; |
468 |
|
} |
469 |
|
} while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) }; |
470 |
< |
|
470 |
> |
|
471 |
|
return $rv?$thispath:undef; |
472 |
|
} |
473 |
|
|
474 |
< |
sub meta { |
474 |
> |
sub archname { |
475 |
|
my $self=shift; |
476 |
< |
|
477 |
< |
my $string=$self->name()." ".$self->version()." located at :\n ". |
478 |
< |
$self->location; |
476 |
> |
if ( @_ ) { |
477 |
> |
$self->{archname}=shift; |
478 |
> |
} |
479 |
> |
return $self->{archname}; |
480 |
|
} |
481 |
|
|
482 |
< |
sub configitem { |
482 |
> |
sub archdir { |
483 |
|
my $self=shift; |
484 |
< |
|
485 |
< |
return ($self->config()->find("ConfigItem",@_)); |
484 |
> |
if ( @_ ) { |
485 |
> |
$self->{archdir}=shift; |
486 |
> |
} |
487 |
> |
if ( ! defined $self->{archdir} ) { |
488 |
> |
if ( defined $self->{archname} ) { |
489 |
> |
$self->{archdir}=$self->location()."/".$self->{admindir}."/". |
490 |
> |
$self->{archname}; |
491 |
> |
} |
492 |
> |
else { |
493 |
> |
$self->error("ConfigArea : cannot create arch directory - ". |
494 |
> |
"architecture name not set") |
495 |
> |
} |
496 |
> |
} |
497 |
> |
return $self->{archdir}; |
498 |
|
} |
499 |
|
|
500 |
< |
sub addconfigitem { |
500 |
> |
sub satellite { |
501 |
|
my $self=shift; |
336 |
– |
my $url=shift; |
502 |
|
|
503 |
< |
my $docref=$self->activatedoc($url); |
504 |
< |
# Set up the document |
505 |
< |
$docref->setup(); |
506 |
< |
$docref->save(); |
507 |
< |
# $self->config()->storepolicy("local"); |
508 |
< |
} |
503 |
> |
# -- create the sat object |
504 |
> |
my $sat=Configuration::ConfigArea->new(); |
505 |
> |
$sat->name($self->name()); |
506 |
> |
$sat->version($self->version()); |
507 |
> |
$sat->requirementsdoc($self->{reqdoc}); |
508 |
> |
$sat->configurationdir($self->configurationdir()); |
509 |
> |
$sat->sourcedir($self->sourcedir()); |
510 |
> |
$sat->toolboxversion($self->toolboxversion()); |
511 |
> |
$sat->setup(@_); |
512 |
> |
|
513 |
> |
# -- copy across the cache and ObjectStore |
514 |
> |
# -- make sure we dont try building new caches in release areas |
515 |
> |
my $rcache=$self->cache(); |
516 |
> |
if ( defined $rcache ) { |
517 |
> |
copy($rcache->location(),$sat->cache()->location()); |
518 |
> |
} |
519 |
> |
|
520 |
> |
# -- make sure we dont try building new objectstores in release areas |
521 |
> |
my $rostore=$self->objectstore(); |
522 |
> |
if ( defined $rostore ) { |
523 |
> |
copy($rostore->location(),$sat->objectstore()->location()); |
524 |
> |
} |
525 |
|
|
526 |
< |
sub storeconfigobject { |
527 |
< |
my $self=shift; |
347 |
< |
my $obj=shift; |
348 |
< |
$obj->save($self->config()); |
349 |
< |
} |
526 |
> |
# and make sure in reinitialises |
527 |
> |
undef ($sat->{cache}); |
528 |
|
|
529 |
< |
sub downloadtotop { |
530 |
< |
my $self=shift; |
353 |
< |
my $url=shift; |
354 |
< |
my $dir=shift; |
529 |
> |
# -- link it to this area |
530 |
> |
$sat->linkarea($self); |
531 |
|
|
532 |
< |
# only download once |
533 |
< |
if ( ! -e $self->location()."/".$dir ) { |
358 |
< |
$self->{urlhandler}->download($url,$self->location()."/".$dir); |
359 |
< |
} |
360 |
< |
} |
532 |
> |
# -- save it |
533 |
> |
$sat->save(); |
534 |
|
|
535 |
< |
sub _makesatellites { |
363 |
< |
my $self=shift; |
364 |
< |
foreach $st ( values %{$self->{structures}} ) { |
365 |
< |
$st->setupsatellite() |
366 |
< |
} |
535 |
> |
return $sat; |
536 |
|
} |
537 |
|
|
538 |
< |
sub _storestructures { |
538 |
> |
sub copy { |
539 |
|
my $self=shift; |
540 |
< |
foreach $struct ( values %{$self->{structures}} ) { |
372 |
< |
$self->config()->store($struct, "Structures", $struct->name()); |
373 |
< |
} |
374 |
< |
} |
540 |
> |
my $destination=shift; |
541 |
|
|
542 |
< |
sub _restorestructures { |
543 |
< |
my $self=shift; |
544 |
< |
my @strs=$self->config()->find("Structures"); |
379 |
< |
foreach $struct ( @strs ) { |
380 |
< |
$struct->parent($self); |
381 |
< |
$self->{structures}{$struct->name()}=$struct; |
382 |
< |
} |
542 |
> |
# copy across the admin dir |
543 |
> |
my $temp=$self->location()."/".$self->{admindir}; |
544 |
> |
AddDir::copydir($temp,"$destination/".$self->{admindir}); |
545 |
|
} |
546 |
|
|
547 |
< |
sub _defaultoptions { |
547 |
> |
sub align { |
548 |
|
my $self=shift; |
549 |
< |
my $name; |
388 |
< |
my $location; |
389 |
< |
|
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 |
< |
} |
549 |
> |
use File::Copy; |
550 |
|
|
551 |
< |
# --- find area directory name , default name projectname_version |
552 |
< |
$name=$self->option("ConfigArea_name"); |
553 |
< |
if ( ! defined $name ) { |
554 |
< |
$name=$self->defaultdirname(); |
555 |
< |
} |
556 |
< |
return ($location,$name); |
551 |
> |
$self->_LoadEnvFile(); |
552 |
> |
my $Envfile=$self->location()."/".$self->{admindir}."/Environment"; |
553 |
> |
my $tmpEnvfile=$Envfile.".bak"; |
554 |
> |
my $rel=$self->{ENV}{RELEASETOP}; |
555 |
> |
my $local=$self->location(); |
556 |
> |
|
557 |
> |
rename( $Envfile, $tmpEnvfile ); |
558 |
> |
use FileHandle; |
559 |
> |
my $fh=FileHandle->new(); |
560 |
> |
my $fout=FileHandle->new(); |
561 |
> |
open ( $fh, "<".$tmpEnvfile ) or |
562 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
563 |
> |
.$self->location().")\n $!"); |
564 |
> |
open ( $fout, ">".$Envfile ) or |
565 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
566 |
> |
.$self->location().")\n $!"); |
567 |
> |
while ( <$fh> ) { |
568 |
> |
$_=~s/\Q$rel\L/$local/g; |
569 |
> |
print $fout $_; |
570 |
> |
} |
571 |
> |
undef $fh; |
572 |
> |
undef $fout; |
573 |
|
} |
406 |
– |
# -------------- Tags --------------------------------- |
407 |
– |
# -- init parse |
408 |
– |
sub Project_Start { |
409 |
– |
my $self=shift; |
410 |
– |
my $name=shift; |
411 |
– |
my $hashref=shift; |
574 |
|
|
575 |
< |
$self->checktag($name,$hashref,'name'); |
576 |
< |
$self->checktag($name,$hashref,'version'); |
577 |
< |
|
578 |
< |
$self->name($$hashref{'name'}); |
579 |
< |
$self->version($$hashref{'version'}); |
575 |
> |
sub copysetup { |
576 |
> |
my $self=shift; |
577 |
> |
my $dest=shift; |
578 |
> |
my $rv=1; |
579 |
> |
# copy across the admin dir |
580 |
> |
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
581 |
> |
my $temp2=$dest."/".$self->{admindir}."/".$self->arch(); |
582 |
> |
if ( $temp ne $temp2 ) { |
583 |
> |
if ( -d $temp ) { |
584 |
> |
AddDir::copydir($temp,$temp2); |
585 |
> |
$rv=0; |
586 |
> |
} |
587 |
> |
} |
588 |
> |
return $rv; |
589 |
|
} |
590 |
|
|
591 |
< |
|
421 |
< |
sub Project_text { |
591 |
> |
sub copyurlcache { |
592 |
|
my $self=shift; |
593 |
< |
my $name=shift; |
594 |
< |
my $string=shift; |
595 |
< |
|
596 |
< |
print $string; |
593 |
> |
my $dest=shift; |
594 |
> |
my $rv=1; |
595 |
> |
# copy across the admin dir |
596 |
> |
my $temp=$self->location()."/".$self->{admindir}."/cache"; |
597 |
> |
my $temp2=$dest."/".$self->{admindir}."/cache"; |
598 |
> |
if ( $temp ne $temp2 ) { |
599 |
> |
if ( -d $temp ) { |
600 |
> |
AddDir::copydir($temp,$temp2); |
601 |
> |
$rv=0; |
602 |
> |
} |
603 |
> |
} |
604 |
> |
return $rv; |
605 |
> |
} |
606 |
> |
|
607 |
> |
sub copywithskip { |
608 |
> |
my $self=shift; |
609 |
> |
my $dest=shift; |
610 |
> |
my $filetoskip=shift || []; |
611 |
> |
my $rv=1; |
612 |
> |
# copy across the admin dir |
613 |
> |
my $temp=$self->location()."/".$self->{admindir}."/".$self->arch(); |
614 |
> |
my $temp2=$dest."/".$self->{admindir}."/".$self->arch(); |
615 |
> |
if ( $temp ne $temp2 ) { |
616 |
> |
if ( -d $temp ) { |
617 |
> |
my $fs=[]; |
618 |
> |
foreach my $f (@$filetoskip) {push @$fs,"${temp}/${f}";} |
619 |
> |
AddDir::copydirwithskip($temp,$temp2,$fs); |
620 |
> |
$rv=0; |
621 |
> |
} |
622 |
> |
} |
623 |
> |
return $rv; |
624 |
|
} |
625 |
|
|
626 |
< |
# ---- download parse |
430 |
< |
|
431 |
< |
sub Download_Start { |
626 |
> |
sub copyenv { |
627 |
|
my $self=shift; |
628 |
< |
my $name=shift; |
629 |
< |
my $hashref=shift; |
630 |
< |
|
631 |
< |
$self->checktag($name,$hashref,'url'); |
437 |
< |
$self->checktag($name,$hashref,'location'); |
438 |
< |
if ( $$hashref{'location'}!~/^\w/ ) { |
439 |
< |
$self->parseerror("location must start with an". |
440 |
< |
" alphanumeric character"); |
628 |
> |
my $hashref=shift; |
629 |
> |
|
630 |
> |
foreach $elem ( keys %{$self->{ENV}} ) { |
631 |
> |
$$hashref{$elem}=$self->{ENV}{$elem}; |
632 |
|
} |
442 |
– |
print "Downloading .... ".$$hashref{'url'}."\n"; |
443 |
– |
$self->downloadtotop($$hashref{'url'},$$hashref{'location'}); |
633 |
|
} |
634 |
|
|
635 |
< |
sub Use_download_Start { |
635 |
> |
sub arch { |
636 |
|
my $self=shift; |
637 |
< |
my $name=shift; |
449 |
< |
my $hashref=shift; |
450 |
< |
|
451 |
< |
$self->checktag($name,$hashref,'url'); |
452 |
< |
print "Downloading .... ".$$hashref{'url'}."\n"; |
453 |
< |
$self->getfile($$hashref{'url'}); |
637 |
> |
return $ENV{SCRAM_ARCH}; |
638 |
|
} |
639 |
|
|
640 |
< |
# --- setup parse |
457 |
< |
|
458 |
< |
sub Structure_Start { |
640 |
> |
sub linkto { |
641 |
|
my $self=shift; |
642 |
< |
my $name=shift; |
461 |
< |
my $hashref=shift; |
642 |
> |
my $location=shift; |
643 |
|
|
644 |
< |
$self->checktag($name,$hashref,'name'); |
645 |
< |
if ( !(( exists $$hashref{'type'}) || ( exists $$hashref{'url'})) ) { |
646 |
< |
$self->parseerror("No url or type given in <$name> tag"); |
647 |
< |
} |
467 |
< |
if ( ! exists $self->{structures}{$$hashref{'name'}} ) { |
468 |
< |
if ( exists $$hashref{'type'}) { |
469 |
< |
# create a new object of the specified type |
470 |
< |
eval "require $$hashref{'type'} "; |
471 |
< |
if ( $@ ) { |
472 |
< |
$self->parseerror("Unable to instantiate type=". |
473 |
< |
$$hashref{'type'}." in <$name> .".$@); |
474 |
< |
} |
475 |
< |
$self->{structures}{$$hashref{'name'}}= |
476 |
< |
$$hashref{'type'}->new($self->config()); |
477 |
< |
$self->{structures}{$$hashref{'name'}}->name($$hashref{'name'}); |
478 |
< |
$self->{structures}{$$hashref{'name'}}->parent($self); |
479 |
< |
$self->{structures}{$$hashref{'name'}}->vars($hashref); |
480 |
< |
$self->{structures}{$$hashref{'name'}}->arch($self->arch()); |
481 |
< |
} |
482 |
< |
else { # its an activedoc |
483 |
< |
$self->{structures}{$$hashref{'name'}}= |
484 |
< |
$self->activatedoc($$hashref{'url'}); |
485 |
< |
} |
486 |
< |
$self->{structures}{$$hashref{'name'}}->setupbase(); |
644 |
> |
if ( -d $location ) { |
645 |
> |
my $area=Configuration::ConfigArea->new(); |
646 |
> |
$area->bootstrapfromlocation($location); |
647 |
> |
$self->linkarea($area); |
648 |
|
} |
649 |
|
else { |
650 |
< |
$self->parseerror("Multiply defined Structure - ". |
651 |
< |
$$hashref{'name'}); |
650 |
> |
$self->error("ConfigArea : Unable to link to non existing directory ". |
651 |
> |
$location); |
652 |
|
} |
653 |
|
} |
654 |
|
|
655 |
< |
sub Use_Start { |
655 |
> |
sub unlinkarea { |
656 |
|
my $self=shift; |
657 |
< |
my $name=shift; |
658 |
< |
my $hashref=shift; |
657 |
> |
undef $self->{linkarea}; |
658 |
> |
$self->{linkarea}=undef; |
659 |
> |
$self->save(); |
660 |
> |
} |
661 |
> |
|
662 |
> |
sub linkarea { |
663 |
> |
my $self=shift; |
664 |
> |
my $area=shift; |
665 |
> |
if ( defined $area ) { |
666 |
> |
$self->{linkarea}=$area; |
667 |
> |
} |
668 |
> |
return (defined $self->{linkarea} && $self->{linkarea} ne "")? |
669 |
> |
$self->{linkarea}:undef; |
670 |
> |
} |
671 |
> |
|
672 |
> |
sub save { |
673 |
> |
my $self=shift; |
674 |
> |
$self->_SaveEnvFile(); |
675 |
> |
} |
676 |
> |
|
677 |
> |
sub reqdoc() |
678 |
> |
{ |
679 |
> |
my $self=shift; |
680 |
> |
my ($path)=@_; |
681 |
> |
return $path."/".$self->{reqdoc}; |
682 |
> |
} |
683 |
> |
|
684 |
> |
sub creationtime() |
685 |
> |
{ |
686 |
> |
my $self=shift; |
687 |
> |
my ($location)= @_; |
688 |
> |
$location||=$self->location(); |
689 |
> |
my $requirementsdoc = $self->reqdoc($location); |
690 |
> |
my ($mode, $time) = (stat($requirementsdoc))[2, 9]; |
691 |
> |
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); |
692 |
> |
|
693 |
> |
($sec < 10) ? ($sec = "0".$sec) : $sec; |
694 |
> |
($min < 10) ? ($min = "0".$min) : $min; |
695 |
> |
|
696 |
> |
$year += 1900; |
697 |
> |
my $months = |
698 |
> |
{ |
699 |
> |
0 => "Jan", 1 => "Feb", |
700 |
> |
2 => "Mar", 3 => "Apr", |
701 |
> |
4 => "May", 5 => "Jun", |
702 |
> |
6 => "Jul", 7 => "Aug", |
703 |
> |
8 => "Sept", 9 => "Oct", |
704 |
> |
10 => "Nov", 11 => "Dec" }; |
705 |
> |
|
706 |
> |
my $days = { 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat", 7 => "Sun"}; |
707 |
> |
|
708 |
> |
# Return the timestamp (as string) of the requirementsdoc: |
709 |
> |
return $days->{$wday}."-".$mday."-".$months->{$mon}."-".$year." ".$hour.":".$min.":".$sec; |
710 |
> |
} |
711 |
> |
|
712 |
> |
# ---- support routines |
713 |
> |
|
714 |
> |
sub _SaveEnvFile |
715 |
> |
{ |
716 |
> |
my $self=shift; |
717 |
> |
my $filemode = 0644; |
718 |
> |
|
719 |
> |
use FileHandle; |
720 |
> |
my $fh=FileHandle->new(); |
721 |
> |
open ( $fh, ">".$self->location()."/".$self->{admindir}."/". |
722 |
> |
"Environment" ) or |
723 |
> |
$self->error("Cannot Open Environment file to Save (" |
724 |
> |
.$self->location().")\n $!"); |
725 |
|
|
726 |
< |
$self->checktag($name,$hashref,'url'); |
727 |
< |
$self->addconfigitem($$hashref{'url'}); |
728 |
< |
} |
729 |
< |
|
726 |
> |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
727 |
> |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
728 |
> |
print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n"; |
729 |
> |
print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n"; |
730 |
> |
print $fh "SCRAM_ProjReqsDoc=".$self->{reqdoc}."\n"; |
731 |
> |
print $fh "SCRAM_TOOLBOXVERSION=".$self->{toolboxversion}."\n"; |
732 |
> |
print $fh "SCRAM_SYMLINKS=",$self->{symlinks},"\n"; |
733 |
> |
|
734 |
> |
if ( defined $self->linkarea() ) |
735 |
> |
{ |
736 |
> |
my $area=$self->linkarea()->location(); |
737 |
> |
if ( $area ne "" ) |
738 |
> |
{ |
739 |
> |
print $fh "RELEASETOP=".$area."\n"; |
740 |
> |
} |
741 |
> |
} |
742 |
> |
|
743 |
> |
undef $fh; |
744 |
> |
|
745 |
> |
# Repeat the exercise to save as XML: |
746 |
> |
my $fh=FileHandle->new(); |
747 |
> |
open ( $fh, ">".$self->location()."/".$self->{admindir}."/". |
748 |
> |
"Environment.xml" ) or |
749 |
> |
$self->error("Cannot Open Environment.xml file to Save (" |
750 |
> |
.$self->location().")\n $!"); |
751 |
> |
print $fh "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; |
752 |
> |
print $fh "<doc type=\"Configuration::ProjectEnvironment\" version=\"1.0\">\n"; |
753 |
> |
print $fh " <environment SCRAM_PROJECTNAME=\"".$self->name()."\"/>\n"; |
754 |
> |
print $fh " <environment SCRAM_PROJECTVERSION=\"".$self->version()."\"/>\n"; |
755 |
> |
print $fh " <environment SCRAM_CONFIGDIR=\"".$self->configurationdir()."\"/>\n"; |
756 |
> |
print $fh " <environment SCRAM_SOURCEDIR=\"".$self->sourcedir()."\"/>\n"; |
757 |
> |
print $fh " <environment SCRAM_ProjReqsDoc=\"".$self->{reqdoc}."\"/>\n"; |
758 |
> |
print $fh " <environment SCRAM_TOOLBOXVERSION=\"".$self->{toolboxversion}."\"/>\n"; |
759 |
> |
print $fh "<environment SCRAM_SYMLINKS=\"",$self->{symlinks},"\"/>\n"; |
760 |
> |
|
761 |
> |
if ( defined $self->linkarea() ) |
762 |
> |
{ |
763 |
> |
my $area=$self->linkarea()->location(); |
764 |
> |
if ( $area ne "" ) |
765 |
> |
{ |
766 |
> |
print $fh " <environment RELEASETOP=\"".$area."\"/>\n"; |
767 |
> |
} |
768 |
> |
} |
769 |
> |
|
770 |
> |
print $fh "</doc>\n"; |
771 |
> |
undef $fh; |
772 |
> |
|
773 |
> |
# Set the default permissions (-rw-r--r--): |
774 |
> |
chmod $filemode, $self->location()."/".$self->{admindir}."/Environment"; |
775 |
> |
chmod $filemode, $self->location()."/".$self->{admindir}."/Environment.xml"; |
776 |
> |
} |
777 |
> |
|
778 |
> |
sub _LoadEnvFile |
779 |
> |
{ |
780 |
> |
my $self=shift; |
781 |
> |
|
782 |
> |
use FileHandle; |
783 |
> |
my $fh=FileHandle->new(); |
784 |
> |
open ( $fh, "<".$self->location()."/".$self->{admindir}."/". |
785 |
> |
"Environment" ) or |
786 |
> |
$self->error("Cannot find Environment file. Area Corrupted? (" |
787 |
> |
.$self->location().")\n $!"); |
788 |
> |
while ( <$fh> ) |
789 |
> |
{ |
790 |
> |
chomp; |
791 |
> |
next if /^#/; |
792 |
> |
next if /^\s*$/ ; |
793 |
> |
($name, $value)=split /=/; |
794 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
795 |
> |
} |
796 |
> |
undef $fh; |
797 |
> |
|
798 |
> |
# -- set internal variables appropriately |
799 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) |
800 |
> |
{ |
801 |
> |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
802 |
> |
} |
803 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) |
804 |
> |
{ |
805 |
> |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
806 |
> |
} |
807 |
> |
if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} ) |
808 |
> |
{ |
809 |
> |
$self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"}); |
810 |
> |
} |
811 |
> |
if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} ) |
812 |
> |
{ |
813 |
> |
$self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"}); |
814 |
> |
} |
815 |
> |
if ( defined $self->{ENV}{"SCRAM_ProjReqsDoc"} ) |
816 |
> |
{ |
817 |
> |
$self->requirementsdoc($self->{ENV}{"SCRAM_ProjReqsDoc"}); |
818 |
> |
} |
819 |
> |
if ( defined $self->{ENV}{"SCRAM_TOOLBOXVERSION"} ) |
820 |
> |
{ |
821 |
> |
if ($self->{ENV}{"SCRAM_TOOLBOXVERSION"} eq '') |
822 |
> |
{ |
823 |
> |
$self->toolboxversion("STANDALONE"); |
824 |
> |
} |
825 |
> |
else |
826 |
> |
{ |
827 |
> |
$self->toolboxversion($self->{ENV}{"SCRAM_TOOLBOXVERSION"}); |
828 |
> |
} |
829 |
> |
} |
830 |
> |
|
831 |
> |
if ( ( defined $self->{ENV}{"RELEASETOP"} ) && |
832 |
> |
($self->{ENV}{"RELEASETOP"} ne $self->location())) |
833 |
> |
{ |
834 |
> |
$self->linkto($self->{ENV}{"RELEASETOP"}); |
835 |
> |
} |
836 |
> |
} |