ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.10
Committed: Fri Apr 16 14:50:24 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: ProtoEnd, V0_9_9, V0_9_8, V0_9_7, V0_9_6, V0_9_5, V0_9_4, V0_9_3, V0_9_2, V0_9_1, V0_9
Branch point for: V0_9branch
Changes since 1.9: +6 -1 lines
Log Message:
Allow for user specified development directory name

File Contents

# Content
1 #!/usr/local/bin/perl5
2 # Bootstrap file parser
3
4 package BootStrapProject;
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 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,
30 'base_endtag' => \&base_end,
31 'project' => 'none',
32 'project_starttag' => \&project_start,
33 'project_endtag' => \&project_finish,
34 'install' => \&install,
35 'install_starttag' => \&install_start,
36 'install_endtag' => \&install_finish,
37 'requirements' => 'none',
38 'requirements_starttag' => \&reqs_start,
39 'file' => 'none',
40 'file_starttag' => \&file_start
41 };
42 $filename=urlhandler::urlhandler($url);
43 $switch=Switcher->new($BootHash, $filename);
44 $switch->parse();
45 }
46
47 sub Bootlocaltop {
48 my $hashref=shift;
49 use Cwd;
50 use Utilities::AddDir;
51
52 $switch->checkparam($hashref, $name, "name");
53 $switch->checkparam($hashref, $name, "version");
54 if ( ! defined $ENV{devareaname} ) {
55 $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$$hashref{'version'};
56 }
57 else {
58 $ENV{LOCALTOP}=&cwd."/".$ENV{devareaname};
59 }
60 $scramdir=$ENV{LOCALTOP}."/.SCRAM";
61 &AddDir::adddir($scramdir);
62 chdir $ENV{LOCALTOP};
63 }
64
65 sub project_start {
66 my $name=shift;
67 my @vars=@_;
68 my $hashref;
69
70 $hashref=$switch->SetupValueHash( \@vars );
71 Bootlocaltop($hashref);
72 print "Installing Project $$hashref{'name'} ".
73 "Version $$hashref{'version'}\n";
74 open ( ENVIRONMENT , ">$scramdir/Environment" ) || die "Unable to open ".
75 "Environment file : $!\n";
76 print ENVIRONMENT 'SCRAM_PROJECTNAME='.$$hashref{'name'}."\n";
77 print ENVIRONMENT 'SCRAM_PROJVERSION='.$$hashref{'version'}."\n";
78 $ENV{SCRAM_BootStrapFiles}=$scramdir;
79 open INSTALLFILE, ">$scramdir/InstallFile";
80 print INSTALLFILE "<install name=$$hashref{name} ".
81 "version=$$hashref{version}>\n";
82 print INSTALLFILE "<base urltype=file value=$scramdir>\n";
83 print INSTALLFILE "<file name=Environment>\n";
84 push @{ $basehash{file}}, "$ENV{SCRAM_HOME}/toolbox";
85 $lastbasekey='file';
86 push @dirstack, $scramdir;
87 $currentdir=$scramdir;
88 }
89
90 sub project_finish {
91 print ENVIRONMENT "SCRAM_BootStrapFiles=".$ENV{SCRAM_BootStrapFiles}."\n";
92 print ENVIRONMENT "RELEASETOP=$ENV{LOCALTOP}\n";
93 close ENVIRONMENT;
94 print INSTALLFILE "</install>\n";
95 close INSTALLFILE
96 }
97
98 # Set where the project specific configuration files live for the project
99 sub config_starttag {
100 my $name=shift;
101 my @vars=@_;
102 my $hashref;
103
104 $hashref=$switch->SetupValueHash( \@vars );
105 $switch->checkparam($hashref, $name, "dir");
106 print ENVIRONMENT 'projconfigdir='.$$hashref{'dir'}."\n";
107 $ENV{SCRAM_BootStrapFiles}=$ENV{SCRAM_BootStrapFiles}.":".
108 $ENV{LOCALTOP}."/".$$hashref{'dir'};
109 push @dirstack, $ENV{LOCALTOP}."/".$$hashref{'dir'};
110 $currentdir=$ENV{LOCALTOP}."/".$$hashref{'dir'};
111 if ( $switch->context('project') ) {
112 print INSTALLFILE "<$name dir=$$hashref{dir}>\n";
113 }
114 }
115 sub config_endtag {
116 my $name=shift;
117
118 pop @dirstack;
119 $currentdir=$dirstack[$#dirstack];
120 if ( $switch->context('project') ) {
121 print INSTALLFILE "</$name>\n";
122 }
123 }
124
125 sub file_start {
126 my $name=shift;
127 my @vars=@_;
128 my $hashref;
129
130 $hashref=$switch->SetupValueHash( \@vars );
131 $switch->checkparam($hashref, $name, "name");
132 # now download the file
133 print "Downloading File .... $$hashref{'name'}\n";
134 &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
135 $scramdir."/".$$hashref{'name'}) ;
136 if ( $switch->context('project') ) {
137 print INSTALLFILE "<$name name=$$hashref{name}>\n";
138 }
139 }
140
141 sub reqs_start {
142 my $name=shift;
143 my @vars=@_;
144 my $hashref;
145
146 $hashref=$switch->SetupValueHash( \@vars );
147 $switch->checkparam($hashref, $name, "name");
148 use clientfile;
149 $ENV{SCRAM_ProjReqsDoc}=
150 $currentdir."/".$$hashref{'name'};
151 print ENVIRONMENT 'SCRAM_ProjReqsDoc='.$ENV{SCRAM_ProjReqsDoc}."\n";
152 # &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
153 # $scramdir."/".$$hashref{'name'}) ;
154 if ( $switch->context("project") ) {
155 print INSTALLFILE "<$name name=$$hashref{name}>\n";
156 }
157 }
158
159 sub base_start {
160 my $name=shift;
161 my @vars=@_;
162 my $hashref;
163
164 $hashref=$switch->SetupValueHash( \@vars );
165 $switch->checkparam($hashref, $name, 'urltype');
166 $switch->checkparam($hashref, $name, 'value');
167 push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'};
168 $lastbasekey=$$hashref{'urltype'};
169 #print $lastbasekey." lastbasekey \n";
170 }
171
172 sub base_end {
173 pop @{ $basehash{$lastbasekey} };
174 }
175
176 #sub checkparam($hash, $name, $key) {
177 # my $hashref=shift;
178 # my $name=shift;
179 # my $key=shift;
180 #
181 # if ( ! defined $$hashref{$key} ) {
182 # print "BootParser: Badly formed $name tag -".
183 # " undefined $key parameter\n";
184 # exit 1;
185 # }
186 # $$hashref{$key}=~s/["']//;
187 #}
188
189 #Just a file for now!
190 #Will eventually cross ref with access checker to get types available.
191 sub geturlbase {
192 return "file:".@{$basehash{'file'}}[$#{$basehash{'file'}}];
193 }
194
195
196 #
197 # Now deal with an already intalled release base
198 #
199
200 sub install_start {
201 my $name=shift;
202 my @vars=@_;
203 my $hashref;
204
205 $hashref=$switch->SetupValueHash( \@vars );
206 Bootlocaltop($hashref);
207
208 }
209
210 # Can use this to print out a project specific message
211 sub install {
212 my $name=shift;
213 my $vars=shift;
214
215 print @$vars;
216 }
217
218 sub install_finish {
219 my $name=shift;
220 my @vars=@_;
221 my $hashref;
222 }
223
224 sub cvsrep_start {
225 my $name=shift;
226 my @vars=@_;
227 my $hashref;
228
229 $hashref=$switch->SetupValueHash( \@vars );
230 $switch->checkparam($hashref, $name, 'auth' );
231 $switch->checkparam($hashref, $name, 'base' );
232 $cvsobject=cvsmodule->new();
233 $cvsobject->set_base($$hashref{base});
234 $cvsobject->set_auth($$hashref{auth});
235 if ( exists $$hashref{user} ) {
236 $cvsobject->set_user($$hashref{user});
237 }
238 if ( exists $$hashref{passkey} ) {
239 $cvsobject->set_passkey($$hashref{passkey});
240 }
241 }
242
243 sub cvsrep_end {
244 my $name=shift;
245 $cvsobject=undef; #Move out of scope to destroy cvsrep context
246 }
247
248 sub cvs_start {
249 my $name=shift;
250 my @vars=@_;
251 my $hashref;
252
253 if ( ! defined $cvsobject ) {
254 print "BootStraper: Undefined cvs repository on line ".
255 $switch->{linenumber}."\n - set up repository".
256 "specifics with the <cvsrep> flag\n";
257 exit 1;
258 }
259 $hashref=$switch->SetupValueHash( \@vars );
260 $switch->checkparam( $hashref, $name, "fn" );
261 $cvsobject->invokecvs( (split / /, $$hashref{fn} ) );
262 }