ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.10.2.4
Committed: Thu Apr 27 11:44:18 2000 UTC (25 years ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_14_0, V0_12_12_4, V0_12_12_3, V0_12_12_2, V0_12_12_1, V0_12_12_0, PlayGround_0, V0_12_12, V0_12_11, V0_12_9b, V0_12_10, V0_12_9, V0_12_8, V0_12_7, V0_12_6, V0_12_5, V0_12_4, V0_12_3
Branch point for: HPWbranch
Changes since 1.10.2.3: +0 -1 lines
Log Message:
Remove clientfile reference

File Contents

# User Rev Content
1 williamc 1.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 williamc 1.3 use Utilities::cvsmodule;
9 williamc 1.1
10     sub BootStrapProject($) {
11     my $url=shift;
12     # my $outputfile=shift;
13    
14 williamc 1.2 use Utilities::urlhandler;
15     use Utilities::Switcher;
16 williamc 1.1
17     my $filename;
18     $BootHash={
19 williamc 1.3 '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 williamc 1.1 'config_starttag' => \&config_starttag,
26 williamc 1.4 'config_endtag' => \&config_endtag,
27 williamc 1.1 '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 williamc 1.6 $filename=urlhandler::urlhandler($url);
43 williamc 1.1 $switch=Switcher->new($BootHash, $filename);
44     $switch->parse();
45     }
46    
47 williamc 1.6 sub Bootlocaltop {
48 williamc 1.1 my $hashref=shift;
49     use Cwd;
50 williamc 1.2 use Utilities::AddDir;
51 williamc 1.1
52 williamc 1.3 $switch->checkparam($hashref, $name, "name");
53     $switch->checkparam($hashref, $name, "version");
54 williamc 1.10 if ( ! defined $ENV{devareaname} ) {
55 williamc 1.10.2.2 my $vers=$$hashref{'version'};
56     $vers=~s/^$$hashref{'name'}_//;
57     $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$vers;
58 williamc 1.10 }
59     else {
60     $ENV{LOCALTOP}=&cwd."/".$ENV{devareaname};
61     }
62 williamc 1.1 $scramdir=$ENV{LOCALTOP}."/.SCRAM";
63 williamc 1.3 &AddDir::adddir($scramdir);
64 williamc 1.4 chdir $ENV{LOCALTOP};
65 williamc 1.1 }
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 williamc 1.8 print "Installing Project $$hashref{'name'} ".
75     "Version $$hashref{'version'}\n";
76 williamc 1.1 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 williamc 1.4 push @{ $basehash{file}}, "$ENV{SCRAM_HOME}/toolbox";
87     $lastbasekey='file';
88     push @dirstack, $scramdir;
89     $currentdir=$scramdir;
90 williamc 1.1 }
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 williamc 1.3 $switch->checkparam($hashref, $name, "dir");
108 williamc 1.10.2.1 $$hashref{'dir'}=~s/`//g;
109 williamc 1.1 print ENVIRONMENT 'projconfigdir='.$$hashref{'dir'}."\n";
110     $ENV{SCRAM_BootStrapFiles}=$ENV{SCRAM_BootStrapFiles}.":".
111     $ENV{LOCALTOP}."/".$$hashref{'dir'};
112 williamc 1.4 push @dirstack, $ENV{LOCALTOP}."/".$$hashref{'dir'};
113     $currentdir=$ENV{LOCALTOP}."/".$$hashref{'dir'};
114 williamc 1.5 if ( $switch->context('project') ) {
115 williamc 1.7 print INSTALLFILE "<$name dir=$$hashref{dir}>\n";
116 williamc 1.5 }
117 williamc 1.4 }
118     sub config_endtag {
119 williamc 1.5 my $name=shift;
120    
121 williamc 1.4 pop @dirstack;
122     $currentdir=$dirstack[$#dirstack];
123 williamc 1.5 if ( $switch->context('project') ) {
124     print INSTALLFILE "</$name>\n";
125     }
126 williamc 1.1 }
127    
128     sub file_start {
129     my $name=shift;
130     my @vars=@_;
131     my $hashref;
132    
133     $hashref=$switch->SetupValueHash( \@vars );
134 williamc 1.3 $switch->checkparam($hashref, $name, "name");
135 williamc 1.1 # now download the file
136     print "Downloading File .... $$hashref{'name'}\n";
137 williamc 1.3 &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
138 williamc 1.1 $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 williamc 1.3 $switch->checkparam($hashref, $name, "name");
151 williamc 1.1 $ENV{SCRAM_ProjReqsDoc}=
152 williamc 1.4 $currentdir."/".$$hashref{'name'};
153 williamc 1.9 print ENVIRONMENT 'SCRAM_ProjReqsDoc='.$ENV{SCRAM_ProjReqsDoc}."\n";
154 williamc 1.4 # &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
155     # $scramdir."/".$$hashref{'name'}) ;
156 williamc 1.1 if ( $switch->context("project") ) {
157     print INSTALLFILE "<$name name=$$hashref{name}>\n";
158     }
159     }
160    
161     sub base_start {
162     my $name=shift;
163     my @vars=@_;
164     my $hashref;
165    
166     $hashref=$switch->SetupValueHash( \@vars );
167 williamc 1.3 $switch->checkparam($hashref, $name, 'urltype');
168     $switch->checkparam($hashref, $name, 'value');
169 williamc 1.1 push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'};
170     $lastbasekey=$$hashref{'urltype'};
171     #print $lastbasekey." lastbasekey \n";
172     }
173    
174     sub base_end {
175     pop @{ $basehash{$lastbasekey} };
176     }
177    
178 williamc 1.3 #sub checkparam($hash, $name, $key) {
179     # my $hashref=shift;
180     # my $name=shift;
181     # my $key=shift;
182     #
183     # if ( ! defined $$hashref{$key} ) {
184     # print "BootParser: Badly formed $name tag -".
185     # " undefined $key parameter\n";
186     # exit 1;
187     # }
188     # $$hashref{$key}=~s/["']//;
189     #}
190 williamc 1.1
191     #Just a file for now!
192     #Will eventually cross ref with access checker to get types available.
193     sub geturlbase {
194     return "file:".@{$basehash{'file'}}[$#{$basehash{'file'}}];
195     }
196    
197    
198     #
199     # Now deal with an already intalled release base
200     #
201    
202     sub install_start {
203     my $name=shift;
204     my @vars=@_;
205     my $hashref;
206    
207     $hashref=$switch->SetupValueHash( \@vars );
208     Bootlocaltop($hashref);
209    
210     }
211    
212     # Can use this to print out a project specific message
213     sub install {
214     my $name=shift;
215     my $vars=shift;
216    
217     print @$vars;
218     }
219    
220     sub install_finish {
221     my $name=shift;
222     my @vars=@_;
223     my $hashref;
224 williamc 1.3 }
225    
226     sub cvsrep_start {
227     my $name=shift;
228     my @vars=@_;
229     my $hashref;
230    
231     $hashref=$switch->SetupValueHash( \@vars );
232     $switch->checkparam($hashref, $name, 'auth' );
233     $switch->checkparam($hashref, $name, 'base' );
234     $cvsobject=cvsmodule->new();
235     $cvsobject->set_base($$hashref{base});
236     $cvsobject->set_auth($$hashref{auth});
237     if ( exists $$hashref{user} ) {
238     $cvsobject->set_user($$hashref{user});
239     }
240     if ( exists $$hashref{passkey} ) {
241     $cvsobject->set_passkey($$hashref{passkey});
242     }
243     }
244    
245     sub cvsrep_end {
246     my $name=shift;
247     $cvsobject=undef; #Move out of scope to destroy cvsrep context
248     }
249    
250     sub cvs_start {
251     my $name=shift;
252     my @vars=@_;
253     my $hashref;
254    
255     if ( ! defined $cvsobject ) {
256     print "BootStraper: Undefined cvs repository on line ".
257     $switch->{linenumber}."\n - set up repository".
258     "specifics with the <cvsrep> flag\n";
259     exit 1;
260     }
261     $hashref=$switch->SetupValueHash( \@vars );
262     $switch->checkparam( $hashref, $name, "fn" );
263     $cvsobject->invokecvs( (split / /, $$hashref{fn} ) );
264 williamc 1.1 }