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.1 by williamc, Mon Mar 1 10:37:52 1999 UTC vs.
Revision 1.10.2.5 by williamc, Wed Jun 14 16:42:20 2000 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;  
12   #       my $outputfile=shift;
13  
14 <        use urlhandler;
15 <        use Switcher;
14 >        use Utilities::urlhandler;
15 >        use Utilities::Switcher;
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 AddDir;
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 >         $ENV{LOCALTOP}=&cwd."/".$$hashref{'name'}."_".$vers;
58 >        }
59 >        else {
60 >         $ENV{LOCALTOP}=&cwd."/".$ENV{devareaname};
61 >        }
62          $scramdir=$ENV{LOCALTOP}."/.SCRAM";
63 <        &adddir($scramdir);
63 >        &AddDir::adddir($scramdir);
64 >        chdir $ENV{LOCALTOP};
65   }
66  
67   sub project_start {
# Line 55 | Line 71 | sub project_start {
71  
72          $hashref=$switch->SetupValueHash( \@vars );
73          Bootlocaltop($hashref);
74 +        print "Installing Project $$hashref{'name'} ".
75 +                "Version $$hashref{'version'}\n";
76          open ( ENVIRONMENT , ">$scramdir/Environment" ) || die "Unable to open ".
77                                  "Environment file : $!\n";
78          print ENVIRONMENT 'SCRAM_PROJECTNAME='.$$hashref{'name'}."\n";
# Line 65 | Line 83 | sub project_start {
83                  "version=$$hashref{version}>\n";
84          print INSTALLFILE "<base urltype=file value=$scramdir>\n";
85          print INSTALLFILE "<file name=Environment>\n";
86 +        push @{ $basehash{file}}, "$ENV{SCRAM_HOME}/toolbox";
87 +        $lastbasekey='file';
88 +        push @dirstack, $scramdir;
89 +        $currentdir=$scramdir;
90   }
91  
92   sub project_finish {
# Line 82 | Line 104 | sub config_starttag {
104          my $hashref;
105  
106          $hashref=$switch->SetupValueHash( \@vars );
107 <        checkparam($hashref, $name, "dir");
107 >        $switch->checkparam($hashref, $name, "dir");
108 >        $$hashref{'dir'}=~s/`//g;
109          print ENVIRONMENT 'projconfigdir='.$$hashref{'dir'}."\n";
110          $ENV{SCRAM_BootStrapFiles}=$ENV{SCRAM_BootStrapFiles}.":".
111                  $ENV{LOCALTOP}."/".$$hashref{'dir'};
112 +        push @dirstack, $ENV{LOCALTOP}."/".$$hashref{'dir'};
113 +        $currentdir=$ENV{LOCALTOP}."/".$$hashref{'dir'};
114 +        if ( $switch->context('project') ) {
115 +         print INSTALLFILE "<$name dir=$$hashref{dir}>\n";
116 +        }
117 + }
118 + sub config_endtag {
119 +        my $name=shift;
120 +
121 +        pop @dirstack;
122 +        $currentdir=$dirstack[$#dirstack];
123 +        if ( $switch->context('project') ) {
124 +         print INSTALLFILE "</$name>\n";
125 +        }
126   }
127  
128   sub file_start {
# Line 94 | Line 131 | sub file_start {
131          my $hashref;
132  
133          $hashref=$switch->SetupValueHash( \@vars );
134 <        checkparam($hashref, $name, "name");
134 >        $switch->checkparam($hashref, $name, "name");
135          # now download the file
136          print "Downloading File .... $$hashref{'name'}\n";
137 <        &urlhandler(&geturlbase."/".$$hashref{'name'},
137 >        &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
138                           $scramdir."/".$$hashref{'name'}) ;
139          if ( $switch->context('project') ) {
140           print INSTALLFILE "<$name name=$$hashref{name}>\n";
# Line 110 | Line 147 | sub reqs_start {
147          my $hashref;
148  
149          $hashref=$switch->SetupValueHash( \@vars );
150 <        checkparam($hashref, $name, "name");
151 <        use clientfile;
152 <        $ENV{SCRAM_ProjReqsDoc}=
153 <        &urlhandler(&geturlbase."/".$$hashref{'name'},
154 <                $scramdir."/".$$hashref{'name'}) ;
150 >        $switch->checkparam($hashref, $name, "name");
151 >        $ENV{SCRAM_ProjReqsDoc}=$$hashref{'name'};
152 >        print ENVIRONMENT 'SCRAM_ProjReqsDoc='.$ENV{SCRAM_ProjReqsDoc}."\n";
153 > #       &urlhandler::urlhandler(&geturlbase."/".$$hashref{'name'},
154 > #               $scramdir."/".$$hashref{'name'}) ;
155          if ( $switch->context("project") ) {
156           print INSTALLFILE "<$name name=$$hashref{name}>\n";
157          }
# Line 126 | Line 163 | sub base_start {
163          my $hashref;
164  
165          $hashref=$switch->SetupValueHash( \@vars );
166 <        checkparam($hashref, $name, 'urltype');
167 <        checkparam($hashref, $name, 'value');
166 >        $switch->checkparam($hashref, $name, 'urltype');
167 >        $switch->checkparam($hashref, $name, 'value');
168          push @{ $basehash{ $$hashref{'urltype'} }}, $$hashref{'value'};
169          $lastbasekey=$$hashref{'urltype'};
170          #print $lastbasekey." lastbasekey \n";
# Line 137 | Line 174 | sub base_end {
174          pop @{ $basehash{$lastbasekey} };
175   }
176  
177 < 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 < }
177 > #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  
190   #Just a file for now!
191   #Will eventually cross ref with access checker to get types available.
# Line 184 | Line 221 | sub install_finish {
221          my @vars=@_;
222          my $hashref;
223   }
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 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines