diff options
author | Modestas Vainius <modestas@vainius.eu> | 2011-03-11 01:23:37 +0200 |
---|---|---|
committer | Modestas Vainius <modestas@vainius.eu> | 2011-03-11 01:43:47 +0200 |
commit | 0fd7f222fe80115d28a325998f5c8f4ed6882221 (patch) | |
tree | 5a71fabaeccf3c48fdf4921dca6286f87c02041a /qt-kde-team/2 | |
parent | 25a6d38c759f40157c077d0512c1950cebb6548a (diff) | |
download | pkg-kde-tools-0fd7f222fe80115d28a325998f5c8f4ed6882221.tar.gz |
Do not lose environment changes when remaking dhmk_rules.mk.
dhmk.pl could have failed to detect environment changes made by dh addons when
remaking dhmk_rules.mk. That's due to the fact that make tries to remake
included snippets after including their old versions. Thus environment changes
would already been made by old dhmk_rules.mk by the time dh addons and dhmk.pl
the reevaluate environment.
The problem is solved by restoring changed environment variables to their
original values before remaking dhmk_rules.mk.
Diffstat (limited to 'qt-kde-team/2')
-rwxr-xr-x | qt-kde-team/2/dhmk.pl | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/qt-kde-team/2/dhmk.pl b/qt-kde-team/2/dhmk.pl index 0a2b0fd..28d7978 100755 --- a/qt-kde-team/2/dhmk.pl +++ b/qt-kde-team/2/dhmk.pl @@ -147,13 +147,7 @@ sub load_addons { foreach my $e (keys %ENV) { if (!exists $oldenv{$e} || (($ENV{$e} || "") ne ($oldenv{$e} || ""))) { - $env_changes{$e} = $ENV{$e}; - } - } - foreach my $e (keys %oldenv) { - if (!exists $ENV{$e}) { - # Environment variable was delete - $env_changes{$e} = undef; + $env_changes{$e} = { old => $oldenv{$e}, new => $ENV{$e} }; } } @@ -350,20 +344,24 @@ sub get_override_info { return \%overrides; } -sub write_envvar { +sub write_definevar { my ($fh, $name, $value, $escape) = @_; $escape = 1 if !defined $escape; if ($value) { $value =~ s/\$/\$\$/g if $escape; - print $fh "define $name", "\n", $value, "\n", "endef", "\n"; - print $fh "export $name", "\n"; } else { - print $fh "export $name =", "\n"; + print $fh "$name =", "\n"; } } +sub write_exportvar { + my ($fh, $name,$export) = @_; + $export = "export" if !defined $export; + print $fh "$export $name", "\n"; +} + sub write_dhmk_rules { my ($dhmk_file, $rules_file, $targets, $overrides, $extraopts, $env_changes) = @_; @@ -398,14 +396,24 @@ sub write_dhmk_rules { # overrides) if ($extraopts) { print $fh "# Export specified extra options for debhelper programs", "\n"; - write_envvar($fh, "DHMK_OPTIONS", $extraopts, 0); + write_definevar($fh, "DHMK_OPTIONS", $extraopts, 0); + write_exportvar($fh, "DHMK_OPTIONS"); print $fh "\n"; } if (keys %$env_changes) { print $fh "# Export environment changes", "\n"; foreach my $e (keys %$env_changes) { - write_envvar($fh, $e, $env_changes->{$e}); + print $fh "dhmk_envvar_orig_$e := \$($e)\n"; + if (defined ($env_changes->{$e}{new})) { + write_definevar($fh, $e, $env_changes->{$e}{new}); + } else { + write_export($fh, $e, "unexport"); + } + } + # Restore all modified environment variables when remaking $dhmk_file + foreach my $e (keys %$env_changes) { + print $fh "$dhmk_file: $e = \$(dhmk_envvar_orig_$e)", "\n"; } print $fh "\n"; } |