ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.5
Committed: Mon Mar 8 11:02:39 1999 UTC (26 years, 2 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.4: +8 -7 lines
Log Message:
Move config dir copy to scram as environment npt defined in BootStrap

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($hashref) {
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 $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$$hashref{'version'};
55 $scramdir=$ENV{LOCALTOP}."/.SCRAM";
56 &AddDir::adddir($scramdir);
57 chdir $ENV{LOCALTOP};
58 }
59
60 sub project_start {
61 my $name=shift;
62 my @vars=@_;
63 my $hashref;
64
65 $hashref=$switch->SetupValueHash( \@vars );
66 Bootlocaltop($hashref);
67 open ( ENVIRONMENT , ">$scramdir/Environment" ) || die "Unable to open ".
68 "Environment file : $!\n";
69 print ENVIRONMENT 'SCRAM_PROJECTNAME='.$$hashref{'name'}."\n";
70 print ENVIRONMENT 'SCRAM_PROJVERSION='.$$hashref{'version'}."\n";
71 $ENV{SCRAM_BootStrapFiles}=$scramdir;
72 open INSTALLFILE, ">$scramdir/InstallFile";
73 print INSTALLFILE "<install name=$$hashref{name} ".
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 {
84 print ENVIRONMENT "SCRAM_BootStrapFiles=".$ENV{SCRAM_BootStrapFiles}."\n";
85 print ENVIRONMENT "RELEASETOP=$ENV{LOCALTOP}\n";
86 close ENVIRONMENT;
87 print INSTALLFILE "</install>\n";
88 close INSTALLFILE
89 }
90
91 # Set where the project specific configuration files live for the project
92 sub config_starttag {
93 my $name=shift;
94 my @vars=@_;
95 my $hashref;
96
97 $hashref=$switch->SetupValueHash( \@vars );
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 {
119 my $name=shift;
120 my @vars=@_;
121 my $hashref;
122
123 $hashref=$switch->SetupValueHash( \@vars );
124 $switch->checkparam($hashref, $name, "name");
125 # now download the file
126 print "Downloading File .... $$hashref{'name'}\n";
127 &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
128 $scramdir."/".$$hashref{'name'}) ;
129 if ( $switch->context('project') ) {
130 print INSTALLFILE "<$name name=$$hashref{name}>\n";
131 }
132 }
133
134 sub reqs_start {
135 my $name=shift;
136 my @vars=@_;
137 my $hashref;
138
139 $hashref=$switch->SetupValueHash( \@vars );
140 $switch->checkparam($hashref, $name, "name");
141 use clientfile;
142 $ENV{SCRAM_ProjReqsDoc}=
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 }
149 }
150
151 sub base_start {
152 my $name=shift;
153 my @vars=@_;
154 my $hashref;
155
156 $hashref=$switch->SetupValueHash( \@vars );
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";
162 }
163
164 sub base_end {
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 #}
180
181 #Just a file for now!
182 #Will eventually cross ref with access checker to get types available.
183 sub geturlbase {
184 return "file:".@{$basehash{'file'}}[$#{$basehash{'file'}}];
185 }
186
187
188 #
189 # Now deal with an already intalled release base
190 #
191
192 sub install_start {
193 my $name=shift;
194 my @vars=@_;
195 my $hashref;
196
197 $hashref=$switch->SetupValueHash( \@vars );
198 Bootlocaltop($hashref);
199
200 }
201
202 # Can use this to print out a project specific message
203 sub install {
204 my $name=shift;
205 my $vars=shift;
206
207 print @$vars;
208 }
209
210 sub install_finish {
211 my $name=shift;
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 }