[dpkg] 80/187: Dpkg::Substvars: Add new method set_field_substvars()

Reiner Herrmann reiner at reiner-h.de
Sun Nov 6 12:46:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

deki-guest pushed a commit to branch master
in repository dpkg.

commit a8abe4885f8535a783bdb0c7188076a272dd6182
Author: Guillem Jover <guillem at debian.org>
Date:   Thu Aug 18 05:41:54 2016 +0200

    Dpkg::Substvars: Add new method set_field_substvars()
    
    Refactor the ad-code in Dpkg::Control::HashCore to use this new method.
---
 debian/changelog                 |  1 +
 scripts/Dpkg/Control/HashCore.pm |  4 +---
 scripts/Dpkg/Substvars.pm        | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d8eeeee..e2d80fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
       hooks. Prompted by Johannes Schauer <josch at 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 46e3dfd..e947d91 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 4104d18..db0e09f 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().

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list