ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/BootStrapProject.pm
Revision: 1.3
Committed: Mon Dec 3 19:02:05 2001 UTC (23 years, 5 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: V0_19_6, V0_19_6p1, V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1
Branch point for: V0_19_4_B
Changes since 1.2: +0 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 williamc 1.2 # Bootstrap file parser
2     #
3     # Interface
4     # ---------
5     # new(cache,installbase) : a new bootstrapper
6     # boot(url[,devareaname]) : boot up a new project , return the ConfigArea
7    
8     package Configuration::BootStrapProject;
9     use ActiveDoc::SimpleURLDoc;
10     use URL::URLhandler;
11     use Utilities::Verbose;
12     require 5.004;
13    
14     @ISA=qw(Utilities::Verbose);
15    
16    
17     sub new {
18     my $class=shift;
19     my $self={};
20     bless $self, $class;
21     $self->{cache}=shift;
22     $self->{baselocation}=shift;
23     $self->{mydoctype}="Configuration::BootStrapProject";
24     $self->{mydocversion}="1.0";
25     $self->{Arch}=1;
26     push @{$self->{ARCHBLOCK}}, $self->{Arch};
27     return $self;
28     }
29    
30     sub _initswitcher {
31     my $self=shift;
32     my $switch=ActiveDoc::SimpleURLDoc->new($self->{cache});
33     my $parse="boot";
34     $switch->newparse($parse);
35     $switch->addbasetags($parse);
36     $switch->addtag($parse,"RequirementsDoc", \&ReqDoc_start, $self,
37     \&print_text, $self,
38     \&ReqDoc_end, $self);
39     $switch->addtag($parse,"config", \&Config_start, $self,
40     "", $self,
41     "", $self);
42     $switch->addtag($parse,"project", \&Project_start, $self,
43     \&print_text, $self,
44     \&Project_end, $self);
45     $switch->addtag($parse,"download", \&GetToTop_start, $self,
46     \&print_text, $self,
47     "", $self);
48     $self->{switch}=$switch;
49     }
50    
51     sub boot {
52     my $self=shift;
53     my $url=shift;
54    
55     # -- override directory name
56     if ( @_ ) {
57     $self->{devareaname}=shift;
58     }
59     else {
60     $self->{devareaname}="";
61     }
62    
63     # -- initialise file parser
64     $self->_initswitcher();
65     my ($fullurl,$filename)=$self->{switch}->urldownload($url);
66     $self->{switch}->filetoparse($filename);
67    
68     # -- document version check
69     my ($doctype,$docversion)=$self->{switch}->doctype();
70     if ( ( $doctype ne $self->{mydoctype}) &&
71     ( $docversion ne $self->{mydocversion}) ) {
72     $self->{switch}->parseerror("Can Only process documents of type ".
73     $self->{mydoctype}." version ".$self->{mydocversion}.
74     "\nAre you sure you are using the correct scram version?");
75     }
76    
77     $self->{switch}->parse("boot");
78     return $self->{area};
79     }
80    
81     # --- Tag Routines
82    
83     sub print_text {
84     my $self=shift;
85     my $name=shift;
86     my @text=shift;
87    
88     print "@text\n";
89     }
90    
91     sub Project_start {
92     my $self=shift;
93     my $name=shift;
94     my $hashref=shift;
95    
96     $self->{switch}->checktag($name, $hashref, 'name');
97     $self->{switch}->checktag($name, $hashref, 'version');
98     print "Installing Project $$hashref{'name'} ".
99     "Version $$hashref{'version'}\n";
100     $self->{area}=Configuration::ConfigArea->new();
101     $self->{area}->name($$hashref{'name'});
102     $self->{area}->version($$hashref{'version'});
103     $self->{area}->setup($self->{baselocation});
104    
105     # new urlhandler based on area cache
106     $self->{switch}->cache($self->{area}->cache());
107     }
108    
109     sub Project_end {
110     my $self=shift;
111     $self->{area}->save();
112     }
113    
114     # Set where the project specific configuration files live for the project
115     sub Config_start {
116     my $self=shift;
117     my $name=shift;
118     my $hashref=shift;
119    
120     $self->{switch}->checktag($name, $hashref, "dir");
121     $$hashref{'dir'}=~s/`//g;
122     $self->{area}->configurationdir($$hashref{'dir'});
123     }
124    
125     sub ReqDoc_start {
126     my $self=shift;
127     my $name=shift;
128     my $hashref=shift;
129    
130     my ($filename,$fullurl);
131     if ( exists $$hashref{'url'} ) {
132     # -- download into our cache
133     ($fullurl,$filename)=$self->{switch}->urlget($$hashref{'url'});
134     }
135     else {
136     $self->{switch}->checktag($name, $hashref, "name");
137     $filename=$$hashref{'name'};
138     }
139     $self->{area}->requirementsdoc($filename);
140     }
141    
142     sub GetToTop_start {
143     my $self=shift;
144     my $name=shift;
145     my $hashref=shift;
146    
147     $self->{switch}->checktag($name, $hashref, "url");
148     $self->{switch}->checktag($name, $hashref, "name");
149    
150     # -- download into top directory
151     my ($fullurl,$filename)=$self->{switch}->urlget($$hashref{'url'},
152     $self->{area}->location()."/".$$hashref{'name'});
153     }