ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Requirements.pm
Revision: 1.1.2.4.2.9
Committed: Mon Aug 28 06:54:52 2000 UTC (24 years, 8 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
CVS Tags: BuildSystemProto1, V0_18_0, V0_18_0model, V0_17_1, V0_18_0alpha, V0_17_0, V0_16_4, V0_16_3, V0_16_2, V0_16_1, V0_16_0, V0_15_1, V0_15_0, V0_15_0beta
Branch point for: V0_17branch, V0_16branch, V0_15branch
Changes since 1.1.2.4.2.8: +108 -14 lines
Log Message:
Add informational tag processing

File Contents

# Content
1 # Requirements Doc - just to get ordering info
2 #
3 # Interface
4 # ---------
5 # new(ActiveStore,url[,arch]) : new requirements doc
6 # setup(toolbox): set up the requirements into the specified toolbox object
7 # download(toolbox) : download description files (into toolbox cache)
8 # tools() : Return list of ALL requirements (ordered)
9 # selectedtools() : Return list of only those tools selected
10 # version(tool) : return the version of a given tool
11 # toolurl(tool) : return the url of a given tool
12 # getreqforarch(arch) : Return a RequirementsObject corresponding to the
13 # specified architecture
14 # toolcomment(tool,version) : return the comment string for the specified tool
15 # distributionurl(tool,version) : return the dist info url for the tool
16
17 package BuildSystem::Requirements;
18 use ActiveDoc::ActiveDoc;
19 use Utilities::Verbose;
20
21 require 5.004;
22 @ISA=qw(Utilities::Verbose);
23
24 sub new {
25 my $class=shift;
26 my $self={};
27 bless $self, $class;
28 $self->{dbstore}=shift;
29 $self->{file}=shift;
30 $self->{cache}=$self->{dbstore}->cache();
31 if ( @_ ) {
32 $self->arch(shift);
33 }
34 $self->{mydocversion}="2.0";
35 $self->{Arch}=1;
36 push @{$self->{ARCHBLOCK}}, $self->{Arch};
37 $self->init($self->{file});
38 return $self;
39 }
40
41 sub url {
42 my $self=shift;
43 if ( @_ ) {
44 $self->{file}=shift;
45 }
46 return $self->{file}
47 }
48
49 sub setup {
50 my $self=shift;
51 my $toolbox=shift;
52
53 my $tool;
54 foreach $tool ( $self->selectedtools() ) {
55 $self->verbose("Setting Up Tool $tool");
56 $toolbox->toolsetup($tool, $self->version($tool), $self->toolurl($tool));
57 }
58 }
59
60 sub tools {
61 my $self=shift;
62 return @{$self->{tools}};
63 }
64
65 sub selectedtools {
66 my $self=shift;
67 my @toollist=();
68 foreach $tool ( @{$self->{tools}} ) {
69 if ( $self->{selected}{$tool} == 1 ) {
70 push @toollist, $tool;
71 }
72 }
73 return @toollist;
74 }
75
76 sub toolcomment {
77 my $self=shift;
78 my $tool=shift;
79 my $version=shift;
80
81 return $self->{reqtext}{$tool}{$version};
82 }
83
84 sub distributionurl {
85 my $self=shift;
86 my $tool=shift;
87 my $version=shift;
88
89 return ( defined $self->{dist}{$tool}{$version})?
90 $self->{dist}{$tool}{$version}:undef;
91 }
92
93 sub version {
94 my $self=shift;
95 my $tool=shift;
96 return $self->{'version'}{$tool};
97 }
98
99 sub toolurl {
100 my $self=shift;
101 my $tool=shift;
102 return $self->{'url'}{$tool};
103 }
104
105 sub init {
106 my $self=shift;
107 my $url=shift;
108
109 my $switch=ActiveDoc::ActiveDoc->new($self->{dbstore});
110 $switch->verbosity($self->verbosity());
111 $switch->url($url);
112 $switch->newparse("ordering");
113 $switch->addbasetags("ordering");
114 $switch->addtag("ordering","Architecture",
115 \&Arch_Start,$self,
116 "", $self,
117 \&Arch_End, $self);
118 $switch->addtag("ordering","Restrict",
119 \&Restrict_start,$self,
120 "", $self,
121 \&Restrict_end, $self);
122 $switch->addtag("ordering","deselect",
123 \&deselect_start,$self,
124 "", $self,
125 "", $self);
126 $switch->addtag("ordering","select",
127 \&select_start,$self,
128 "", $self,
129 "", $self);
130 $switch->addtag("ordering","distribution",
131 \&disttag,$self);
132 $switch->grouptag("Architecture","ordering");
133 $switch->addtag("ordering","require",
134 \&require_start,$self,
135 \&require_text, $self,
136 \&require_end, $self);
137
138 $self->{reqcontext}=0;
139 $self->{switch}=$switch;
140 undef $self->{restrictstack};
141 @{$self->{tools}}=();
142
143 my($doctype,$docversion)=$switch->doctype();
144 # -- for backwards compatability only parse if we have a docversion
145 # defined
146 if ( defined $docversion ) {
147 if ( $docversion eq $self->{mydocversion} ) {
148 @{$self->{ArchStack}}=();
149 $self->{switch}->parse("ordering");
150 }
151 }
152 else {
153 #print "wrong doc version - not parsing\n";
154 }
155 }
156
157 sub arch {
158 my $self=shift;
159 if ( @_ ) {
160 $self->{arch}=shift
161 }
162 else {
163 if ( ! defined $self->{arch} ) {
164 $self->{arch}="";
165 }
166 }
167 return $self->{arch};
168 }
169
170 sub archlist {
171 my $self=shift;
172 return @{$self->{ArchStack}};
173 }
174
175 sub getreqforarch {
176 my $self=shift;
177 my $arch=shift;
178
179 if ( ! defined $self->{reqsforarch}{$arch} ) {
180 $self->{reqsforarch}{$arch}=
181 BuildSystem::Requirements->new($self->{dbstore},$self->{file},
182 $arch);
183 }
184 return $self->{reqsforarch}{$arch};
185 }
186
187
188 sub download {
189 my $self=shift;
190
191 my $tool;
192 foreach $tool ( $self->tools() ) {
193 $self->verbose("Downloading ".$self->toolurl($tool));
194 # get into the cache
195 $self->{switch}->urlget($self->toolurl($tool));
196 }
197 }
198
199 sub _autoselect {
200 my $self=shift;
201 if ( @_ ) {
202 $self->{autoselect}=shift;
203 }
204 # -- default is true
205 return ((defined $self->{autoselect})?$self->{autoselect}:1);
206 }
207
208 # ---- Tag routines
209
210 sub Restrict_start {
211 my $self=shift;
212 my $name=shift;
213 my $hashref=shift;
214
215 $self->{switch}->checktag( $name, $hashref, 'autoselect');
216 if ( $self->{Arch} ) {
217 # -- create selection state stack
218 push @{$self->{restrictstack}}, $self->_autoselect();
219 $self->_autoselect(
220 (($$hashref{'autoselect'}=~/true/i)?1:0));
221 }
222 }
223
224 sub Restrict_end {
225 my $self=shift;
226 my $name=shift;
227
228 if ( $self->{Arch} ) {
229 if ( $#{$self->{restrictstack}} >= 0 ) {
230 $self->_autoselect(pop @{$self->{restrictstack}});
231 }
232 else {
233 $self->{switch}->parseerror("Unmatched </$name>");
234 }
235 }
236 }
237
238 sub require_start {
239 my $self=shift;
240 my $name=shift;
241 my $hashref=shift;
242
243 $self->{switch}->checktag( $name, $hashref, 'version');
244 $self->{switch}->checktag( $name, $hashref, 'name');
245 $self->{switch}->checktag( $name, $hashref, 'url');
246
247 if ( $self->{reqcontext} == 1 ) {
248 $self->{switch}->parseerror(
249 "Open new $name conext without previous </$name>");
250 }
251 $self->{reqcontext}=1;
252 $$hashref{'name'}=~tr[A-Z][a-z];
253 push @{$self->{tools}}, $$hashref{'name'};
254 $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
255 # -- make sure the full url is taken
256 my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
257 $self->{url}{$$hashref{'name'}}=$urlobj->url();
258
259 # -- selection
260 if ( $self->{Arch} ) {
261 if ( $self->_autoselect() ) {
262 $self->{selected}{$$hashref{'name'}}=1;
263 }
264 else {
265 $self->{selected}{$$hashref{'name'}}=0;
266 }
267 }
268 $self->{creqtool}=$$hashref{'name'};
269 $self->{creqversion}=$$hashref{'version'};
270 $self->{reqtext}{$self->{creqtool}}{$self->{creqversion}}="";
271 }
272
273 sub require_text {
274 my $self=shift;
275 my $name=shift;
276 my $string=shift;
277
278 chomp $string;
279 $self->{reqtext}{$self->{creqtool}}{$self->{creqversion}}=
280 $self->{reqtext}{$self->{creqtool}}{$self->{creqversion}}.
281 $string;
282
283 }
284
285 sub require_end {
286 my $self=shift;
287 my $name=shift;
288
289 if ( $self->{reqcontext} != 1 ) {
290 $self->{switch}->parseerror("No matching tag for </$name>");
291 }
292 else {
293 $self->{reqcontext}=0;
294 }
295 }
296
297 sub select_start {
298 my $self=shift;
299 my $name=shift;
300 my $hashref=shift;
301
302 $self->{switch}->checktag( $name, $hashref, 'name');
303 $$hashref{'name'}=~tr[A-Z][a-z];
304 if ( $self->{Arch} ) {
305 $self->verbose("Selecting ".$$hashref{'name'});
306 $self->{selected}{$$hashref{'name'}}=1;
307 }
308 }
309
310 sub deselect_start {
311 my $self=shift;
312 my $name=shift;
313 my $hashref=shift;
314
315 $self->{switch}->checktag( $name, $hashref, 'name');
316 $$hashref{'name'}=~tr[A-Z][a-z];
317 if ( $self->{Arch} ) {
318 $self->verbose("Deselecting ".$$hashref{'name'});
319 $self->{selected}{$$hashref{'name'}}=0;
320 }
321 }
322
323 sub Arch_Start {
324 my $self=shift;
325 my $name=shift;
326 my $hashref=shift;
327
328 $self->{switch}->checktag($name, $hashref,'name');
329
330 ( ($self->arch()=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
331 : ($self->{Arch}=0);
332 $self->verbose(($self->{Arch}?"OK":"skipping")." ".$$hashref{name});
333 push @{$self->{ARCHBLOCK}}, $self->{Arch};
334 push @{$self->{ArchStack}}, $$hashref{'name'};
335 }
336
337 sub Arch_End {
338 my $self=shift;
339 my $name=shift;
340
341 pop @{$self->{ARCHBLOCK}};
342 $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
343 }
344
345 sub disttag {
346 my $self=shift;
347 my $name=shift;
348 my $hashref=shift;
349
350 if ( exists $$hashref{'url'} ) {
351 $self->{dist}{$self->{creqtool}}{$self->{creqversion}}=
352 $$hashref{'url'};
353 }
354 }