ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
Revision: 1.9
Committed: Tue Mar 30 13:44:00 1999 UTC (26 years, 1 month ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_8, V0_7, V0_6, V0_5
Changes since 1.8: +1 -0 lines
Log Message:
Add scram setup installation functionality

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