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.10.2.2 by williamc, Mon Aug 30 14:14:58 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");
54 <        $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$$hashref{'version'};
52 >        $switch->checkparam($hashref, $name, "name");
53 >        $switch->checkparam($hashref, $name, "version");
54 >        if ( ! defined $ENV{devareaname} ) {
55 >         my $vers=$$hashref{'version'};
56 >         $vers=~s/^$$hashref{'name'}_//;
57 >        print $vers;
58 >         $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$vers;
59 >        }
60 >        else {
61 >         $ENV{LOCALTOP}=&cwd."/".$ENV{devareaname};
62 >        }
63          $scramdir=$ENV{LOCALTOP}."/.SCRAM";
64 <        &adddir($scramdir);
64 >        &AddDir::adddir($scramdir);
65 >        chdir $ENV{LOCALTOP};
66   }
67  
68   sub project_start {
# Line 55 | Line 72 | sub project_start {
72  
73          $hashref=$switch->SetupValueHash( \@vars );
74          Bootlocaltop($hashref);
75 +        print "Installing Project $$hashref{'name'} ".
76 +                "Version $$hashref{'version'}\n";
77          open ( ENVIRONMENT , ">$scramdir/Environment" ) || die "Unable to open ".
78                                  "Environment file : $!\n";
79          print ENVIRONMENT 'SCRAM_PROJECTNAME='.$$hashref{'name'}."\n";
# Line 65 | Line 84 | sub project_start {
84                  "version=$$hashref{version}>\n";
85          print INSTALLFILE "<base urltype=file value=$scramdir>\n";
86          print INSTALLFILE "<file name=Environment>\n";
87 +        push @{ $basehash{file}}, "$ENV{SCRAM_HOME}/toolbox";
88 +        $lastbasekey='file';
89 +        push @dirstack, $scramdir;
90 +        $currentdir=$scramdir;
91   }
92  
93   sub project_finish {
# Line 82 | Line 105 | sub config_starttag {
105          my $hashref;
106  
107          $hashref=$switch->SetupValueHash( \@vars );
108 <        checkparam($hashref, $name, "dir");
108 >        $switch->checkparam($hashref, $name, "dir");
109 >        $$hashref{'dir'}=~s/`//g;
110          print ENVIRONMENT 'projconfigdir='.$$hashref{'dir'}."\n";
111          $ENV{SCRAM_BootStrapFiles}=$ENV{SCRAM_BootStrapFiles}.":".
112                  $ENV{LOCALTOP}."/".$$hashref{'dir'};
113 +        push @dirstack, $ENV{LOCALTOP}."/".$$hashref{'dir'};
114 +        $currentdir=$ENV{LOCALTOP}."/".$$hashref{'dir'};
115 +        if ( $switch->context('project') ) {
116 +         print INSTALLFILE "<$name dir=$$hashref{dir}>\n";
117 +        }
118 + }
119 + sub config_endtag {
120 +        my $name=shift;
121 +
122 +        pop @dirstack;
123 +        $currentdir=$dirstack[$#dirstack];
124 +        if ( $switch->context('project') ) {
125 +         print INSTALLFILE "</$name>\n";
126 +        }
127   }
128  
129   sub file_start {
# Line 94 | Line 132 | sub file_start {
132          my $hashref;
133  
134          $hashref=$switch->SetupValueHash( \@vars );
135 <        checkparam($hashref, $name, "name");
135 >        $switch->checkparam($hashref, $name, "name");
136          # now download the file
137          print "Downloading File .... $$hashref{'name'}\n";
138 <        &urlhandler(&geturlbase."/".$$hashref{'name'},
138 >        &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
139                           $scramdir."/".$$hashref{'name'}) ;
140          if ( $switch->context('project') ) {
141           print INSTALLFILE "<$name name=$$hashref{name}>\n";
# Line 110 | Line 148 | sub reqs_start {
148          my $hashref;
149  
150          $hashref=$switch->SetupValueHash( \@vars );
151 <        checkparam($hashref, $name, "name");
151 >        $switch->checkparam($hashref, $name, "name");
152          use clientfile;
153          $ENV{SCRAM_ProjReqsDoc}=
154 <        &urlhandler(&geturlbase."/".$$hashref{'name'},
155 <                $scramdir."/".$$hashref{'name'}) ;
154 >          $currentdir."/".$$hashref{'name'};
155 >        print ENVIRONMENT 'SCRAM_ProjReqsDoc='.$ENV{SCRAM_ProjReqsDoc}."\n";
156 > #       &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
157 > #               $scramdir."/".$$hashref{'name'}) ;
158          if ( $switch->context("project") ) {
159           print INSTALLFILE "<$name name=$$hashref{name}>\n";
160          }
# Line 126 | Line 166 | sub base_start {
166          my $hashref;
167  
168          $hashref=$switch->SetupValueHash( \@vars );
169 <        checkparam($hashref, $name, 'urltype');
170 <        checkparam($hashref, $name, 'value');
169 >        $switch->checkparam($hashref, $name, 'urltype');
170 >        $switch->checkparam($hashref, $name, 'value');
171          push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'};
172          $lastbasekey=$$hashref{'urltype'};
173          #print $lastbasekey." lastbasekey \n";
# Line 137 | Line 177 | sub base_end {
177          pop @{ $basehash{$lastbasekey} };
178   }
179  
180 < 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 < }
180 > #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  
193   #Just a file for now!
194   #Will eventually cross ref with access checker to get types available.
# Line 184 | Line 224 | sub install_finish {
224          my @vars=@_;
225          my $hashref;
226   }
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 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines