ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Requirements.pm
Revision: 1.1.2.4.2.1
Committed: Wed Aug 9 16:00:37 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
Changes since 1.1.2.4: +15 -7 lines
Log Message:
add url mechanism + download

File Contents

# User Rev Content
1 williamc 1.1.2.1 # Requirements Doc - just to get ordering info
2     #
3     # Interface
4     # ---------
5 williamc 1.1.2.4.2.1 # new(file,URLcache) : 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.1 use ActiveDoc::SimpleURLDoc;
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.1 $self->{Arch}=1;
26 williamc 1.1.2.3 push @{$self->{ARCHBLOCK}}, $self->{Arch};
27 williamc 1.1.2.1 $self->init($self->{file});
28     return $self;
29     }
30    
31 williamc 1.1.2.2 sub setup {
32     my $self=shift;
33     my $toolbox=shift;
34    
35     my $tool;
36     foreach $tool ( $self->tools() ) {
37 williamc 1.1.2.4.2.1 $self->verbose("Setting Up Tool $tool");
38 williamc 1.1.2.2 $toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
39     }
40     }
41    
42 williamc 1.1.2.1 sub tools {
43     my $self=shift;
44     return @{$self->{tools}};
45     }
46    
47     sub version {
48     my $self=shift;
49     my $tool=shift;
50     return $self->{'version'}{$tool};
51     }
52    
53 williamc 1.1.2.2 sub url {
54     my $self=shift;
55     my $tool=shift;
56     return $self->{'url'}{$tool};
57     }
58    
59 williamc 1.1.2.1 sub init {
60     my $self=shift;
61     my $file=shift;
62    
63 williamc 1.1.2.4.2.1 my $switch=ActiveDoc::SimpleURLDoc->new($self->{cache});
64 williamc 1.1.2.1 $switch->filetoparse($file);
65 williamc 1.1.2.4 $switch->newparse("doc");
66     $switch->addtag("doc","Doc", \&Doc_start,$self,"",$self,"",$self);
67 williamc 1.1.2.1 $switch->newparse("ordering");
68 williamc 1.1.2.4.2.1 $switch->addbasetags("ordering");
69 williamc 1.1.2.3 $switch->addtag("ordering","Architecture",
70     \&Arch_Start,$self,
71     "", $self,
72     \&Arch_End, $self);
73     $switch->grouptag("Architecture","ordering");
74 williamc 1.1.2.1 $switch->addtag("ordering","require",
75     \&require_start,$self,
76     "", $self,
77     "", $self);
78     $self->{switch}=$switch;
79     @{$self->{tools}}=();
80 williamc 1.1.2.4
81     $self->{switch}->parse("doc");
82     # -- for backwards compatability only parse if we have a docversion
83     # defined
84     if ( defined $self->{docversion} ) {
85     $self->{switch}->parse("ordering");
86     }
87 williamc 1.1.2.4.2.1 else {
88     #print "wrong doc version - not parsing\n";
89     }
90 williamc 1.1.2.2 }
91    
92     sub download {
93     my $self=shift;
94    
95     my $tool;
96     foreach $tool ( $self->tools() ) {
97     $self->verbose("Downloading ".$self->url($tool));
98 williamc 1.1.2.4.2.1 # get into the cache
99     $self->{switch}->urlget($self->url($tool));
100 williamc 1.1.2.2 }
101 williamc 1.1.2.1 }
102    
103     # ---- Tag routines
104 williamc 1.1.2.4
105     sub Doc_start {
106     my $self=shift;
107     my $name=shift;
108     my $hashref=shift;
109    
110     $self->{switch}->checktag( $name, $hashref, 'type');
111     $self->{switch}->checktag( $name, $hashref, 'version');
112    
113     $self->{docversion}=$$hashref{'version'};
114     }
115    
116 williamc 1.1.2.1 sub require_start {
117     my $self=shift;
118     my $name=shift;
119     my $hashref=shift;
120    
121     $self->{switch}->checktag( $name, $hashref, 'version');
122     $self->{switch}->checktag( $name, $hashref, 'name');
123 williamc 1.1.2.4.2.1 $self->{switch}->checktag( $name, $hashref, 'url');
124 williamc 1.1.2.1 if ( $self->{Arch} ) {
125     push @{$self->{tools}}, $$hashref{'name'};
126 williamc 1.1.2.2 $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
127 williamc 1.1.2.4.2.1 # -- make sure the full url is taken
128     my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
129     $self->{url}{$$hashref{'name'}}=$urlobj->url();
130 williamc 1.1.2.1 }
131     }
132 williamc 1.1.2.3
133     sub Arch_Start {
134     my $self=shift;
135     my $name=shift;
136     my $hashref=shift;
137    
138     $self->{switch}->checktag($name, $hashref,'name');
139     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
140     : ($self->{Arch}=0);
141     push @{$self->{ARCHBLOCK}}, $self->{Arch};
142     }
143    
144     sub Arch_End {
145     my $self=shift;
146     my $name=shift;
147    
148     pop @{$self->{ARCHBLOCK}};
149     $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
150     }
151