ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Configuration/BootStrapProject.pm
Revision: 1.13
Committed: Fri Dec 14 09:03:54 2007 UTC (17 years, 4 months ago) by muzaffar
Content type: text/plain
Branch: MAIN
CVS Tags: V1_2_1b, V1_2_1a, V1_2_3, V1_2_2, V1_2_2_relcand2, V1_2_2_relcand1, V1_2_1, V1_2_0, V1_2_0-cand11, V1_1_7, V1_1_6, V1_2_0-cand10, V1_1_5, V1_2_0-cand9, V1_2_0-cand8, V1_2_0-cand7, V1_2_0-cand6, V1_2_0-cand5, V1_2_0-cand4, V1_2_0-cand3, V1_2_0-cand2, V1_2_0-cand1, V1_1_4, V1_1_3, V1_1_2, V1_1_0_reltag8, V1_1_0_reltag7, V1_1_0_reltag6, V1_1_1, V1_1_0_reltag5, V1_1_0_reltag4, V1_1_0_reltag3, V1_1_0_reltag2, V1_1_0_reltag1, V1_1_0_reltag, V1_1_0_cand3, V1_1_0_cand2, V1_1_0_cand1
Branch point for: SCRAM_V2_0, forBinLess_SCRAM
Changes since 1.12: +2 -3 lines
Log Message:
replace head with xml branch

File Contents

