ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/BootStrapProject.pm
Revision: 1.2
Committed: Mon Aug 28 08:35:13 2000 UTC (24 years, 8 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_19_0, V0_18_5, V0_18_4, V_18_3_TEST, VO_18_3, V0_18_2, V0_18_1
Changes since 1.1: +156 -0 lines
Log Message:
remove Interface.pm

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,"base", \&Base_start, $self);
37     $switch->addtag($parse,"RequirementsDoc", \&ReqDoc_start, $self,
38     \&print_text, $self,
39     \&ReqDoc_end, $self);
40     $switch->addtag($parse,"config", \&Config_start, $self,
41     "", $self,
42     "", $self);
43     $switch->addtag($parse,"project", \&Project_start, $self,
44     \&print_text, $self,
45     \&Project_end, $self);
46     $switch->addtag($parse,"download", \&GetToTop_start, $self,
47     \&print_text, $self,
48     "", $self);
49     $self->{switch}=$switch;
50     }
51    
52     sub boot {
53     my $self=shift;
54     my $url=shift;
55    
56     # -- override directory name
57     if ( @_ ) {
58     $self->{devareaname}=shift;
59     }
60     else {
61     $self->{devareaname}="";
62     }
63    
64     # -- initialise file parser
65     $self->_initswitcher();
66     my ($fullurl,$filename)=$self->{switch}->urldownload($url);
67     $self->{switch}->filetoparse($filename);
68    
69     # -- document version check
70     my ($doctype,$docversion)=$self->{switch}->doctype();
71     if ( ( $doctype ne $self->{mydoctype}) &&
72     ( $docversion ne $self->{mydocversion}) ) {
73     $self->{switch}->parseerror("Can Only process documents of type ".
74     $self->{mydoctype}." version ".$self->{mydocversion}.
75     "\nAre you sure you are using the correct scram version?");
76     }
77    
78     #my ($fullurl,$filename)=$self->{switch}->urlget($url);
79     #$self->{switch}->filetoparse($filename);
80     $self->{switch}->parse("boot");
81     return $self->{area};
82     }
83    
84     # --- Tag Routines
85    
86     sub print_text {
87     my $self=shift;
88     my $name=shift;
89     my @text=shift;
90    
91     print "@text\n";
92     }
93    
94     sub Project_start {
95     my $self=shift;
96     my $name=shift;
97     my $hashref=shift;
98    
99     $self->{switch}->checktag($name, $hashref, 'name');
100     $self->{switch}->checktag($name, $hashref, 'version');
101     print "Installing Project $$hashref{'name'} ".
102     "Version $$hashref{'version'}\n";
103     $self->{area}=Configuration::ConfigArea->new();
104     $self->{area}->name($$hashref{'name'});
105     $self->{area}->version($$hashref{'version'});
106     $self->{area}->setup($self->{baselocation});
107    
108     # new urlhandler based on area cache
109     $self->{switch}->cache($self->{area}->cache());
110     }
111    
112     sub Project_end {
113     my $self=shift;
114     $self->{area}->save();
115     }
116    
117     # Set where the project specific configuration files live for the project
118     sub Config_start {
119     my $self=shift;
120     my $name=shift;
121     my $hashref=shift;
122    
123     $self->{switch}->checktag($name, $hashref, "dir");
124     $$hashref{'dir'}=~s/`//g;
125     $self->{area}->configurationdir($$hashref{'dir'});
126     }
127    
128     sub ReqDoc_start {
129     my $self=shift;
130     my $name=shift;
131     my $hashref=shift;
132    
133     my ($filename,$fullurl);
134     if ( exists $$hashref{'url'} ) {
135     # -- download into our cache
136     ($fullurl,$filename)=$self->{switch}->urlget($$hashref{'url'});
137     }
138     else {
139     $self->{switch}->checktag($name, $hashref, "name");
140     $filename=$$hashref{'name'};
141     }
142     $self->{area}->requirementsdoc($filename);
143     }
144    
145     sub GetToTop_start {
146     my $self=shift;
147     my $name=shift;
148     my $hashref=shift;
149    
150     $self->{switch}->checktag($name, $hashref, "url");
151     $self->{switch}->checktag($name, $hashref, "name");
152    
153     # -- download into top directory
154     my ($fullurl,$filename)=$self->{switch}->urlget($$hashref{'url'},
155     $self->{area}->location()."/".$$hashref{'name'});
156     }