diff options
author | Guillem Jover <guillem@debian.org> | 2016-08-18 05:41:54 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2016-10-30 04:44:14 +0100 |
commit | a8abe4885f8535a783bdb0c7188076a272dd6182 (patch) | |
tree | f400b8d021c3e96ef5d261fd2e4deb2aac8d299e | |
parent | 020460f5729775fcc5d7ac0a8289f87ce9732be0 (diff) | |
download | dpkg-a8abe4885f8535a783bdb0c7188076a272dd6182.tar.gz |
Dpkg::Substvars: Add new method set_field_substvars()
Refactor the ad-code in Dpkg::Control::HashCore to use this new method.
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | scripts/Dpkg/Control/HashCore.pm | 4 | ||||
-rw-r--r-- | scripts/Dpkg/Substvars.pm | 19 |
3 files changed, 21 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog index d8eeeeea6..e2d80fd54 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,6 +32,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium hooks. Prompted by Johannes Schauer <josch@debian.org>. - Make the Dpkg::Substavars parse() method return the number of substvars parsed. + - Add new set_field_substvars() method to Dpkg::Substvars. * Packaging: - Add liblocale-gettext-perl to libdpkg-perl Recommends. - Wrap and document dependency relationships. diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 46e3dfddd..e947d9179 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -402,9 +402,7 @@ sub apply_substvars { my ($self, $substvars, %opts) = @_; # Add substvars to refer to other fields - foreach my $f (keys %$self) { - $substvars->set_as_auto("F:$f", $self->{$f}); - } + $substvars->set_field_substvars($self, 'F'); foreach my $f (keys %$self) { my $v = $substvars->substvars($self->{$f}, %opts); diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 4104d18e8..db0e09f97 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -270,6 +270,23 @@ sub set_arch_substvars { $self->set('Arch', get_host_arch(), $attr); } +=item $s->set_field_substvars($ctrl, $prefix) + +Defines field variables from a Dpkg::Control object, with each variable +having the form "${$prefix:$field}". + +They will never be warned about when unused. + +=cut + +sub set_field_substvars { + my ($self, $ctrl, $prefix) = @_; + + foreach my $field (keys %{$ctrl}) { + $self->set_as_auto("$prefix:$field", $ctrl->{$field}); + } +} + =item $newstring = $s->substvars($string) Substitutes variables in $string and return the result in $newstring. @@ -407,6 +424,8 @@ Obsolete substvar: Emit an error on Source-Version substvar usage. New return: $s->parse() now returns the number of parsed substvars. +New method: $s->set_field_substvars(). + =head2 Version 1.04 (dpkg 1.18.0) New method: $s->filter(). |