diff options
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Control/HashCore.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Substvars.pm | 28 |
3 files changed, 26 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog index b99c0c0d1..4cc662ead 100644 --- a/debian/changelog +++ b/debian/changelog @@ -72,6 +72,8 @@ dpkg (1.17.11) UNRELEASED; urgency=low dpkg-dev and gcc. Closes: #751363 * Update i386 architecture GNU cpu regex in cputable to match i786 too. * Remove unused pkglibdir variable from libdpkg.pc.in. + * Perl modules: + - Add new set_as_auto() method to Dpkg::Substvars. [ Updated programs translations ] * Danish (Joe Dalton). Closes: #754127 diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 83d3bbbe4..b23a77cea 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -397,7 +397,7 @@ sub apply_substvars { # Add substvars to refer to other fields foreach my $f (keys %$self) { - $substvars->set_as_used("F:$f", $self->{$f}); + $substvars->set_as_auto("F:$f", $self->{$f}); } foreach my $f (keys %$self) { diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 51b81b683..afd4c574e 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -19,7 +19,7 @@ package Dpkg::Substvars; use strict; use warnings; -our $VERSION = '1.02'; +our $VERSION = '1.03'; use Dpkg (); use Dpkg::Arch qw(get_host_arch); @@ -48,6 +48,7 @@ strings. use constant { SUBSTVAR_ATTR_USED => 1, + SUBSTVAR_ATTR_AUTO => 2, }; =head1 METHODS @@ -85,7 +86,7 @@ sub new { $self->{vars}{'dpkg:Upstream-Version'} =~ s/-[^-]+$//; bless $self, $class; - my $attr = SUBSTVAR_ATTR_USED; + my $attr = SUBSTVAR_ATTR_USED | SUBSTVAR_ATTR_AUTO; $self->{attr}{$_} = $attr foreach keys %{$self->{vars}}; if ($arg) { $self->load($arg) if -e $arg; @@ -121,6 +122,19 @@ sub set_as_used { $self->set($key, $value, SUBSTVAR_ATTR_USED); } +=item $s->set_as_auto($key, $value) + +Add/replace a substitution and mark it as used and automatic (no warnings +will be produced even if unused). + +=cut + +sub set_as_auto { + my ($self, $key, $value) = @_; + + $self->set($key, $value, SUBSTVAR_ATTR_USED | SUBSTVAR_ATTR_AUTO); +} + =item $s->get($key) Get the value of a given substitution. @@ -217,7 +231,7 @@ sub set_version_substvars { my $upstreamversion = $sourceversion; $upstreamversion =~ s/-[^-]*$//; - my $attr = SUBSTVAR_ATTR_USED; + my $attr = SUBSTVAR_ATTR_USED | SUBSTVAR_ATTR_AUTO; $self->set('binary:Version', $binaryversion, $attr); $self->set('source:Version', $sourceversion, $attr); @@ -238,7 +252,7 @@ This will never be warned about when unused. sub set_arch_substvars { my ($self) = @_; - my $attr = SUBSTVAR_ATTR_USED; + my $attr = SUBSTVAR_ATTR_USED | SUBSTVAR_ATTR_AUTO; $self->set('Arch', get_host_arch(), $attr); } @@ -336,7 +350,7 @@ sub output { my $str = ''; # Store all non-automatic substitutions only foreach my $vn (sort keys %{$self->{vars}}) { - next if /^(?:(?:dpkg|source|binary):(?:Source-)?Version|Space|Tab|Newline|Arch|Source-Version|F:.+)$/; + next if $self->{attr}{$vn} & SUBSTVAR_ATTR_AUTO; my $line = "$vn=" . $self->{vars}{$vn} . "\n"; print { $fh } $line if defined $fh; $str .= $line; @@ -348,6 +362,10 @@ sub output { =head1 CHANGES +=head2 Version 1.03 + +New method: $s->set_as_auto(). + =head2 Version 1.02 New argument: Accept a $binaryversion in $s->set_version_substvars(), |