2 |
|
# |
3 |
|
# Interface |
4 |
|
# --------- |
5 |
< |
# new(file) : new requirements doc |
5 |
> |
# new(url,URLcache,ObjectStore) : 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 requirements (ordered) |
10 |
|
# url(tool) : return the url of a given tool |
11 |
|
|
12 |
|
package BuildSystem::Requirements; |
13 |
< |
use ActiveDoc::SimpleDoc; |
13 |
> |
use ActiveDoc::ActiveDoc; |
14 |
|
use Utilities::Verbose; |
15 |
|
|
16 |
|
require 5.004; |
21 |
|
my $self={}; |
22 |
|
bless $self, $class; |
23 |
|
$self->{file}=shift; |
24 |
+ |
$self->{cache}=shift; |
25 |
+ |
$self->{dbstore}=shift; |
26 |
+ |
$self->{mydocversion}="2.0"; |
27 |
|
$self->{Arch}=1; |
28 |
|
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
29 |
|
$self->init($self->{file}); |
36 |
|
|
37 |
|
my $tool; |
38 |
|
foreach $tool ( $self->tools() ) { |
39 |
+ |
$self->verbose("Setting Up Tool $tool"); |
40 |
|
$toolbox->toolsetup($tool, $self->version($tool), $self->url($tool)); |
41 |
|
} |
42 |
|
} |
60 |
|
|
61 |
|
sub init { |
62 |
|
my $self=shift; |
63 |
< |
my $file=shift; |
63 |
> |
my $url=shift; |
64 |
|
|
65 |
< |
my $switch=ActiveDoc::SimpleDoc->new(); |
66 |
< |
$switch->filetoparse($file); |
67 |
< |
$switch->newparse("doc"); |
64 |
< |
$switch->addtag("doc","Doc", \&Doc_start,$self,"",$self,"",$self); |
65 |
> |
my $switch=ActiveDoc::ActiveDoc->new($self->{cache},$self->{dbstore}); |
66 |
> |
$switch->verbosity($self->verbosity()); |
67 |
> |
$switch->url($url); |
68 |
|
$switch->newparse("ordering"); |
69 |
+ |
$switch->addbasetags("ordering"); |
70 |
|
$switch->addtag("ordering","Architecture", |
71 |
|
\&Arch_Start,$self, |
72 |
|
"", $self, |
76 |
|
\&require_start,$self, |
77 |
|
"", $self, |
78 |
|
"", $self); |
79 |
+ |
|
80 |
|
$self->{switch}=$switch; |
81 |
|
@{$self->{tools}}=(); |
82 |
|
|
83 |
< |
$self->{switch}->parse("doc"); |
83 |
> |
my($doctype,$docversion)=$switch->doctype(); |
84 |
|
# -- for backwards compatability only parse if we have a docversion |
85 |
|
# defined |
86 |
< |
if ( defined $self->{docversion} ) { |
87 |
< |
$self->{switch}->parse("ordering"); |
86 |
> |
if ( defined $docversion ) { |
87 |
> |
if ( $docversion eq $self->{mydocversion} ) { |
88 |
> |
$self->{switch}->parse("ordering"); |
89 |
> |
} |
90 |
> |
} |
91 |
> |
else { |
92 |
> |
#print "wrong doc version - not parsing\n"; |
93 |
|
} |
94 |
|
} |
95 |
|
|
96 |
|
sub download { |
97 |
|
my $self=shift; |
88 |
– |
my $toolbox=shift; |
98 |
|
|
99 |
|
my $tool; |
100 |
|
foreach $tool ( $self->tools() ) { |
101 |
|
$self->verbose("Downloading ".$self->url($tool)); |
102 |
< |
$toolbox->_download($self->url($tool)); |
102 |
> |
# get into the cache |
103 |
> |
$self->{switch}->urlget($self->url($tool)); |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
|
# ---- Tag routines |
108 |
|
|
99 |
– |
sub Doc_start { |
100 |
– |
my $self=shift; |
101 |
– |
my $name=shift; |
102 |
– |
my $hashref=shift; |
103 |
– |
|
104 |
– |
$self->{switch}->checktag( $name, $hashref, 'type'); |
105 |
– |
$self->{switch}->checktag( $name, $hashref, 'version'); |
106 |
– |
|
107 |
– |
$self->{docversion}=$$hashref{'version'}; |
108 |
– |
} |
109 |
– |
|
109 |
|
sub require_start { |
110 |
|
my $self=shift; |
111 |
|
my $name=shift; |
113 |
|
|
114 |
|
$self->{switch}->checktag( $name, $hashref, 'version'); |
115 |
|
$self->{switch}->checktag( $name, $hashref, 'name'); |
116 |
< |
$self->{switch}->checktag( $name, $hashref, 'file'); |
116 |
> |
$self->{switch}->checktag( $name, $hashref, 'url'); |
117 |
|
if ( $self->{Arch} ) { |
118 |
|
push @{$self->{tools}}, $$hashref{'name'}; |
119 |
|
$self->{version}{$$hashref{'name'}}=$$hashref{'version'}; |
120 |
< |
$self->{url}{$$hashref{'name'}}=$$hashref{'file'}; |
120 |
> |
# -- make sure the full url is taken |
121 |
> |
my $urlobj=$self->{switch}->expandurl($$hashref{'url'}); |
122 |
> |
$self->{url}{$$hashref{'name'}}=$urlobj->url(); |
123 |
|
} |
124 |
|
} |
125 |
|
|
141 |
|
pop @{$self->{ARCHBLOCK}}; |
142 |
|
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}]; |
143 |
|
} |
143 |
– |
|