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

# 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     # &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
147     # $scramdir."/".$$hashref{'name'}) ;
148 williamc 1.1 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 williamc 1.3 $switch->checkparam($hashref, $name, 'urltype');
160     $switch->checkparam($hashref, $name, 'value');
161 williamc 1.1 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 williamc 1.3 #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 williamc 1.1
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 williamc 1.3 }
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 williamc 1.1 }