1 |
package Configuration::BootStrapProject;
|
2 |
use ActiveDoc::SimpleURLDoc;
|
3 |
use Utilities::Verbose;
|
4 |
use SCRAM::MsgLog;
|
5 |
require 5.004;
|
6 |
|
7 |
@ISA=qw(Utilities::Verbose);
|
8 |
$Configuration::BootStrapProject::self;
|
9 |
|
10 |
sub new()
|
11 |
{
|
12 |
my $class=shift;
|
13 |
# Initialise the global package variable:
|
14 |
no strict 'refs';
|
15 |
$self = defined $self ? $self
|
16 |
: (bless {}, $class );
|
17 |
$self->{baselocation}=shift;
|
18 |
|
19 |
if ( @_ )
|
20 |
{
|
21 |
$self->{area}=shift;
|
22 |
}
|
23 |
|
24 |
$self->{scramdoc} = ActiveDoc::SimpleURLDoc->new();
|
25 |
$self->{scramdoc}->newparse("bootstrap","Configuration::BootStrapProject",'Subs');
|
26 |
$self->{Arch}=1;
|
27 |
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
28 |
return $self;
|
29 |
}
|
30 |
|
31 |
sub boot()
|
32 |
{
|
33 |
my $self=shift;
|
34 |
my $url=shift;
|
35 |
|
36 |
$url=~s/^\s*file://;
|
37 |
$self->{scramdoc}->filetoparse($url);
|
38 |
my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="Configuration::BootStrapProject" version="1.0">';
|
39 |
my $ftail='</doc>';
|
40 |
$self->{scramdoc}->parse("bootstrap",$fhead,$ftail);
|
41 |
return $self->{area};
|
42 |
}
|
43 |
|
44 |
# --- Tag Routines
|
45 |
sub project()
|
46 |
{
|
47 |
my ($xmlparser,$name,%attributes)=@_;
|
48 |
my $name = $attributes{'name'};
|
49 |
my $version = $attributes{'version'};
|
50 |
my $src=$attributes{'source'} || 'src';
|
51 |
|
52 |
scramlogmsg("Creating New Project ".$name." Version ".$version."\n\n");
|
53 |
|
54 |
use Configuration::ConfigArea;
|
55 |
$self->{area}=Configuration::ConfigArea->new($ENV{SCRAM_ARCH});
|
56 |
|
57 |
$self->{area}->name($name);
|
58 |
$self->{area}->version($version);
|
59 |
$self->{area}->sourcedir($src);
|
60 |
$ENV{SCRAM_SOURCEDIR} = $src;
|
61 |
$self->{area}->setup($self->{baselocation});
|
62 |
}
|
63 |
|
64 |
sub project_()
|
65 |
{
|
66 |
my ($xmlparser,$name,%attributes)=@_;
|
67 |
my $confdir = $self->{area}->location()."/".$self->{area}->configurationdir();
|
68 |
my $conf="${confdir}/toolbox/".$self->{area}->arch();
|
69 |
my $toolbox=$self->{toolbox};
|
70 |
if (-d $toolbox)
|
71 |
{
|
72 |
use Utilities::AddDir;
|
73 |
if (-d "${toolbox}/tools")
|
74 |
{
|
75 |
Utilities::AddDir::copydirexp("${toolbox}/tools","${conf}/tools",'\.xml$');
|
76 |
}
|
77 |
else
|
78 |
{
|
79 |
my $boot=$self->{scramdoc}->filetoparse();
|
80 |
die "Project creating error. Missing directory \"${toolbox}/tools\" in the toolbox. Please fix file \"$boo\" and set a valid toolbox directory.";
|
81 |
}
|
82 |
if (-d "${toolbox}/site")
|
83 |
{
|
84 |
Utilities::AddDir::copydir("${toolbox}/site","${conf}/site");
|
85 |
}
|
86 |
else
|
87 |
{
|
88 |
Utilities::AddDir::adddir("${conf}/site");
|
89 |
my $rf;open($rf,">${conf}/site/tools.conf");close($rf);
|
90 |
}
|
91 |
}
|
92 |
else
|
93 |
{
|
94 |
my $boot=$self->{scramdoc}->filetoparse();
|
95 |
die "Project creating error. Missing toolbox directory \"${toolbox}\". Please fix file \"$boot\" and set a valid toolbox directory.";
|
96 |
}
|
97 |
$self->{area}->configchksum($self->{area}->calchksum());
|
98 |
if (!-f "${confdir}/scram_version")
|
99 |
{
|
100 |
my $ref;
|
101 |
if (open($ref,">${confdir}/scram_version"))
|
102 |
{
|
103 |
print $ref "$ENV{SCRAM_VERSION}\n";
|
104 |
close($ref);
|
105 |
}
|
106 |
else{die "ERROR: Can not open ${confdir}/scram_version file for writing.";}
|
107 |
}
|
108 |
$self->{area}->save();
|
109 |
}
|
110 |
|
111 |
sub config()
|
112 |
{
|
113 |
my ($xmlparser,$name,%attributes)=@_;
|
114 |
$ENV{SCRAM_CONFIGDIR} = $attributes{'dir'};
|
115 |
$self->{area}->configurationdir($attributes{'dir'});
|
116 |
}
|
117 |
|
118 |
sub toolbox () {
|
119 |
my ($xmlparser,$name,%attributes)=@_;
|
120 |
my $dir = $attributes{'dir'};
|
121 |
$dir=~s/^\s*file://;
|
122 |
$self->{toolbox}=$dir;
|
123 |
}
|
124 |
|
125 |
sub download()
|
126 |
{
|
127 |
my ($xmlparser,$name,%attributes)=@_;
|
128 |
$self->{scramdoc}->urldownload ($attributes{'url'},$self->{area}->location()."/".$attributes{'name'});
|
129 |
}
|
130 |
|
131 |
sub AUTOLOAD()
|
132 |
{
|
133 |
my ($xmlparser,$name,%attributes)=@_;
|
134 |
return if $AUTOLOAD =~ /::DESTROY$/;
|
135 |
my $name=$AUTOLOAD;
|
136 |
$name =~ s/.*://;
|
137 |
if ($name eq 'base' || $name eq 'base_')
|
138 |
{
|
139 |
$self->{scramdoc}->$name(%attributes);
|
140 |
}
|
141 |
}
|
142 |
|
143 |
1;
|