This repository has been archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
DidbsPackage.pm
127 lines (115 loc) · 4.18 KB
/
DidbsPackage.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package DidbsPackage;
use DidbsUtils;
# Contents read from packages/packageId.packagedef - contains:
#
# packageId
# packageSource (fetchable link for the package)
# packageFile (resulting file name after fetch)
# packageChecksum (a least a little signature check)
# packageExtraction (how to extract)
# packageDir (what directory gets created by extraction)
# packagePatch (patch to apply)
# expectedToolsList (can show which "sed" we use)
# dependenciesList (which other bootstrapped packages we depend on)
# envModifs (which env vars have to be set)
# configureRecipe (how to launch the configure step)
# buildRecipe (how to launch the build step)
# passesChecksIndicator (human set flag to warn when make check hasn't passed)
sub new
{
my $self = bless {}, shift;
my $verbose = shift;
$self->{v} = $verbose;
my $packageId = shift;
$self->{packageId} = $packageId;
return $self;
}
sub debug
{
my $self = shift;
if( $self->{v} )
{
didbsprint "DidbsPackage: \t ".$self->{packageId}."\n";
didbsprint " packageSource: \t=> ".$self->{packageSource}."\n";
didbsprint " packageFile: \t=> ".$self->{packageFile}."\n";
didbsprint " packageChecksum: \t=> ".$self->{packageChecksum}."\n";
didbsprint " packageExtraction: \t=> ".$self->{packageExtraction}."\n";
didbsprint " packageDir: \t=> ".$self->{packageDir}."\n";
didbsprint " packagePatch: \t=> ".$self->{packagePatch}."\n";
didbsprint " expectedToolList: \t=> ".$self->{expectedToolList}."\n";
didbsprint " dependenciesList: \t=> ".$self->{dependenciesList}."\n";
didbsprint " envModifs: \t=> ".$self->{envModifs}."\n";
didbsprint " configureRecipe: \t=> ".$self->{configureRecipe}."\n";
didbsprint " buildRecipe: \t=> ".$self->{buildRecipe}."\n";
didbsprint " installRecipe: \t=> ".$self->{installRecipe}."\n";
didbsprint " passesChecksIndicator:\t=> ".$self->{passesChecksIndicator}."\n";
didbsprint " disabled \t=> ".$self->{disabled}."\n";
didbsprint " compilers \t=> ".$self->{compilers}."\n";
didbsprint " sequenceNo: \t=> ".$self->{sequenceNo}."\n";
}
}
sub readPackageDef
{
my $self = shift;
my $scriptLocation = shift;
my $packageDefDir = shift;
my $packageDef = $packageDefDir . "/" .
$self->{packageId} . "/" .
$self->{packageId}.".packagedef";
if( !( -e $packageDef ) )
{
die "No such package definition: $packageDef\n";
}
$verbose && didbsprint "Reading from $packageDef\n";
open PKG, "<".$packageDef || die $!;
my @lines = <PKG>;
close PKG;
my %values;
foreach (@lines) {
chomp;
s|#.+||;
s|@(.+?)@|$1|g;
s|\s||;
my($key, $val) = split(/=/);
$values{$key} = $val;
}
$self->{packageSource} = $values{"packageSource"};
$self->{packageFile} = $values{"packageFile"};
$self->{packageChecksum} = $values{"packageChecksum"};
$self->{packageExtraction} = $values{"packageExtraction"};
$self->{packageDir} = $values{"packageDir"};
$self->{packagePatch} = $values{"packagePatch"};
$self->{expectedToolList} = $values{"expectedToolList"};
$self->{dependenciesList} = $values{"dependenciesList"};
$self->{envModifs} = $values{"envModifs"};
$self->{configureRecipe} = $values{"configureRecipe"};
$self->{buildRecipe} = $values{"buildRecipe"};
$self->{installRecipe} = $values{"installRecipe"};
$self->{passesChecksIndicator} = $values{"passesChecksIndicator"};
$self->{disabled} = $values{"disabled"};
$self->{compilers} = $values{"compilers"};
if( length($self->{compilers}) == 0 )
{
die "Package $self->{packageId} has no defined compilers!\n";
}
if( length($self->{configureRecipe}) == 0
||
length($self->{buildRecipe}) == 0
||
length($self->{installRecipe}) == 0 )
{
die "configureRecipe, buildRecipe, installRecipe must be filled for $packageDef.";
}
if( length($self->{envModifs}) != 0 )
{
my $envModifsFilePath = $packageDefDir . "/" .
$self->{packageId} . "/" .
$self->{envModifs};
if( !(-e $envModifsFilePath) )
{
my $packageId = $self->{packageId};
die "Package $packageId specifies envModifs but file not found.";
}
}
}
1;