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