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

# Content
1 =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
13 =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
39 package Configuration::BootStrapProject;
40 use ActiveDoc::SimpleURLDoc;
41 use URL::URLhandler;
42 use Utilities::Verbose;
43 use SCRAM::MsgLog;
44 require 5.004;
45
46 @ISA=qw(Utilities::Verbose);
47 $Configuration::BootStrapProject::self;
48
49 sub new()
50 {
51 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 }
73
74 sub boot()
75 {
76 my $self=shift;
77 my $url=shift;
78 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 chmod $filemode,$filename;
97 $self->{scramdoc}->filetoparse($filename);
98 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 return $self->{area};
102 }
103
104 # --- Tag Routines
105 sub project()
106 {
107 my ($xmlparser,$name,%attributes)=@_;
108 my $name = $attributes{'name'};
109 my $version = $attributes{'version'};
110
111 scramlogmsg("Creating New Project ".$name." Version ".$version."\n\n");
112
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
124 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
132 sub config()
133 {
134 my ($xmlparser,$name,%attributes)=@_;
135 # Set the project config dir variable here so that
136 # "projconfigdir" value can be used while bootstrapping:
137 $ENV{SCRAM_CONFIGDIR} = $attributes{'dir'};
138 $self->{area}->configurationdir($attributes{'dir'});
139 }
140
141 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
149 sub requirementsdoc() {
150 my ($xmlparser,$name,%attributes)=@_;
151 my ($filename,$fullurl);
152
153 if ( exists $attributes{'url'} ) {
154 # -- download into our cache
155 ($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 }
171
172 sub doc()
173 {
174 my ($xmlparser,$name,%attributes)=@_;
175 my $doctype = $attributes{'type'};
176
177 if ($doctype ne $self->{mydoctype})
178 {
179 warn "Configuration::BootStrapProject::boot: Unable to handle doc of type $doctype";
180 }
181 }
182
183 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 }
194
195 1;