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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=5d4ab4ae7d11c736bdabb51af4bc7e66c69cdd23

commit 5d4ab4ae7d11c736bdabb51af4bc7e66c69cdd23
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Sat Dec 29 12:32:26 2018 +0100

    dpkg-scanpackages: Do not compute unnecessary checksums
    
    When we specify a --hash argument we should not compute all checksums to
    then discard them.
    
    Closes: #916456
    Based-on-patch-by: Chris Lamb <la...@debian.org>
---
 debian/changelog             |  3 +++
 scripts/dpkg-scanpackages.pl | 11 +++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 075fff395..b244c8d3b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,9 @@ dpkg (1.19.3) UNRELEASED; urgency=medium
   * dpkg-genchanges: Only reference binary packages being uploaded, which
     means that for a source-only upload, the Binary and Description fields
     should be empty. Closes: #818618
+  * dpkg-scanpackages: Do not compute unnecessary checksums when using the
+    --hash argument. Based on a patch by Chris Lamb <la...@debian.org>.
+    Closes: #916456
   * Perl modules:
     - Dpkg::Changelog::Debian: Preserve modelines at EOF. Closes: #916056
       Thanks to Chris Lamb <la...@debian.org> for initial test cases.
diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl
index 05710ae69..dd4308641 100755
--- a/scripts/dpkg-scanpackages.pl
+++ b/scripts/dpkg-scanpackages.pl
@@ -41,7 +41,7 @@ my (@samemaint, @changedmaint);
 my @spuriousover;
 my %packages;
 my %overridden;
-my %hash;
+my @checksums;
 
 my %options = (help            => sub { usage(); exit 0; },
               version         => sub { version(); exit 0; },
@@ -196,10 +196,8 @@ sub process_deb {
     $fields->{'Filename'} = "$pathprefix$fn";
 
     my $sums = Dpkg::Checksums->new();
-    $sums->add_from_file($fn);
-    foreach my $alg (checksums_get_list()) {
-        next if %hash and not $hash{$alg};
-
+    $sums->add_from_file($fn, checksums => \@checksums);
+    foreach my $alg (@checksums) {
         if ($alg eq 'md5') {
             $fields->{'MD5sum'} = $sums->get_checksum($fn, $alg);
         } else {
@@ -223,13 +221,14 @@ if (not (@ARGV >= 1 and @ARGV <= 3)) {
 
 my $type = $options{type} // 'deb';
 my $arch = $options{arch};
-%hash = map { $_ => 1 } split /,/, $options{hash} // '';
+my %hash = map { $_ => 1 } split /,/, $options{hash} // '';
 
 foreach my $alg (keys %hash) {
     if (not checksums_is_supported($alg)) {
         usageerr(g_('unsupported checksum \'%s\''), $alg);
     }
 }
+@checksums = %hash ? keys %hash : checksums_get_list();
 
 my ($binarypath, $override, $pathprefix) = @ARGV;
 

-- 
Dpkg.Org's dpkg

Reply via email to