1 |
williamc |
1.2 |
package Configuration::BootStrapProject;
|
2 |
|
|
use ActiveDoc::SimpleURLDoc;
|
3 |
|
|
use Utilities::Verbose;
|
4 |
muzaffar |
1.13 |
use SCRAM::MsgLog;
|
5 |
williamc |
1.2 |
require 5.004;
|
6 |
|
|
|
7 |
|
|
@ISA=qw(Utilities::Verbose);
|
8 |
sashby |
1.10 |
$Configuration::BootStrapProject::self;
|
9 |
williamc |
1.2 |
|
10 |
sashby |
1.10 |
sub new()
|
11 |
sashby |
1.5 |
{
|
12 |
sashby |
1.10 |
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 |
muzaffar |
1.13.4.1 |
$self->{scramdoc} = ActiveDoc::SimpleURLDoc->new();
|
25 |
|
|
$self->{scramdoc}->newparse("bootstrap","Configuration::BootStrapProject",'Subs');
|
26 |
sashby |
1.10 |
$self->{Arch}=1;
|
27 |
|
|
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
28 |
|
|
return $self;
|
29 |
sashby |
1.5 |
}
|
30 |
|
|
|
31 |
sashby |
1.10 |
sub boot()
|
32 |
sashby |
1.5 |
{
|
33 |
|
|
my $self=shift;
|
34 |
|
|
my $url=shift;
|
35 |
sashby |
1.10 |
|
36 |
muzaffar |
1.13.4.1 |
$url=~s/^\s*file://;
|
37 |
|
|
$self->{scramdoc}->filetoparse($url);
|
38 |
muzaffar |
1.12 |
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 |
sashby |
1.5 |
return $self->{area};
|
42 |
|
|
}
|
43 |
|
|
|
44 |
williamc |
1.2 |
# --- Tag Routines
|
45 |
sashby |
1.10 |
sub project()
|
46 |
|
|
{
|
47 |
|
|
my ($xmlparser,$name,%attributes)=@_;
|
48 |
|
|
my $name = $attributes{'name'};
|
49 |
|
|
my $version = $attributes{'version'};
|
50 |
muzaffar |
1.13.4.1 |
my $src=$attributes{'source'} || 'src';
|
51 |
sashby |
1.10 |
|
52 |
muzaffar |
1.13 |
scramlogmsg("Creating New Project ".$name." Version ".$version."\n\n");
|
53 |
sashby |
1.10 |
|
54 |
|
|
use Configuration::ConfigArea;
|
55 |
muzaffar |
1.13.4.1 |
$self->{area}=Configuration::ConfigArea->new($ENV{SCRAM_ARCH});
|
56 |
sashby |
1.10 |
|
57 |
|
|
$self->{area}->name($name);
|
58 |
|
|
$self->{area}->version($version);
|
59 |
muzaffar |
1.13.4.1 |
$self->{area}->sourcedir($src);
|
60 |
|
|
$ENV{SCRAM_SOURCEDIR} = $src;
|
61 |
sashby |
1.10 |
$self->{area}->setup($self->{baselocation});
|
62 |
|
|
}
|
63 |
williamc |
1.2 |
|
64 |
sashby |
1.10 |
sub project_()
|
65 |
|
|
{
|
66 |
|
|
my ($xmlparser,$name,%attributes)=@_;
|
67 |
muzaffar |
1.13.4.1 |
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 |
sashby |
1.10 |
$self->{area}->save();
|
109 |
|
|
}
|
110 |
williamc |
1.2 |
|
111 |
sashby |
1.10 |
sub config()
|
112 |
sashby |
1.4 |
{
|
113 |
sashby |
1.10 |
my ($xmlparser,$name,%attributes)=@_;
|
114 |
|
|
$ENV{SCRAM_CONFIGDIR} = $attributes{'dir'};
|
115 |
|
|
$self->{area}->configurationdir($attributes{'dir'});
|
116 |
sashby |
1.4 |
}
|
117 |
williamc |
1.2 |
|
118 |
muzaffar |
1.13.4.1 |
sub toolbox () {
|
119 |
sashby |
1.10 |
my ($xmlparser,$name,%attributes)=@_;
|
120 |
muzaffar |
1.13.4.1 |
my $dir = $attributes{'dir'};
|
121 |
|
|
$dir=~s/^\s*file://;
|
122 |
|
|
$self->{toolbox}=$dir;
|
123 |
williamc |
1.2 |
}
|
124 |
|
|
|
125 |
muzaffar |
1.13.4.1 |
sub download()
|
126 |
sashby |
1.10 |
{
|
127 |
|
|
my ($xmlparser,$name,%attributes)=@_;
|
128 |
muzaffar |
1.13.4.1 |
$self->{scramdoc}->urldownload ($attributes{'url'},$self->{area}->location()."/".$attributes{'name'});
|
129 |
sashby |
1.10 |
}
|
130 |
sashby |
1.5 |
|
131 |
sashby |
1.10 |
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 |
sashby |
1.5 |
}
|
142 |
|
|
|
143 |
sashby |
1.10 |
1;
|