5 |
|
require Exporter; |
6 |
|
@ISA=qw(Exporter); |
7 |
|
@EXPORT=qw(BootStrapProject); |
8 |
+ |
use Utilities::cvsmodule; |
9 |
|
|
10 |
|
sub BootStrapProject($) { |
11 |
|
my $url=shift; |
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 |
|
} |
46 |
|
|
47 |
< |
sub Bootlocaltop($hashref) { |
47 |
> |
sub Bootlocaltop { |
48 |
|
my $hashref=shift; |
49 |
|
use Cwd; |
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 |
+ |
if ( $switch->context('project') ) { |
105 |
+ |
print INSTALLFILE "<$name name=$$hashref{dir}>\n"; |
106 |
+ |
} |
107 |
+ |
} |
108 |
+ |
sub config_endtag { |
109 |
+ |
my $name=shift; |
110 |
+ |
|
111 |
+ |
pop @dirstack; |
112 |
+ |
$currentdir=$dirstack[$#dirstack]; |
113 |
+ |
if ( $switch->context('project') ) { |
114 |
+ |
print INSTALLFILE "</$name>\n"; |
115 |
+ |
} |
116 |
|
} |
117 |
|
|
118 |
|
sub file_start { |
121 |
|
my $hashref; |
122 |
|
|
123 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
124 |
< |
checkparam($hashref, $name, "name"); |
124 |
> |
$switch->checkparam($hashref, $name, "name"); |
125 |
|
# now download the file |
126 |
|
print "Downloading File .... $$hashref{'name'}\n"; |
127 |
< |
&urlhandler(&geturlbase."/".$$hashref{'name'}, |
127 |
> |
&urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'}, |
128 |
|
$scramdir."/".$$hashref{'name'}) ; |
129 |
|
if ( $switch->context('project') ) { |
130 |
|
print INSTALLFILE "<$name name=$$hashref{name}>\n"; |
137 |
|
my $hashref; |
138 |
|
|
139 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
140 |
< |
checkparam($hashref, $name, "name"); |
140 |
> |
$switch->checkparam($hashref, $name, "name"); |
141 |
|
use clientfile; |
142 |
|
$ENV{SCRAM_ProjReqsDoc}= |
143 |
< |
&urlhandler(&geturlbase."/".$$hashref{'name'}, |
144 |
< |
$scramdir."/".$$hashref{'name'}) ; |
143 |
> |
$currentdir."/".$$hashref{'name'}; |
144 |
> |
# &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'}, |
145 |
> |
# $scramdir."/".$$hashref{'name'}) ; |
146 |
|
if ( $switch->context("project") ) { |
147 |
|
print INSTALLFILE "<$name name=$$hashref{name}>\n"; |
148 |
|
} |
154 |
|
my $hashref; |
155 |
|
|
156 |
|
$hashref=$switch->SetupValueHash( \@vars ); |
157 |
< |
checkparam($hashref, $name, 'urltype'); |
158 |
< |
checkparam($hashref, $name, 'value'); |
157 |
> |
$switch->checkparam($hashref, $name, 'urltype'); |
158 |
> |
$switch->checkparam($hashref, $name, 'value'); |
159 |
|
push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'}; |
160 |
|
$lastbasekey=$$hashref{'urltype'}; |
161 |
|
#print $lastbasekey." lastbasekey \n"; |
165 |
|
pop @{ $basehash{$lastbasekey} }; |
166 |
|
} |
167 |
|
|
168 |
< |
sub checkparam($hash, $name, $key) { |
169 |
< |
my $hashref=shift; |
170 |
< |
my $name=shift; |
171 |
< |
my $key=shift; |
172 |
< |
|
173 |
< |
if ( ! defined $$hashref{$key} ) { |
174 |
< |
print "BootParser: Badly formed $name tag -". |
175 |
< |
" undefined $key parameter\n"; |
176 |
< |
exit 1; |
177 |
< |
} |
178 |
< |
$$hashref{$key}=~s/["']//; |
179 |
< |
} |
168 |
> |
#sub checkparam($hash, $name, $key) { |
169 |
> |
# my $hashref=shift; |
170 |
> |
# my $name=shift; |
171 |
> |
# my $key=shift; |
172 |
> |
# |
173 |
> |
# if ( ! defined $$hashref{$key} ) { |
174 |
> |
# print "BootParser: Badly formed $name tag -". |
175 |
> |
# " undefined $key parameter\n"; |
176 |
> |
# exit 1; |
177 |
> |
# } |
178 |
> |
# $$hashref{$key}=~s/["']//; |
179 |
> |
#} |
180 |
|
|
181 |
|
#Just a file for now! |
182 |
|
#Will eventually cross ref with access checker to get types available. |
212 |
|
my @vars=@_; |
213 |
|
my $hashref; |
214 |
|
} |
215 |
+ |
|
216 |
+ |
sub cvsrep_start { |
217 |
+ |
my $name=shift; |
218 |
+ |
my @vars=@_; |
219 |
+ |
my $hashref; |
220 |
+ |
|
221 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
222 |
+ |
$switch->checkparam($hashref, $name, 'auth' ); |
223 |
+ |
$switch->checkparam($hashref, $name, 'base' ); |
224 |
+ |
$cvsobject=cvsmodule->new(); |
225 |
+ |
$cvsobject->set_base($$hashref{base}); |
226 |
+ |
$cvsobject->set_auth($$hashref{auth}); |
227 |
+ |
if ( exists $$hashref{user} ) { |
228 |
+ |
$cvsobject->set_user($$hashref{user}); |
229 |
+ |
} |
230 |
+ |
if ( exists $$hashref{passkey} ) { |
231 |
+ |
$cvsobject->set_passkey($$hashref{passkey}); |
232 |
+ |
} |
233 |
+ |
} |
234 |
+ |
|
235 |
+ |
sub cvsrep_end { |
236 |
+ |
my $name=shift; |
237 |
+ |
$cvsobject=undef; #Move out of scope to destroy cvsrep context |
238 |
+ |
} |
239 |
+ |
|
240 |
+ |
sub cvs_start { |
241 |
+ |
my $name=shift; |
242 |
+ |
my @vars=@_; |
243 |
+ |
my $hashref; |
244 |
+ |
|
245 |
+ |
if ( ! defined $cvsobject ) { |
246 |
+ |
print "BootStraper: Undefined cvs repository on line ". |
247 |
+ |
$switch->{linenumber}."\n - set up repository". |
248 |
+ |
"specifics with the <cvsrep> flag\n"; |
249 |
+ |
exit 1; |
250 |
+ |
} |
251 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
252 |
+ |
$switch->checkparam( $hashref, $name, "fn" ); |
253 |
+ |
$cvsobject->invokecvs( (split / /, $$hashref{fn} ) ); |
254 |
+ |
} |