ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BootStrapProject.pm
(Generate patch)

Comparing COMP/SCRAM/src/BootStrapProject.pm (file contents):
Revision 1.2 by williamc, Mon Mar 1 11:01:41 1999 UTC vs.
Revision 1.9 by williamc, Tue Mar 30 13:44:00 1999 UTC

# Line 5 | Line 5 | package BootStrapProject;
5   require Exporter;
6   @ISA=qw(Exporter);
7   @EXPORT=qw(BootStrapProject);
8 + use Utilities::cvsmodule;
9  
10   sub BootStrapProject($) {
11          my $url=shift;  
# Line 15 | Line 16 | sub BootStrapProject($) {
16  
17          my $filename;
18          $BootHash={
19 +                '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                  'config_starttag' =>  \&config_starttag,
26 +                'config_endtag' =>  \&config_endtag,
27                  'config' => 'none',
28                  'base' => 'none',
29                  'base_starttag' => \&base_start,
# Line 31 | Line 39 | sub BootStrapProject($) {
39                  'file' => 'none',
40                  'file_starttag' => \&file_start
41          };
42 <         $filename=urlhandler($url);
42 >        $filename=urlhandler::urlhandler($url);
43          $switch=Switcher->new($BootHash, $filename);
44          $switch->parse();
45   }
46  
47 < sub Bootlocaltop($hashref) {
47 > sub Bootlocaltop {
48          my $hashref=shift;
49          use Cwd;
50          use Utilities::AddDir;
51  
52 <        checkparam($hashref, $name, "name");
53 <        checkparam($hashref, $name, "version");
52 >        $switch->checkparam($hashref, $name, "name");
53 >        $switch->checkparam($hashref, $name, "version");
54          $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$$hashref{'version'};
55          $scramdir=$ENV{LOCALTOP}."/.SCRAM";
56 <        &adddir($scramdir);
56 >        &AddDir::adddir($scramdir);
57 >        chdir $ENV{LOCALTOP};
58   }
59  
60   sub project_start {
# Line 55 | Line 64 | sub project_start {
64  
65          $hashref=$switch->SetupValueHash( \@vars );
66          Bootlocaltop($hashref);
67 +        print "Installing Project $$hashref{'name'} ".
68 +                "Version $$hashref{'version'}\n";
69          open ( ENVIRONMENT , ">$scramdir/Environment" ) || die "Unable to open ".
70                                  "Environment file : $!\n";
71          print ENVIRONMENT 'SCRAM_PROJECTNAME='.$$hashref{'name'}."\n";
# Line 65 | Line 76 | sub project_start {
76                  "version=$$hashref{version}>\n";
77          print INSTALLFILE "<base urltype=file value=$scramdir>\n";
78          print INSTALLFILE "<file name=Environment>\n";
79 +        push @{ $basehash{file}}, "$ENV{SCRAM_HOME}/toolbox";
80 +        $lastbasekey='file';
81 +        push @dirstack, $scramdir;
82 +        $currentdir=$scramdir;
83   }
84  
85   sub project_finish {
# Line 82 | Line 97 | sub config_starttag {
97          my $hashref;
98  
99          $hashref=$switch->SetupValueHash( \@vars );
100 <        checkparam($hashref, $name, "dir");
100 >        $switch->checkparam($hashref, $name, "dir");
101          print ENVIRONMENT 'projconfigdir='.$$hashref{'dir'}."\n";
102          $ENV{SCRAM_BootStrapFiles}=$ENV{SCRAM_BootStrapFiles}.":".
103                  $ENV{LOCALTOP}."/".$$hashref{'dir'};
104 +        push @dirstack, $ENV{LOCALTOP}."/".$$hashref{'dir'};
105 +        $currentdir=$ENV{LOCALTOP}."/".$$hashref{'dir'};
106 +        if ( $switch->context('project') ) {
107 +         print INSTALLFILE "<$name dir=$$hashref{dir}>\n";
108 +        }
109 + }
110 + sub config_endtag {
111 +        my $name=shift;
112 +
113 +        pop @dirstack;
114 +        $currentdir=$dirstack[$#dirstack];
115 +        if ( $switch->context('project') ) {
116 +         print INSTALLFILE "</$name>\n";
117 +        }
118   }
119  
120   sub file_start {
# Line 94 | Line 123 | sub file_start {
123          my $hashref;
124  
125          $hashref=$switch->SetupValueHash( \@vars );
126 <        checkparam($hashref, $name, "name");
126 >        $switch->checkparam($hashref, $name, "name");
127          # now download the file
128          print "Downloading File .... $$hashref{'name'}\n";
129 <        &urlhandler(&geturlbase."/".$$hashref{'name'},
129 >        &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
130                           $scramdir."/".$$hashref{'name'}) ;
131          if ( $switch->context('project') ) {
132           print INSTALLFILE "<$name name=$$hashref{name}>\n";
# Line 110 | Line 139 | sub reqs_start {
139          my $hashref;
140  
141          $hashref=$switch->SetupValueHash( \@vars );
142 <        checkparam($hashref, $name, "name");
142 >        $switch->checkparam($hashref, $name, "name");
143          use clientfile;
144          $ENV{SCRAM_ProjReqsDoc}=
145 <        &urlhandler(&geturlbase."/".$$hashref{'name'},
146 <                $scramdir."/".$$hashref{'name'}) ;
145 >          $currentdir."/".$$hashref{'name'};
146 >        print ENVIRONMENT 'SCRAM_ProjReqsDoc='.$ENV{SCRAM_ProjReqsDoc}."\n";
147 > #       &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
148 > #               $scramdir."/".$$hashref{'name'}) ;
149          if ( $switch->context("project") ) {
150           print INSTALLFILE "<$name name=$$hashref{name}>\n";
151          }
# Line 126 | Line 157 | sub base_start {
157          my $hashref;
158  
159          $hashref=$switch->SetupValueHash( \@vars );
160 <        checkparam($hashref, $name, 'urltype');
161 <        checkparam($hashref, $name, 'value');
160 >        $switch->checkparam($hashref, $name, 'urltype');
161 >        $switch->checkparam($hashref, $name, 'value');
162          push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'};
163          $lastbasekey=$$hashref{'urltype'};
164          #print $lastbasekey." lastbasekey \n";
# Line 137 | Line 168 | sub base_end {
168          pop @{ $basehash{$lastbasekey} };
169   }
170  
171 < 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 < }
171 > #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  
184   #Just a file for now!
185   #Will eventually cross ref with access checker to get types available.
# Line 184 | Line 215 | sub install_finish {
215          my @vars=@_;
216          my $hashref;
217   }
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 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines