1 |
williamc |
1.1.2.1 |
# Requirements Doc - just to get ordering info
|
2 |
|
|
#
|
3 |
|
|
# Interface
|
4 |
|
|
# ---------
|
5 |
williamc |
1.1.2.4.2.5 |
# new(url,URLcache,ObjectStore) : new requirements doc
|
6 |
williamc |
1.1.2.2 |
# setup(toolbox): set up the requirements into the specified toolbox object
|
7 |
|
|
# download(toolbox) : download description files (into toolbox cache)
|
8 |
williamc |
1.1.2.1 |
# tools() : Return list of requirements (ordered)
|
9 |
|
|
# version(tool) : return the version of a given tool
|
10 |
williamc |
1.1.2.2 |
# url(tool) : return the url of a given tool
|
11 |
williamc |
1.1.2.1 |
|
12 |
|
|
package BuildSystem::Requirements;
|
13 |
williamc |
1.1.2.4.2.4 |
use ActiveDoc::ActiveDoc;
|
14 |
williamc |
1.1.2.2 |
use Utilities::Verbose;
|
15 |
|
|
|
16 |
williamc |
1.1.2.1 |
require 5.004;
|
17 |
williamc |
1.1.2.2 |
@ISA=qw(Utilities::Verbose);
|
18 |
williamc |
1.1.2.1 |
|
19 |
|
|
sub new {
|
20 |
|
|
my $class=shift;
|
21 |
|
|
my $self={};
|
22 |
|
|
bless $self, $class;
|
23 |
|
|
$self->{file}=shift;
|
24 |
williamc |
1.1.2.4.2.1 |
$self->{cache}=shift;
|
25 |
williamc |
1.1.2.4.2.4 |
$self->{dbstore}=shift;
|
26 |
williamc |
1.1.2.4.2.2 |
$self->{mydocversion}="2.0";
|
27 |
williamc |
1.1.2.1 |
$self->{Arch}=1;
|
28 |
williamc |
1.1.2.3 |
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
29 |
williamc |
1.1.2.1 |
$self->init($self->{file});
|
30 |
|
|
return $self;
|
31 |
|
|
}
|
32 |
|
|
|
33 |
williamc |
1.1.2.2 |
sub setup {
|
34 |
|
|
my $self=shift;
|
35 |
|
|
my $toolbox=shift;
|
36 |
|
|
|
37 |
|
|
my $tool;
|
38 |
|
|
foreach $tool ( $self->tools() ) {
|
39 |
williamc |
1.1.2.4.2.1 |
$self->verbose("Setting Up Tool $tool");
|
40 |
williamc |
1.1.2.2 |
$toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
|
41 |
|
|
}
|
42 |
|
|
}
|
43 |
|
|
|
44 |
williamc |
1.1.2.1 |
sub tools {
|
45 |
|
|
my $self=shift;
|
46 |
|
|
return @{$self->{tools}};
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
sub version {
|
50 |
|
|
my $self=shift;
|
51 |
|
|
my $tool=shift;
|
52 |
|
|
return $self->{'version'}{$tool};
|
53 |
|
|
}
|
54 |
|
|
|
55 |
williamc |
1.1.2.2 |
sub url {
|
56 |
|
|
my $self=shift;
|
57 |
|
|
my $tool=shift;
|
58 |
|
|
return $self->{'url'}{$tool};
|
59 |
|
|
}
|
60 |
|
|
|
61 |
williamc |
1.1.2.1 |
sub init {
|
62 |
|
|
my $self=shift;
|
63 |
williamc |
1.1.2.4.2.5 |
my $url=shift;
|
64 |
williamc |
1.1.2.1 |
|
65 |
williamc |
1.1.2.4.2.5 |
my $switch=ActiveDoc::ActiveDoc->new($self->{cache},$self->{dbstore});
|
66 |
|
|
$switch->verbosity($self->verbosity());
|
67 |
|
|
$switch->url($url);
|
68 |
williamc |
1.1.2.1 |
$switch->newparse("ordering");
|
69 |
williamc |
1.1.2.4.2.1 |
$switch->addbasetags("ordering");
|
70 |
williamc |
1.1.2.3 |
$switch->addtag("ordering","Architecture",
|
71 |
|
|
\&Arch_Start,$self,
|
72 |
|
|
"", $self,
|
73 |
|
|
\&Arch_End, $self);
|
74 |
|
|
$switch->grouptag("Architecture","ordering");
|
75 |
williamc |
1.1.2.1 |
$switch->addtag("ordering","require",
|
76 |
|
|
\&require_start,$self,
|
77 |
|
|
"", $self,
|
78 |
|
|
"", $self);
|
79 |
williamc |
1.1.2.4.2.2 |
|
80 |
williamc |
1.1.2.1 |
$self->{switch}=$switch;
|
81 |
|
|
@{$self->{tools}}=();
|
82 |
williamc |
1.1.2.4 |
|
83 |
williamc |
1.1.2.4.2.5 |
my($doctype,$docversion)=$switch->doctype();
|
84 |
williamc |
1.1.2.4 |
# -- for backwards compatability only parse if we have a docversion
|
85 |
|
|
# defined
|
86 |
williamc |
1.1.2.4.2.5 |
if ( defined $docversion ) {
|
87 |
|
|
if ( $docversion eq $self->{mydocversion} ) {
|
88 |
williamc |
1.1.2.4.2.2 |
$self->{switch}->parse("ordering");
|
89 |
|
|
}
|
90 |
williamc |
1.1.2.4 |
}
|
91 |
williamc |
1.1.2.4.2.1 |
else {
|
92 |
|
|
#print "wrong doc version - not parsing\n";
|
93 |
|
|
}
|
94 |
williamc |
1.1.2.2 |
}
|
95 |
|
|
|
96 |
|
|
sub download {
|
97 |
|
|
my $self=shift;
|
98 |
|
|
|
99 |
|
|
my $tool;
|
100 |
|
|
foreach $tool ( $self->tools() ) {
|
101 |
|
|
$self->verbose("Downloading ".$self->url($tool));
|
102 |
williamc |
1.1.2.4.2.1 |
# get into the cache
|
103 |
|
|
$self->{switch}->urlget($self->url($tool));
|
104 |
williamc |
1.1.2.2 |
}
|
105 |
williamc |
1.1.2.1 |
}
|
106 |
|
|
|
107 |
|
|
# ---- Tag routines
|
108 |
williamc |
1.1.2.4 |
|
109 |
williamc |
1.1.2.1 |
sub require_start {
|
110 |
|
|
my $self=shift;
|
111 |
|
|
my $name=shift;
|
112 |
|
|
my $hashref=shift;
|
113 |
|
|
|
114 |
|
|
$self->{switch}->checktag( $name, $hashref, 'version');
|
115 |
|
|
$self->{switch}->checktag( $name, $hashref, 'name');
|
116 |
williamc |
1.1.2.4.2.1 |
$self->{switch}->checktag( $name, $hashref, 'url');
|
117 |
williamc |
1.1.2.1 |
if ( $self->{Arch} ) {
|
118 |
|
|
push @{$self->{tools}}, $$hashref{'name'};
|
119 |
williamc |
1.1.2.2 |
$self->{version}{$$hashref{'name'}}=$$hashref{'version'};
|
120 |
williamc |
1.1.2.4.2.1 |
# -- make sure the full url is taken
|
121 |
|
|
my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
|
122 |
|
|
$self->{url}{$$hashref{'name'}}=$urlobj->url();
|
123 |
williamc |
1.1.2.1 |
}
|
124 |
|
|
}
|
125 |
williamc |
1.1.2.3 |
|
126 |
|
|
sub Arch_Start {
|
127 |
|
|
my $self=shift;
|
128 |
|
|
my $name=shift;
|
129 |
|
|
my $hashref=shift;
|
130 |
|
|
|
131 |
|
|
$self->{switch}->checktag($name, $hashref,'name');
|
132 |
|
|
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
|
133 |
|
|
: ($self->{Arch}=0);
|
134 |
|
|
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
sub Arch_End {
|
138 |
|
|
my $self=shift;
|
139 |
|
|
my $name=shift;
|
140 |
|
|
|
141 |
|
|
pop @{$self->{ARCHBLOCK}};
|
142 |
|
|
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
|
143 |
williamc |
1.1.2.4.2.2 |
}
|