ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.10.2.3
Committed: Mon Aug 30 14:15:34 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_12_2, V0_12_1, V0_12_0, V0_11_4, V0_11_3, V0_11_2, V0_11_1, V0_11_0, V0_10_19, V0_10_18, V0_10_17, V0_10_16, V0_10_15, V0_10_14, V0_10_13, V0_10_12, V0_10_11, V0_10_10, V0_10_9, V0_10_8, V0_10_7, V0_10_6, V0_10_5, V0_10_4, V0_10_3, V0_10_2, V0_10_1, V0_10_0, V0_10_0beta, V0_9_42, V0_9_41, V0_9_40, V0_9_39, V0_9_38, V0_9_37, V0_9_36, V0_9_35, V0_9_34, V0_9_33, V0_9_32, V0_9_31, V0_9_30, V0_9_29, V0_9_28, V0_9_27, V0_9_26, V0_9_25, V0_9_24, V0_9_23
Changes since 1.10.2.2: +0 -1 lines
Log Message:
Remove repetition of project name in name of Project directory

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