1 |
– |
# |
2 |
– |
# ConfigArea.pm |
3 |
– |
# |
4 |
– |
# Originally Written by Christopher Williams |
5 |
– |
# |
6 |
– |
# Description |
7 |
– |
# |
8 |
– |
# Interface |
9 |
– |
# --------- |
10 |
– |
# new(ActiveConfig) : A new ConfigArea object |
11 |
– |
# setup() : setup the configuration area |
12 |
– |
# location([dir]) : set/return the location of the area |
13 |
– |
# version([version]) : set/return the version of the area |
14 |
– |
# name([name]) : set/return the name of the area |
15 |
– |
# store(location) : store data in file location |
16 |
– |
# restore(location) : restore data from file location |
17 |
– |
# meta() : return a description string of the area |
18 |
– |
# addconfigitem(url) : add a new item to the area |
19 |
– |
# configitem(@keys) : return a list of fig items that match |
20 |
– |
# the keys - all if left blank |
21 |
– |
# parentstore() : set/return the parent ObjectStore |
22 |
– |
# bootstrapfromlocation([location]): bootstrap the object based on location. |
23 |
– |
# no location specified - cwd used |
24 |
– |
# searchlocation([startdir]) : returns the location directory. search starts |
25 |
– |
# from cwd if not specified |
26 |
– |
# defaultdirname() : return the default directory name string |
27 |
– |
# copy(location) : make a copy of the current area at the |
28 |
– |
# specified location - return an object |
29 |
– |
# representing the area |
30 |
– |
|
1 |
|
package Configuration::ConfigArea; |
32 |
– |
use ActiveDoc::ActiveDoc; |
2 |
|
require 5.004; |
3 |
|
use Utilities::AddDir; |
4 |
< |
use ObjectUtilities::ObjectStore; |
4 |
> |
use Utilities::Verbose; |
5 |
|
use Cwd; |
6 |
< |
@ISA=qw(ActiveDoc::ActiveDoc ObjectUtilities::StorableObject); |
38 |
< |
|
39 |
< |
sub init { |
40 |
< |
my $self=shift; |
6 |
> |
@ISA=qw(Utilities::Verbose); |
7 |
|
|
8 |
< |
$self->newparse("init"); |
9 |
< |
$self->newparse("download"); |
10 |
< |
$self->newparse("setup"); |
11 |
< |
$self->addtag("init","project",\&Project_Start,$self, |
12 |
< |
\&Project_text,$self,"", $self ); |
13 |
< |
$self->addurltags("download"); |
14 |
< |
$self->addtag("download","use",\&Use_download_Start,$self, |
15 |
< |
"", $self, "",$self); |
16 |
< |
$self->addurltags("setup"); |
17 |
< |
$self->addtag("setup","use",\&Use_Start,$self, "", $self, "",$self); |
18 |
< |
} |
19 |
< |
|
20 |
< |
sub defaultdirname { |
21 |
< |
my $self=shift; |
22 |
< |
my $name=$self->name(); |
23 |
< |
my $vers=$self->version(); |
24 |
< |
$vers=~s/^$name_//; |
25 |
< |
$name=$name."_".$vers; |
26 |
< |
return $name; |
27 |
< |
|
8 |
> |
sub new { |
9 |
> |
my $class=shift; |
10 |
> |
my $self={}; |
11 |
> |
bless $self, $class; |
12 |
> |
$self->{admindir}=".SCRAM"; |
13 |
> |
$self->{configurationdir} = "config"; |
14 |
> |
$self->{forcearch} = shift || ""; |
15 |
> |
$self->{arch} = $self->{forcearch} || $ENV{SCRAM_ARCH}; |
16 |
> |
return $self; |
17 |
> |
} |
18 |
> |
|
19 |
> |
sub toolcachename |
20 |
> |
{ |
21 |
> |
my $self=shift; |
22 |
> |
return ($self->archdir()."/ToolCache.db.gz"); |
23 |
> |
} |
24 |
> |
|
25 |
> |
sub projectcachename |
26 |
> |
{ |
27 |
> |
my $self=shift; |
28 |
> |
return ($self->archdir()."/ProjectCache.db.gz"); |
29 |
> |
} |
30 |
> |
|
31 |
> |
sub symlinks { |
32 |
> |
my $self=shift; |
33 |
> |
if (@_) {$self->{symlinks}=shift;} |
34 |
> |
return $self->{symlinks}; |
35 |
> |
} |
36 |
> |
|
37 |
> |
sub calchksum { |
38 |
> |
my $self=shift; |
39 |
> |
my $dir=$self->location()."/".$self->configurationdir(); |
40 |
> |
my $sum=""; |
41 |
> |
if (-f "${dir}/config_tag") |
42 |
> |
{ |
43 |
> |
my $ref; |
44 |
> |
open ($ref, "${dir}/config_tag"); |
45 |
> |
$sum=<$ref>; |
46 |
> |
close($ref); |
47 |
> |
chomp $sum; |
48 |
> |
} |
49 |
> |
else |
50 |
> |
{ |
51 |
> |
push @INC,$dir; |
52 |
> |
require SCRAM::Plugins::ProjectChkSum; |
53 |
> |
$sum=&SCRAM::Plugins::ProjectChkSum::chksum($dir); |
54 |
> |
pop @INC; |
55 |
> |
} |
56 |
> |
return $sum; |
57 |
|
} |
58 |
|
|
59 |
< |
sub setup { |
59 |
> |
sub configchksum { |
60 |
|
my $self=shift; |
61 |
< |
|
62 |
< |
# --- find out the location |
68 |
< |
my $location=$self->requestoption("area_location", |
69 |
< |
"Please Enter the location of the directory"); |
70 |
< |
if ( $location!~/^\// ) { |
71 |
< |
$location=cwd()."/".$location; |
72 |
< |
} |
73 |
< |
|
74 |
< |
# --- find area directory name , default name projectname_version |
75 |
< |
my $name=$self->option("area_name"); |
76 |
< |
if ( ! defined $name ) { |
77 |
< |
$name=$self->defaultdirname(); |
78 |
< |
} |
79 |
< |
$self->location($location."/".$name); |
80 |
< |
|
81 |
< |
# make a new store handler |
82 |
< |
$self->_setupstore(); |
83 |
< |
|
84 |
< |
# --- download everything first |
85 |
< |
# FIX-ME --- cacheing is broken |
86 |
< |
$self->parse("download"); |
87 |
< |
|
88 |
< |
# --- and parse the setup file |
89 |
< |
$self->parse("setup"); |
90 |
< |
|
91 |
< |
# --- store bootstrap info |
92 |
< |
$self->store($self->location()."/.SCRAM/ConfigArea.dat"); |
93 |
< |
|
94 |
< |
# --- store self in original database |
95 |
< |
$self->parentconfig()->store($self,"ConfigArea",$self->name(), |
96 |
< |
$self->version()); |
61 |
> |
if (@_) {$self->{configchksum}=shift;} |
62 |
> |
return $self->{configchksum}; |
63 |
|
} |
64 |
|
|
99 |
– |
sub _setupstore { |
100 |
– |
my $self=shift; |
65 |
|
|
66 |
< |
# --- make a new ActiveStore at the location and add it to the db list |
103 |
< |
my $ad=ActiveDoc::ActiveConfig->new($self->location()."/\.SCRAM"); |
104 |
< |
|
105 |
< |
$self->parentconfig($self->config()); |
106 |
< |
# $self->config(Configuration::ConfigureStore->new()); |
107 |
< |
# $self->config()->db("local",$ad); |
108 |
< |
# $self->config()->db("parent",$self->parentconfig()); |
109 |
< |
# $self->config()->policy("cache","local"); |
110 |
< |
$self->config($ad); |
111 |
< |
$self->config()->basedoc($self->parentconfig()->basedoc()); |
112 |
< |
} |
113 |
< |
|
114 |
< |
sub bootstrapfromlocation { |
66 |
> |
sub name { |
67 |
|
my $self=shift; |
68 |
< |
|
69 |
< |
if ( ! defined $self->location(@_) ) { |
118 |
< |
$self->error("Unable to locate the top of local configuration area"); |
119 |
< |
} |
120 |
< |
print "Found top ".$self->location()."\n"; |
121 |
< |
$self->_setupstore(); |
122 |
< |
$self->restore($self->location()."/.SCRAM/ConfigArea.dat"); |
68 |
> |
@_?$self->{name}=shift |
69 |
> |
:$self->{name}; |
70 |
|
} |
71 |
|
|
72 |
< |
sub parentconfig { |
72 |
> |
sub version { |
73 |
|
my $self=shift; |
74 |
< |
@_?$self->{parentconfig}=shift |
75 |
< |
:$self->{parentconfig}; |
74 |
> |
@_?$self->{version}=shift |
75 |
> |
:$self->{version}; |
76 |
|
} |
77 |
|
|
78 |
< |
sub store { |
78 |
> |
sub setup { |
79 |
|
my $self=shift; |
80 |
|
my $location=shift; |
81 |
< |
|
82 |
< |
my $fh=$self->openfile(">".$location); |
83 |
< |
$self->savevar($fh,"location", $self->location()); |
84 |
< |
$self->savevar($fh,"url", $self->url()); |
85 |
< |
$self->savevar($fh,"name", $self->name()); |
86 |
< |
$self->savevar($fh,"version", $self->version()); |
87 |
< |
$fh->close(); |
81 |
> |
my $areaname=shift || undef; |
82 |
> |
my $symlinks=shift || 0; |
83 |
> |
my $locarea = shift || undef; |
84 |
> |
if ( (! defined $areaname) || ( $areaname eq "" ) ) { |
85 |
> |
$areaname=$self->version(); |
86 |
> |
} |
87 |
> |
$self->location($location."/".$areaname); |
88 |
> |
$self->symlinks($symlinks); |
89 |
> |
if ($self->configchksum() ne "") |
90 |
> |
{ |
91 |
> |
if ((!-defined $locarea) && (-f "${location}/${areaname}/".$self->admindir()."/Environment")) |
92 |
> |
{ |
93 |
> |
$locarea=Configuration::ConfigArea->new(); |
94 |
> |
$locarea->bootstrapfromlocation("${location}/${areaname}"); |
95 |
> |
} |
96 |
> |
if ((defined $locarea) && ($locarea->configchksum() != $self->configchksum())) |
97 |
> |
{ |
98 |
> |
print "ERROR: Can not setup your current working area for SCRAM_ARCH: $ENV{SCRAM_ARCH}\n", |
99 |
> |
"Your current development area ${location}/${areaname}\n", |
100 |
> |
"is using a different ${areaname}/config then the one used for\n", |
101 |
> |
$self->releasetop(),".\n"; |
102 |
> |
exit 1; |
103 |
> |
} |
104 |
> |
} |
105 |
> |
Utilities::AddDir::adddir($self->archdir()); |
106 |
|
} |
107 |
|
|
108 |
< |
sub copy { |
108 |
> |
sub configurationdir { |
109 |
|
my $self=shift; |
110 |
< |
my $destination=shift; |
111 |
< |
use File::Basename; |
112 |
< |
# create the area |
113 |
< |
|
149 |
< |
AddDir::adddir(dirname($destination)); |
150 |
< |
|
151 |
< |
my @cpcmd=(qw(cp -r), "$self->location()", "$destination"); |
152 |
< |
print "@cpcmd"; |
153 |
< |
# File::Copy::copy("$self->location()", "$destination") or |
154 |
< |
system(@cpcmd) or |
155 |
< |
$self->error("Cannot copy ".$self->location(). |
156 |
< |
" to $destination ".$!); |
157 |
< |
|
158 |
< |
# create a new object based on the new area |
159 |
< |
my $newarea=ref($self)->new($self->parentconfig()); |
160 |
< |
$newarea->bootstrapfromlocation($destination); |
161 |
< |
# save it with the new location info |
162 |
< |
$newarea->store($self->location()."/.SCRAM/ConfigArea.dat"); |
110 |
> |
if ( @_ ) { |
111 |
> |
$self->{configurationdir}=shift; |
112 |
> |
} |
113 |
> |
return (defined $self->{configurationdir})?$self->{configurationdir}:undef; |
114 |
|
} |
115 |
|
|
116 |
< |
sub restore { |
116 |
> |
sub sourcedir { |
117 |
|
my $self=shift; |
118 |
< |
my $location=shift; |
119 |
< |
|
120 |
< |
my $fh=$self->openfile("<".$location); |
121 |
< |
my $varhash={}; |
171 |
< |
$self->restorevars($fh,$varhash); |
172 |
< |
if ( ! defined $self->location() ) { |
173 |
< |
$self->location($$varhash{"location"}); |
174 |
< |
} |
175 |
< |
$self->_setupstore(); |
176 |
< |
$self->url($$varhash{"url"}); |
177 |
< |
$self->name($$varhash{"name"}); |
178 |
< |
$self->version($$varhash{"version"}); |
179 |
< |
$fh->close(); |
118 |
> |
if ( @_ ) { |
119 |
> |
$self->{sourcedir}=shift; |
120 |
> |
} |
121 |
> |
return (defined $self->{sourcedir})?$self->{sourcedir}:undef; |
122 |
|
} |
123 |
|
|
124 |
< |
sub name { |
124 |
> |
sub releasetop { |
125 |
|
my $self=shift; |
126 |
< |
|
127 |
< |
@_?$self->{name}=shift |
128 |
< |
:$self->{name}; |
126 |
> |
if ( @_ ) { |
127 |
> |
$self->{releasetop}=shift; |
128 |
> |
} |
129 |
> |
return (defined $self->{releasetop})?$self->{releasetop}:undef; |
130 |
|
} |
131 |
|
|
132 |
< |
sub version { |
133 |
< |
my $self=shift; |
132 |
> |
sub admindir() |
133 |
> |
{ |
134 |
> |
my $self=shift; |
135 |
> |
|
136 |
> |
@_ ? $self->{admindir} = shift |
137 |
> |
: $self->{admindir}; |
138 |
> |
} |
139 |
|
|
140 |
< |
@_?$self->{version}=shift |
141 |
< |
:$self->{version}; |
140 |
> |
sub bootstrapfromlocation { |
141 |
> |
my $self=shift; |
142 |
> |
my $location = $self->searchlocation(shift); |
143 |
> |
my $rv=0; |
144 |
> |
if ( ! defined $location) { |
145 |
> |
$rv=1; |
146 |
> |
} |
147 |
> |
else { |
148 |
> |
$self->location($location); |
149 |
> |
$self->_LoadEnvFile(); |
150 |
> |
} |
151 |
> |
return $rv; |
152 |
|
} |
153 |
|
|
154 |
|
sub location { |
156 |
|
|
157 |
|
if ( @_ ) { |
158 |
|
$self->{location}=shift; |
159 |
+ |
delete $self->{archs}; |
160 |
+ |
$self->_setAreaArch(); |
161 |
|
} |
162 |
|
elsif ( ! defined $self->{location} ) { |
163 |
|
# try and find the release location |
164 |
|
$self->{location}=$self->searchlocation(); |
165 |
+ |
if (defined $self->{location}) |
166 |
+ |
{ |
167 |
+ |
$self->_setAreaArch() |
168 |
+ |
} |
169 |
|
} |
170 |
|
return $self->{location}; |
171 |
|
} |
172 |
|
|
173 |
|
sub searchlocation { |
174 |
|
my $self=shift; |
175 |
< |
|
175 |
> |
|
176 |
|
#start search in current directory if not specified |
177 |
|
my $thispath; |
178 |
< |
@_?$thispath=shift |
179 |
< |
:$thispath=cwd(); |
180 |
< |
|
178 |
> |
if ( @_ ) { |
179 |
> |
$thispath=shift |
180 |
> |
} |
181 |
> |
else { |
182 |
> |
$thispath=cwd(); |
183 |
> |
} |
184 |
> |
|
185 |
|
my $rv=0; |
186 |
|
|
187 |
+ |
# chop off any files - we only want dirs |
188 |
+ |
if ( -f $thispath ) { |
189 |
+ |
$thispath=~s/(.*)\/.*/$1/; |
190 |
+ |
} |
191 |
|
Sloop:{ |
192 |
|
do { |
193 |
< |
# print "Searching $thispath\n"; |
194 |
< |
if ( -e "$thispath/.SCRAM" ) { |
195 |
< |
# print "Found\n"; |
193 |
> |
$self->verbose("Searching $thispath"); |
194 |
> |
if ( -e "$thispath/".$self->{admindir} ) { |
195 |
> |
$self->verbose("Found\n"); |
196 |
|
$rv=1; |
197 |
|
last Sloop; |
198 |
|
} |
199 |
|
} while ( ($thispath=~s/(.*)\/.*/$1/)=~/./ ) }; |
200 |
< |
|
200 |
> |
|
201 |
|
return $rv?$thispath:undef; |
202 |
|
} |
203 |
|
|
204 |
< |
sub meta { |
204 |
> |
sub archname { |
205 |
|
my $self=shift; |
206 |
< |
|
207 |
< |
my $string=$self->name()." ".$self->version()." located at :\n ". |
208 |
< |
$self->location; |
206 |
> |
if ( @_ ) { |
207 |
> |
$self->{arch} = shift; |
208 |
> |
if (defined $self->{location}) { |
209 |
> |
$self->archdir($self->{location}."/".$self->{admindir}."/".$self->{arch}); |
210 |
> |
} |
211 |
> |
} |
212 |
> |
return $self->{arch}; |
213 |
|
} |
214 |
|
|
215 |
< |
sub configitem { |
215 |
> |
sub archdir { |
216 |
|
my $self=shift; |
217 |
< |
|
218 |
< |
return ($self->config()->find("ConfigItem",@_)); |
217 |
> |
if ( @_ ) { |
218 |
> |
$self->{archdir}=shift; |
219 |
> |
} |
220 |
> |
return $self->{archdir}; |
221 |
|
} |
222 |
|
|
223 |
< |
sub addconfigitem { |
223 |
> |
sub satellite { |
224 |
|
my $self=shift; |
225 |
< |
my $url=shift; |
226 |
< |
|
227 |
< |
my $docref=$self->activatedoc($url); |
228 |
< |
# Set up the document |
229 |
< |
$docref->setup(); |
230 |
< |
# $self->config()->storepolicy("local"); |
231 |
< |
$docref->save(); |
225 |
> |
my $relloc = $self->location(); |
226 |
> |
my $sat=Configuration::ConfigArea->new($ENV{SCRAM_ARCH}); |
227 |
> |
$sat->name($self->name()); |
228 |
> |
$sat->version($self->version()); |
229 |
> |
$sat->configurationdir($self->configurationdir()); |
230 |
> |
$sat->sourcedir($self->sourcedir()); |
231 |
> |
$sat->releasetop($relloc); |
232 |
> |
$sat->configchksum($self->configchksum()); |
233 |
> |
$sat->setup(@_); |
234 |
> |
my $devconf = $sat->location()."/".$sat->configurationdir(); |
235 |
> |
my $relconf = $self->location()."/".$self->configurationdir(); |
236 |
> |
if (!-d $devconf) |
237 |
> |
{ |
238 |
> |
$self->copywithskip($relconf,$devconf,['toolbox']); |
239 |
> |
} |
240 |
> |
Utilities::AddDir::copydir("${relconf}/toolbox/".$self->{arch},"${devconf}/toolbox/".$self->{arch}); |
241 |
> |
Utilities::AddDir::adddir ($sat->location()."/".$sat->sourcedir()); |
242 |
> |
$self->copywithskip($self->archdir(),$sat->archdir(),["InstalledTools","ProjectCache.db.gz","RuntimeCache.db.gz","DirCache.db.gz","MakeData/DirCache","MakeData/DirCache.mk","MakeData/src.mk"]); |
243 |
> |
my $envfile = $sat->archdir()."/Environment"; |
244 |
> |
open ( $fh, "> $envfile" ) or $sat->error("Cannot Open \"$envfile\" file to Save\n $!"); |
245 |
> |
print $fh "RELEASETOP=$relloc\n"; |
246 |
> |
close($fh); |
247 |
> |
$envfile = $sat->location()."/".$self->{admindir}."/Environment"; |
248 |
> |
if (! -f $envfile) |
249 |
> |
{ |
250 |
> |
$sat->save (); |
251 |
> |
} |
252 |
> |
return $sat; |
253 |
> |
} |
254 |
> |
|
255 |
> |
sub copywithskip { |
256 |
> |
my $self=shift; |
257 |
> |
my $src=shift; |
258 |
> |
my $des=shift; |
259 |
> |
my $filetoskip=shift || []; |
260 |
> |
my $rv=1; |
261 |
> |
if ( $src ne $des ) |
262 |
> |
{ |
263 |
> |
if ( -d $src ) |
264 |
> |
{ |
265 |
> |
my $fs=[]; |
266 |
> |
foreach my $f (@$filetoskip) {push @$fs,"${src}/${f}";} |
267 |
> |
Utilities::AddDir::copydirwithskip($src,$des,$fs); |
268 |
> |
$rv=0; |
269 |
> |
} |
270 |
> |
} |
271 |
> |
return $rv; |
272 |
|
} |
273 |
|
|
274 |
< |
# -------------- Tags --------------------------------- |
257 |
< |
# -- init parse |
258 |
< |
sub Project_Start { |
274 |
> |
sub copyenv { |
275 |
|
my $self=shift; |
260 |
– |
my $name=shift; |
276 |
|
my $hashref=shift; |
277 |
< |
|
278 |
< |
$self->checktag($name,$hashref,'name'); |
279 |
< |
$self->checktag($name,$hashref,'version'); |
280 |
< |
|
266 |
< |
$self->name($$hashref{'name'}); |
267 |
< |
$self->version($$hashref{'version'}); |
277 |
> |
|
278 |
> |
foreach $elem ( keys %{$self->{ENV}} ) { |
279 |
> |
$$hashref{$elem}=$self->{ENV}{$elem}; |
280 |
> |
} |
281 |
|
} |
282 |
|
|
283 |
< |
|
271 |
< |
sub Project_text { |
283 |
> |
sub arch { |
284 |
|
my $self=shift; |
285 |
< |
my $name=shift; |
274 |
< |
my $string=shift; |
275 |
< |
|
276 |
< |
print $string; |
285 |
> |
return $self->{arch}; |
286 |
|
} |
287 |
|
|
288 |
< |
# ---- download parse |
280 |
< |
|
281 |
< |
sub Use_download_Start { |
288 |
> |
sub save { |
289 |
|
my $self=shift; |
290 |
< |
my $name=shift; |
284 |
< |
my $hashref=shift; |
285 |
< |
|
286 |
< |
$self->checktag($name,$hashref,'url'); |
287 |
< |
print "Downloading .... ".$$hashref{'url'}."\n"; |
288 |
< |
$self->getfile($$hashref{'url'}); |
290 |
> |
$self->_SaveEnvFile(); |
291 |
|
} |
292 |
|
|
293 |
< |
# --- setup parse |
294 |
< |
|
295 |
< |
sub Use_Start { |
296 |
< |
my $self=shift; |
297 |
< |
my $name=shift; |
298 |
< |
my $hashref=shift; |
293 |
> |
# ---- support routines |
294 |
> |
|
295 |
> |
sub _setAreaArch { |
296 |
> |
my ($self) = @_; |
297 |
> |
my $arch = $self->{forcearch}; |
298 |
> |
if ($arch eq "") |
299 |
> |
{ |
300 |
> |
if (!exists $self->{archs}) |
301 |
> |
{ |
302 |
> |
$self->{archs}=[]; |
303 |
> |
my $toolbox = $self->{location}.'/'.$self->{configurationdir}.'/toolbox'; |
304 |
> |
foreach my $arch (glob("${toolbox}/*")) { |
305 |
> |
if (-d "${arch}/tools") { |
306 |
> |
$arch=~s/^$toolbox\///; |
307 |
> |
push @{$self->{archs}},$arch; |
308 |
> |
} |
309 |
> |
} |
310 |
> |
} |
311 |
> |
if ((!-d "${toolbox}/".$self->{arch}) && (scalar(@{$self->{archs}})==1)) { $arch = $self->{archs}[0]; } |
312 |
> |
} |
313 |
> |
$self->archname($arch || $self->{arch}); |
314 |
> |
return; |
315 |
> |
} |
316 |
> |
|
317 |
> |
sub _SaveEnvFile |
318 |
> |
{ |
319 |
> |
my $self=shift; |
320 |
> |
|
321 |
> |
my $fh; |
322 |
> |
my $envfile = $self->location()."/".$self->{admindir}."/Environment"; |
323 |
> |
open ( $fh, "> $envfile" ) or $self->error("Cannot Open \"$envfile\" file to Save\n $!"); |
324 |
|
|
325 |
< |
$self->checktag($name,$hashref,'url'); |
326 |
< |
$self->addconfigitem($$hashref{'url'}); |
327 |
< |
} |
328 |
< |
|
325 |
> |
print $fh "SCRAM_PROJECTNAME=".$self->name()."\n"; |
326 |
> |
print $fh "SCRAM_PROJECTVERSION=".$self->version()."\n"; |
327 |
> |
print $fh "SCRAM_CONFIGDIR=".$self->configurationdir()."\n"; |
328 |
> |
print $fh "SCRAM_SOURCEDIR=".$self->sourcedir()."\n"; |
329 |
> |
print $fh "SCRAM_SYMLINKS=",$self->symlinks(),"\n"; |
330 |
> |
print $fh "SCRAM_CONFIGCHKSUM=",$self->configchksum(),"\n"; |
331 |
> |
close($fh); |
332 |
> |
|
333 |
> |
# Set the default permissions (-rw-r--r--): |
334 |
> |
my $filemode = 0644; |
335 |
> |
chmod $filemode, $self->location()."/".$self->{admindir}."/Environment"; |
336 |
> |
} |
337 |
> |
|
338 |
> |
sub _LoadEnvFile |
339 |
> |
{ |
340 |
> |
my $self=shift; |
341 |
> |
|
342 |
> |
my $fh; |
343 |
> |
my $envfile = $self->location()."/".$self->{admindir}."/Environment"; |
344 |
> |
open ( $fh, "< $envfile" ) or $self->error("Cannot open \"$envfile\" file for reading.\n $!"); |
345 |
> |
while ( <$fh> ) |
346 |
> |
{ |
347 |
> |
chomp; |
348 |
> |
next if /^#/; |
349 |
> |
next if /^\s*$/ ; |
350 |
> |
($name, $value)=split /=/; |
351 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
352 |
> |
} |
353 |
> |
close($fh); |
354 |
> |
$envfile = $self->archdir()."/Environment"; |
355 |
> |
if (-f $envfile) |
356 |
> |
{ |
357 |
> |
open ( $fh, "< $envfile" ) or $self->error("Cannot open \"$envfile\" file for reading.\n $!"); |
358 |
> |
while ( <$fh> ) |
359 |
> |
{ |
360 |
> |
chomp; |
361 |
> |
next if /^#/; |
362 |
> |
next if /^\s*$/ ; |
363 |
> |
($name, $value)=split /=/; |
364 |
> |
eval "\$self->{ENV}{${name}}=\"$value\""; |
365 |
> |
} |
366 |
> |
close($fh); |
367 |
> |
} |
368 |
> |
|
369 |
> |
# -- set internal variables appropriately |
370 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTNAME"} ) |
371 |
> |
{ |
372 |
> |
$self->name($self->{ENV}{"SCRAM_PROJECTNAME"}); |
373 |
> |
} |
374 |
> |
if ( defined $self->{ENV}{"SCRAM_SYMLINKS"} ) |
375 |
> |
{ |
376 |
> |
$self->symlinks($self->{ENV}{"SCRAM_SYMLINKS"}); |
377 |
> |
} |
378 |
> |
if ( defined $self->{ENV}{"SCRAM_CONFIGCHKSUM"} ) |
379 |
> |
{ |
380 |
> |
$self->configchksum($self->{ENV}{"SCRAM_CONFIGCHKSUM"}); |
381 |
> |
} |
382 |
> |
if ( defined $self->{ENV}{"SCRAM_PROJECTVERSION"} ) |
383 |
> |
{ |
384 |
> |
$self->version($self->{ENV}{"SCRAM_PROJECTVERSION"}); |
385 |
> |
} |
386 |
> |
if ( defined $self->{ENV}{"SCRAM_CONFIGDIR"} ) |
387 |
> |
{ |
388 |
> |
$self->configurationdir($self->{ENV}{"SCRAM_CONFIGDIR"}); |
389 |
> |
} |
390 |
> |
if ( defined $self->{ENV}{"SCRAM_SOURCEDIR"} ) |
391 |
> |
{ |
392 |
> |
$self->sourcedir($self->{ENV}{"SCRAM_SOURCEDIR"}); |
393 |
> |
} |
394 |
> |
if ( defined $self->{ENV}{"RELEASETOP"} ) |
395 |
> |
{ |
396 |
> |
$self->releasetop($self->{ENV}{"RELEASETOP"}); |
397 |
> |
} |
398 |
> |
} |
399 |
> |
1; |