ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.10.2.2
Committed: Mon Aug 30 14:14:58 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
Changes since 1.10.2.1: +4 -1 lines
Log Message:
Remove repetition of project name in name of Project directory

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