[dh-make-perl] 01/05: only try to (re)create Contents.cache if we have Contents files

gregor herrmann gregoa at debian.org
Fri Mar 25 02:43:00 UTC 2016


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

gregoa pushed a commit to branch gregoa/apt-file-3
in repository dh-make-perl.

commit 02793ae7101cb641170240d384e11ffe7f54eccc
Author: gregor herrmann <gregoa at debian.org>
Date:   Fri Mar 25 02:58:03 2016 +0100

    only try to (re)create Contents.cache if we have Contents files
    
    Gbp-Dch: Ignore
---
 lib/Debian/AptContents.pm | 80 ++++++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 39 deletions(-)

diff --git a/lib/Debian/AptContents.pm b/lib/Debian/AptContents.pm
index 982778f..5bf6705 100644
--- a/lib/Debian/AptContents.pm
+++ b/lib/Debian/AptContents.pm
@@ -210,46 +210,48 @@ sub read_cache {
     }
 
     unless ($cache) {
-        $self->source('parsed files');
-        $cache->{stamp}          = time;
-        $cache->{contents_files} = [];
-        $cache->{apt_contents}   = {};
-
-        push @{ $cache->{contents_files} }, @{ $self->contents_files };
-        my @cat_cmd = (
-            '/usr/lib/apt/apt-helper', 'cat-file', @{ $self->contents_files }
-        );
-        open( my $f, "-|", @cat_cmd )
-            or die
-            "Can't run '/usr/lib/apt/apt-helper cat-file' on Contents files: $!\n";
-
-        $self->warning( 1,
-            "Parsing Contents files:\n\t"
-                . join( "\n\t", @{ $self->contents_files } ) );
-        my $line;
-        while ( defined( $line = $f->getline ) ) {
-            my ( $file, $packages ) = split( /\s+/, $line );
-            next unless $file =~ s{
-                ^usr/
-                (?:share|lib)/
-                (?:perl\d+/            # perl5/
-                | perl/(?:\d[\d.]+)/   # or perl/5.10/
-                )
-            }{}x;
-            $cache->{apt_contents}{$file} = exists $cache->{apt_contents}{$file}
-                ? $cache->{apt_contents}{$file}.','.$packages
-                : $packages;
-
-            # $packages is a comma-separated list of
-            # section/package items. We'll parse it when a file
-            # matches. Otherwise we'd parse thousands of entries,
-            # while checking only a couple
-        }
-        close($f);
+        if ( scalar @{ $self->contents_files } ) {
+            $self->source('parsed files');
+            $cache->{stamp}          = time;
+            $cache->{contents_files} = [];
+            $cache->{apt_contents}   = {};
+
+            push @{ $cache->{contents_files} }, @{ $self->contents_files };
+            my @cat_cmd = (
+                '/usr/lib/apt/apt-helper', 'cat-file', @{ $self->contents_files }
+            );
+            open( my $f, "-|", @cat_cmd )
+                or die
+                "Can't run '/usr/lib/apt/apt-helper cat-file' on Contents files: $!\n";
+
+            $self->warning( 1,
+                "Parsing Contents files:\n\t"
+                    . join( "\n\t", @{ $self->contents_files } ) );
+            my $line;
+            while ( defined( $line = $f->getline ) ) {
+                my ( $file, $packages ) = split( /\s+/, $line );
+                next unless $file =~ s{
+                    ^usr/
+                    (?:share|lib)/
+                    (?:perl\d+/            # perl5/
+                    | perl/(?:\d[\d.]+)/   # or perl/5.10/
+                    )
+                }{}x;
+                $cache->{apt_contents}{$file} = exists $cache->{apt_contents}{$file}
+                    ? $cache->{apt_contents}{$file}.','.$packages
+                    : $packages;
+
+                # $packages is a comma-separated list of
+                # section/package items. We'll parse it when a file
+                # matches. Otherwise we'd parse thousands of entries,
+                # while checking only a couple
+            }
+            close($f);
 
-        if ( %{ $cache->{apt_contents} } ) {
-            $self->cache($cache);
-            $self->store_cache;
+            if ( %{ $cache->{apt_contents} } ) {
+                $self->cache($cache);
+                $self->store_cache;
+            }
         }
     }
     else {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/dh-make-perl.git



More information about the Pkg-perl-cvs-commits mailing list