# User Rev Content
1 sashby 1.7 =head1 NAME
2    
3     Configuration::BootStrapProject - File parsing utilities for boot files.
4    
5     =head1 SYNOPSIS
6    
7     my $obj = Configuration::BootStrapProject->new([$area]);
8    
9     =head1 DESCRIPTION
10    
11     Package containing functions for parsing bootstrap files (project initialisation documents).
12 muzaffar 1.12
13 sashby 1.7 =head1 METHODS
14    
15     =over
16    
17     =cut
18    
19     =item C<new($cache,$installbase)>
20    
21     A new bootstrapper.
22    
23     =item C<boot(url[,$devareaname])>
24    
25     Boot up a new project and return the Configuration::ConfigArea.
26    
27     =back
28    
29     =head1 AUTHOR
30    
31     Originally written by Christopher Williams.
32    
33     =head1 MAINTAINER
34    
35     Shaun ASHBY
36    
37     =cut
38 williamc 1.2
39     package Configuration::BootStrapProject;
40     use ActiveDoc::SimpleURLDoc;
41     use URL::URLhandler;
42     use Utilities::Verbose;
43 muzaffar 1.13 use SCRAM::MsgLog;
44 williamc 1.2 require 5.004;
45    
46     @ISA=qw(Utilities::Verbose);
47 sashby 1.10 $Configuration::BootStrapProject::self;
48 williamc 1.2
49 sashby 1.10 sub new()
50 sashby 1.5 {
51 sashby 1.10 my $class=shift;
52     # Initialise the global package variable:
53     no strict 'refs';
54     $self = defined $self ? $self
55     : (bless {}, $class );
56     $self->{havesourcedir}=0;
57     $self->{cache}=shift;
58     $self->{baselocation}=shift;
59    
60     if ( @_ )
61     {
62     $self->{area}=shift;
63     }
64    
65     $self->{mydoctype}="Configuration::BootStrapProject";
66     $self->{mydocversion}="1.0";
67     $self->{scramdoc} = ActiveDoc::SimpleURLDoc->new($self->{cache});
68     $self->{scramdoc}->newparse("bootstrap",$self->{mydoctype},'Subs');
69     $self->{Arch}=1;
70     push @{$self->{ARCHBLOCK}}, $self->{Arch};
71     return $self;
72 sashby 1.5 }
73    
74 sashby 1.10 sub boot()
75 sashby 1.5 {
76     my $self=shift;
77     my $url=shift;
78 sashby 1.10 my $filemode = 0644;
79     # Check that the boot file is XML (simplistic check: make sure file
80     # suffix is xml!):
81     if ($url !~ /xml$/) {
82     die __PACKAGE__.": Wrong boot file type (MUST be XML!)\n";
83     }
84    
85     # -- override directory name
86     if ( @_ )
87     {
88     $self->{devareaname}=shift;
89     }
90     else
91     {
92     $self->{devareaname}="";
93     }
94    
95     my ($fullurl,$filename)=$self->{scramdoc}->urldownload($url);
96 sashby 1.6 chmod $filemode,$filename;
97 sashby 1.10 $self->{scramdoc}->filetoparse($filename);
98 muzaffar 1.12 my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="Configuration::BootStrapProject" version="1.0">';
99     my $ftail='</doc>';
100     $self->{scramdoc}->parse("bootstrap",$fhead,$ftail);
101 sashby 1.5 return $self->{area};
102     }
103    
104 williamc 1.2 # --- Tag Routines
105 sashby 1.10 sub project()
106     {
107     my ($xmlparser,$name,%attributes)=@_;
108     my $name = $attributes{'name'};
109     my $version = $attributes{'version'};
110    
111 muzaffar 1.13 scramlogmsg("Creating New Project ".$name." Version ".$version."\n\n");
112 sashby 1.10
113     use Configuration::ConfigArea;
114     $self->{area}=Configuration::ConfigArea->new();
115    
116     $self->{area}->name($name);
117     $self->{area}->version($version);
118     $self->{area}->setup($self->{baselocation});
119    
120     # new urlhandler based on area cache
121     $self->{scramdoc}->cache($self->{area}->cache());
122     }
123 williamc 1.2
124 sashby 1.10 sub project_()
125     {
126     my ($xmlparser,$name,%attributes)=@_;
127     $self->{area}->sourcedir('src');
128     $ENV{SCRAM_SOURCEDIR} = $self->{area}->sourcedir();
129     $self->{area}->save();
130     }
131 williamc 1.2
132 sashby 1.10 sub config()
133 sashby 1.4 {
134 sashby 1.10 my ($xmlparser,$name,%attributes)=@_;
135 sashby 1.4 # Set the project config dir variable here so that
136     # "projconfigdir" value can be used while bootstrapping:
137 sashby 1.10 $ENV{SCRAM_CONFIGDIR} = $attributes{'dir'};
138     $self->{area}->configurationdir($attributes{'dir'});
139 sashby 1.4 }
140 williamc 1.2
141 sashby 1.10 sub download()
142     {
143     my ($xmlparser,$name,%attributes)=@_;
144     # -- download into top directory
145     my ($fullurl,$filename)=$self->{scramdoc}->urlget($attributes{'url'},
146     $self->{area}->location()."/".$attributes{'name'});
147     }
148 williamc 1.2
149 sashby 1.10 sub requirementsdoc() {
150     my ($xmlparser,$name,%attributes)=@_;
151     my ($filename,$fullurl);
152    
153     if ( exists $attributes{'url'} ) {
154 sashby 1.9 # -- download into our cache
155 sashby 1.10 ($fullurl,$filename)=$self->{scramdoc}->urlget($attributes{'url'});
156     } else {
157     $filename=$attributes{'name'};
158     }
159    
160     # Check that the requirements file is XML (simplistic check: make sure file
161     # suffix is xml!):
162     if ($filename !~ /xml$/) {
163     # We have to use exit here because die() doesn't respond...I guess
164     # that SIG{__DIE__} has been trapped somewhere:
165     print __PACKAGE__.": Wrong requirements file type (MUST be XML!)\n";
166     exit(1);
167     }
168    
169     $self->{area}->requirementsdoc($filename);
170 williamc 1.2 }
171    
172 sashby 1.10 sub doc()
173     {
174     my ($xmlparser,$name,%attributes)=@_;
175     my $doctype = $attributes{'type'};
176 sashby 1.5
177 sashby 1.10 if ($doctype ne $self->{mydoctype})
178     {
179     warn "Configuration::BootStrapProject::boot: Unable to handle doc of type $doctype";
180     }
181     }
182 sashby 1.5
183 sashby 1.10 sub AUTOLOAD()
184     {
185     my ($xmlparser,$name,%attributes)=@_;
186     return if $AUTOLOAD =~ /::DESTROY$/;
187     my $name=$AUTOLOAD;
188     $name =~ s/.*://;
189     if ($name eq 'base' || $name eq 'base_')
190     {
191     $self->{scramdoc}->$name(%attributes);
192     }
193 sashby 1.5 }
194    
195 sashby 1.10 1;