Commit 6a86630a authored by Guillem Jover's avatar Guillem Jover

Dpkg::BuildFlags: Record environment variables accessed or modified

Record environment variables looked at by Dpkg::BuildFlags and the
vendor hooks and make them available via the new Dpkg::BuildEnv module.
Based-on-patch-by: Bernhard Link's avatarBernhard R. Link <brlink@debian.org>
Signed-off-by: Guillem Jover's avatarGuillem Jover <guillem@debian.org>
parent 17b85475
......@@ -32,6 +32,7 @@ use POSIX qw(:errno_h);
use Dpkg;
use Dpkg::Gettext;
use Dpkg::ErrorHandling;
use Dpkg::BuildEnv;
my (@cpu, @os);
my (%cputable, %ostable);
......@@ -65,7 +66,7 @@ my %debarch_to_debtriplet;
sub get_build_arch()
{
return $ENV{DEB_BUILD_ARCH} || get_raw_build_arch();
return Dpkg::BuildEnv::get('DEB_BUILD_ARCH') || get_raw_build_arch();
}
sub get_gcc_host_gnu_type()
......@@ -114,7 +115,7 @@ my %debarch_to_debtriplet;
sub get_host_arch()
{
return $ENV{DEB_HOST_ARCH} || get_raw_host_arch();
return Dpkg::BuildEnv::get('DEB_HOST_ARCH') || get_raw_host_arch();
}
}
......
......@@ -21,6 +21,7 @@ use warnings;
our $VERSION = "1.03";
use Dpkg::Gettext;
use Dpkg::BuildEnv;
use Dpkg::BuildOptions;
use Dpkg::ErrorHandling;
use Dpkg::Vendor qw(run_vendor_hook);
......@@ -126,20 +127,20 @@ sub load_environment_config {
my ($self) = @_;
foreach my $flag (keys %{$self->{flags}}) {
my $envvar = "DEB_" . $flag . "_SET";
if (exists $ENV{$envvar}) {
$self->set($flag, $ENV{$envvar}, "env");
if (Dpkg::BuildEnv::has($envvar)) {
$self->set($flag, Dpkg::BuildEnv::get($envvar), "env");
}
$envvar = "DEB_" . $flag . "_STRIP";
if (exists $ENV{$envvar}) {
$self->strip($flag, $ENV{$envvar}, "env");
if (Dpkg::BuildEnv::has($envvar)) {
$self->strip($flag, Dpkg::BuildEnv::get($envvar), "env");
}
$envvar = "DEB_" . $flag . "_APPEND";
if (exists $ENV{$envvar}) {
$self->append($flag, $ENV{$envvar}, "env");
if (Dpkg::BuildEnv::has($envvar)) {
$self->append($flag, Dpkg::BuildEnv::get($envvar), "env");
}
$envvar = "DEB_" . $flag . "_PREPEND";
if (exists $ENV{$envvar}) {
$self->prepend($flag, $ENV{$envvar}, "env");
if (Dpkg::BuildEnv::has($envvar)) {
$self->prepend($flag, Dpkg::BuildEnv::get($envvar), "env");
}
}
}
......@@ -155,20 +156,20 @@ sub load_maintainer_config {
my ($self) = @_;
foreach my $flag (keys %{$self->{flags}}) {
my $envvar = "DEB_" . $flag . "_MAINT_SET";
if (exists $ENV{$envvar}) {
$self->set($flag, $ENV{$envvar}, undef);
if (Dpkg::BuildEnv::has($envvar)) {
$self->set($flag, Dpkg::BuildEnv::get($envvar), undef);
}
$envvar = "DEB_" . $flag . "_MAINT_STRIP";
if (exists $ENV{$envvar}) {
$self->strip($flag, $ENV{$envvar}, undef);
if (Dpkg::BuildEnv::has($envvar)) {
$self->strip($flag, Dpkg::BuildEnv::get($envvar), undef);
}
$envvar = "DEB_" . $flag . "_MAINT_APPEND";
if (exists $ENV{$envvar}) {
$self->append($flag, $ENV{$envvar}, undef);
if (Dpkg::BuildEnv::has($envvar)) {
$self->append($flag, Dpkg::BuildEnv::get($envvar), undef);
}
$envvar = "DEB_" . $flag . "_MAINT_PREPEND";
if (exists $ENV{$envvar}) {
$self->prepend($flag, $ENV{$envvar}, undef);
if (Dpkg::BuildEnv::has($envvar)) {
$self->prepend($flag, Dpkg::BuildEnv::get($envvar), undef);
}
}
}
......
......@@ -23,6 +23,7 @@ our $VERSION = "1.01";
use Dpkg::Gettext;
use Dpkg::ErrorHandling;
use Dpkg::BuildEnv;
=encoding utf8
......@@ -58,7 +59,7 @@ sub new {
envvar => $opts{'envvar'} // "DEB_BUILD_OPTIONS",
};
bless $self, $class;
$self->merge($ENV{$self->{'envvar'}}, $self->{'envvar'});
$self->merge(Dpkg::BuildEnv::get($self->{'envvar'}), $self->{'envvar'});
return $self;
}
......@@ -181,7 +182,7 @@ sub export {
my ($self, $var) = @_;
$var = $self->{'envvar'} unless defined $var;
my $content = $self->output();
$ENV{$var} = $content;
Dpkg::BuildEnv::set($var, $content);
return $content;
}
......
......@@ -22,6 +22,7 @@ our $VERSION = "1.00";
use Dpkg::ErrorHandling;
use Dpkg::Gettext;
use Dpkg::BuildEnv;
use Dpkg::Control::Hash;
use base qw(Exporter);
......@@ -107,8 +108,8 @@ If that file doesn't exist, it returns undef.
sub get_current_vendor() {
my $f;
if ($ENV{'DEB_VENDOR'}) {
$f = get_vendor_info($ENV{'DEB_VENDOR'});
if (Dpkg::BuildEnv::has('DEB_VENDOR')) {
$f = get_vendor_info(Dpkg::BuildEnv::get('DEB_VENDOR'));
return $f->{'Vendor'} if defined $f;
}
$f = get_vendor_info();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment