ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.8
Committed: Tue Mar 23 13:49:16 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_4, V0_3, V0_2, V0_1
Changes since 1.7: +2 -0 lines
Log Message:
Print project and version at start of new project tag

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