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
/
DidbsStageChecker.pm
114 lines (91 loc) · 2.61 KB
/
DidbsStageChecker.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
package DidbsStageChecker;
use DidbsUtils;
use constant PACKAGESTAGE => qw(BUILD);
sub new
{
my $self = bless {}, shift;
my $scriptLocation = shift;
my $packageDir = shift;
my $buildDir = shift;
my $installDir = shift;
$self->{scriptLocation} = $scriptLocation;
$self->{packageDir} = $packageDir;
$self->{buildDir} = $buildDir;
$self->{installDir} = $installDir;
# Check to see what certain "stage" files exist
my $stageEnvString = $ENV{"DIDBS_STAGE"};
$self->{stageString} = defined($stageEnvString) ? $stageEnvString : "BUILD";
$self->{missingStageString} = $self->calcMissingStage();
didbsprint "Setting missing stage to $self->{missingStageString}\n";
return $self;
}
sub getStageAdjustedPackageDir
{
my $self = shift;
return $self->{packageDir};
}
sub getStageAdjustedBuildDir
{
my $self = shift;
return $self->{buildDir};
}
sub getStageAdjustedInstallDir
{
my $self = shift;
return $self->{installDir};
}
sub getStageAdjustedPackageDefDir()
{
my $self = shift;
return "$self->{scriptLocation}/packages";
}
sub calcMissingStage
{
# We rely on a previous didbs release now for "stage0" binaries
return undef;
}
sub stagesMissing
{
my $self = shift;
return defined($self->{missingStageString});
}
sub prependEnvVarPath
{
my $self = shift;
my $envVarName = shift;
my $extraPath = shift;
my $prevValue = $ENV{$envVarName};
if( !defined($prevValue) )
{
$ENV{$envVarName} = $extraPath;
}
else
{
$ENV{$envVarName} = $extraPath . ":" . $prevValue;
}
my $newValue = $ENV{$envVarName};
didbsprint "Reset $envVarName from $prevValue to $newValue\n";
}
sub modifyPathForCurrentStage
{
my $self = shift;
my $envRef = shift;
didbsprint "Modifying path for stage '$self->{stageString}' ...\n";
my $extraBinPath = $self->getStageAdjustedInstallDir() . "/bin";
$self->prependEnvVarPath("PATH", $extraBinPath);
my $extraLibPath;
my $extraPkgConfigPath;
if( $ENV{"DIDBS_LIBDIR"} eq "lib32" ) {
$extraLibPath = $self->getStageAdjustedInstallDir() . "/lib32";
$self->prependEnvVarPath("LD_LIBRARYN32_PATH", $extraLibPath);
$extraPkgConfigPath = $self->getStageAdjustedInstallDir() . "/lib32/pkgconfig";
}
else {
$extraLibPath = $self->getStageAdjustedInstallDir() . "/lib64";
$self->prependEnvVarPath("LD_LIBRARYN64_PATH", $extraLibPath);
$extraPkgConfigPath = $self->getStageAdjustedInstallDir() . "/lib64/pkgconfig";
}
$self->prependEnvVarPath("LD_LIBRARY_PATH", $extraLibPath);
$self->prependEnvVarPath("PKG_CONFIG_PATH", $extraPkgConfigPath);
}
1;