5 |
|
require Exporter; |
6 |
|
@ISA=qw(Exporter); |
7 |
|
@EXPORT=qw(BootStrapProject); |
8 |
+ |
use Utilities::cvsmodule; |
9 |
|
|
10 |
|
sub BootStrapProject($) { |
11 |
|
my $url=shift; |
12 |
|
# my $outputfile=shift; |
13 |
|
|
14 |
< |
use urlhandler; |
15 |
< |
use Switcher; |
14 |
> |
use Utilities::urlhandler; |
15 |
> |
use Utilities::Switcher; |
16 |
|
|
17 |
|
my $filename; |
18 |
|
$BootHash={ |
19 |
+ |
'cvsrep_StartTag' => \&cvsrep_start, |
20 |
+ |
'cvsrep' => 'none', |
21 |
+ |
'cvsrep_EndTag' => \&cvsrep_end, |
22 |
+ |
'cvs_StartTag' => \&cvs_start, |
23 |
+ |
'cvs' => 'none', |
24 |
+ |
'cvs_EndTag' => 'none', |
25 |
|
'config_starttag' => \&config_starttag, |
26 |
+ |
'config_endtag' => \&config_endtag, |
27 |
|
'config' => 'none', |
28 |
|
'base' => 'none', |
29 |
|
'base_starttag' => \&base_start, |
39 |
|
'file' => 'none', |
40 |
|
'file_starttag' => \&file_start |
41 |
|
}; |
42 |
< |
$filename=urlhandler($url); |
42 |
> |
$filename=urlhandler::urlhandler($url); |
43 |
|
$switch=Switcher->new($BootHash, $filename); |
44 |
|
$switch->parse(); |
45 |
|
} |
47 |
|
sub Bootlocaltop($hashref) { |
48 |
|
my $hashref=shift; |
49 |
|
use Cwd; |
50 |
< |
use AddDir; |
50 |
> |
use Utilities::AddDir; |
51 |
|
|
52 |
< |
checkparam($hashref, $name, "name"); |
53 |
< |
checkparam($hashref, $name, "version"); |
52 |
> |
$switch->checkparam($hashref, $name, "name"); |
53 |
> |
$switch->checkparam($hashref, $name, "version"); |
54 |
|
$ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$$hashref{'version'}; |
55 |
|
$scramdir=$ENV{LOCALTOP}."/.SCRAM"; |
56 |
< |
&adddir($scramdir); |
56 |
> |
&AddDir::adddir($scramdir); |
57 |
> |
chdir $ENV{LOCALTOP}; |
58 |
|
} |
59 |
|
|
60 |
|
sub project_start { |
74 |
|
"version=$$hashref{version}>\n"; |
75 |
|
print INSTALLFILE "<base urltype=file value=$scramdir>\n"; |
76 |
|
print INSTALLFILE "<file name=Environment>\n"; |
77 |
+ |
push @{ $basehash{file}}, "$ENV{SCRAM_HOME}/toolbox"; |
78 |
+ |
$lastbasekey='file'; |
79 |
+ |
push @dirstack, $scramdir; |
80 |
+ |
$currentdir=$scramdir; |
81 |
|
} |
82 |
|
|
83 |
|
sub project_finish { |
95 |
|
my $hashref; |
96 |
|
|
97 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
98 |
< |
checkparam($hashref, $name, "dir"); |
98 |
> |
$switch->checkparam($hashref, $name, "dir"); |
99 |
|
print ENVIRONMENT 'projconfigdir='.$$hashref{'dir'}."\n"; |
100 |
|
$ENV{SCRAM_BootStrapFiles}=$ENV{SCRAM_BootStrapFiles}.":". |
101 |
|
$ENV{LOCALTOP}."/".$$hashref{'dir'}; |
102 |
+ |
push @dirstack, $ENV{LOCALTOP}."/".$$hashref{'dir'}; |
103 |
+ |
$currentdir=$ENV{LOCALTOP}."/".$$hashref{'dir'}; |
104 |
+ |
} |
105 |
+ |
sub config_endtag { |
106 |
+ |
pop @dirstack; |
107 |
+ |
$currentdir=$dirstack[$#dirstack]; |
108 |
|
} |
109 |
|
|
110 |
|
sub file_start { |
113 |
|
my $hashref; |
114 |
|
|
115 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
116 |
< |
checkparam($hashref, $name, "name"); |
116 |
> |
$switch->checkparam($hashref, $name, "name"); |
117 |
|
# now download the file |
118 |
|
print "Downloading File .... $$hashref{'name'}\n"; |
119 |
< |
&urlhandler(&geturlbase."/".$$hashref{'name'}, |
119 |
> |
&urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'}, |
120 |
|
$scramdir."/".$$hashref{'name'}) ; |
121 |
|
if ( $switch->context('project') ) { |
122 |
|
print INSTALLFILE "<$name name=$$hashref{name}>\n"; |
129 |
|
my $hashref; |
130 |
|
|
131 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
132 |
< |
checkparam($hashref, $name, "name"); |
132 |
> |
$switch->checkparam($hashref, $name, "name"); |
133 |
|
use clientfile; |
134 |
|
$ENV{SCRAM_ProjReqsDoc}= |
135 |
< |
&urlhandler(&geturlbase."/".$$hashref{'name'}, |
136 |
< |
$scramdir."/".$$hashref{'name'}) ; |
135 |
> |
$currentdir."/".$$hashref{'name'}; |
136 |
> |
# &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'}, |
137 |
> |
# $scramdir."/".$$hashref{'name'}) ; |
138 |
|
if ( $switch->context("project") ) { |
139 |
|
print INSTALLFILE "<$name name=$$hashref{name}>\n"; |
140 |
|
} |
146 |
|
my $hashref; |
147 |
|
|
148 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
149 |
< |
checkparam($hashref, $name, 'urltype'); |
150 |
< |
checkparam($hashref, $name, 'value'); |
149 |
> |
$switch->checkparam($hashref, $name, 'urltype'); |
150 |
> |
$switch->checkparam($hashref, $name, 'value'); |
151 |
|
push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'}; |
152 |
|
$lastbasekey=$$hashref{'urltype'}; |
153 |
|
#print $lastbasekey." lastbasekey \n"; |
157 |
|
pop @{ $basehash{$lastbasekey} }; |
158 |
|
} |
159 |
|
|
160 |
< |
sub checkparam($hash, $name, $key) { |
161 |
< |
my $hashref=shift; |
162 |
< |
my $name=shift; |
163 |
< |
my $key=shift; |
164 |
< |
|
165 |
< |
if ( ! defined $$hashref{$key} ) { |
166 |
< |
print "BootParser: Badly formed $name tag -". |
167 |
< |
" undefined $key parameter\n"; |
168 |
< |
exit 1; |
169 |
< |
} |
170 |
< |
$$hashref{$key}=~s/["']//; |
171 |
< |
} |
160 |
> |
#sub checkparam($hash, $name, $key) { |
161 |
> |
# my $hashref=shift; |
162 |
> |
# my $name=shift; |
163 |
> |
# my $key=shift; |
164 |
> |
# |
165 |
> |
# if ( ! defined $$hashref{$key} ) { |
166 |
> |
# print "BootParser: Badly formed $name tag -". |
167 |
> |
# " undefined $key parameter\n"; |
168 |
> |
# exit 1; |
169 |
> |
# } |
170 |
> |
# $$hashref{$key}=~s/["']//; |
171 |
> |
#} |
172 |
|
|
173 |
|
#Just a file for now! |
174 |
|
#Will eventually cross ref with access checker to get types available. |
203 |
|
my $name=shift; |
204 |
|
my @vars=@_; |
205 |
|
my $hashref; |
206 |
+ |
use Utilities::AddDir; |
207 |
+ |
use File::Copy; |
208 |
+ |
|
209 |
+ |
# copy across the files in the config directory |
210 |
+ |
AddDir::adddir($ENV{LOCALTOP}/$ENV{projconfigdir}); |
211 |
+ |
copy "$ENV{RELEASETOP}/$ENV{projconfigdir}", |
212 |
+ |
"$ENV{LOCALTOP}/$ENV{projconfigdir}"; |
213 |
+ |
} |
214 |
+ |
|
215 |
+ |
sub cvsrep_start { |
216 |
+ |
my $name=shift; |
217 |
+ |
my @vars=@_; |
218 |
+ |
my $hashref; |
219 |
+ |
|
220 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
221 |
+ |
$switch->checkparam($hashref, $name, 'auth' ); |
222 |
+ |
$switch->checkparam($hashref, $name, 'base' ); |
223 |
+ |
$cvsobject=cvsmodule->new(); |
224 |
+ |
$cvsobject->set_base($$hashref{base}); |
225 |
+ |
$cvsobject->set_auth($$hashref{auth}); |
226 |
+ |
if ( exists $$hashref{user} ) { |
227 |
+ |
$cvsobject->set_user($$hashref{user}); |
228 |
+ |
} |
229 |
+ |
if ( exists $$hashref{passkey} ) { |
230 |
+ |
$cvsobject->set_passkey($$hashref{passkey}); |
231 |
+ |
} |
232 |
+ |
} |
233 |
+ |
|
234 |
+ |
sub cvsrep_end { |
235 |
+ |
my $name=shift; |
236 |
+ |
$cvsobject=undef; #Move out of scope to destroy cvsrep context |
237 |
+ |
} |
238 |
+ |
|
239 |
+ |
sub cvs_start { |
240 |
+ |
my $name=shift; |
241 |
+ |
my @vars=@_; |
242 |
+ |
my $hashref; |
243 |
+ |
|
244 |
+ |
if ( ! defined $cvsobject ) { |
245 |
+ |
print "BootStraper: Undefined cvs repository on line ". |
246 |
+ |
$switch->{linenumber}."\n - set up repository". |
247 |
+ |
"specifics with the <cvsrep> flag\n"; |
248 |
+ |
exit 1; |
249 |
+ |
} |
250 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
251 |
+ |
$switch->checkparam( $hashref, $name, "fn" ); |
252 |
+ |
$cvsobject->invokecvs( (split / /, $$hashref{fn} ) ); |
253 |
|
} |