Package: dh-make-perl Version: 0.84-2 Severity: normal Tags: patch Dear Maintainer,
I recently noticed that the dependency resolution does not find existing Debian packages anymore when it is done using Debian::AptContents. One example is a Perl distribution that uses Catalyst::Runtime, which resulted in a dependency on libcatalyst-runtime-perl (caused by falling back to CPAN-based dependency resolution), even though Catalyst::Runtime is part of the libcatalyst-perl package available in Debian. After adding some debug code to dh-make-perl and looking at Contents.cache, I noticed that a lot of files never made it into the cache. Then I noticed that Debian::AptContents attempts to skip the header in Contents files, which is not contained in current Contents files in the archive anymore (which likely is a change that became visible for Jessie during the recent point release, the main bug regarding this seems to be #841997 [1], and there already is #842887 [2] in dh-make-perl, which is somewhat related). This change in the Contents files does not affect current versions of dh-make-perl, but caused a regression in the version of dh-make-perl in Jessie. The attached patch fixed the problem for me. Kind regards Manfred [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841997 [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=842887 -- System Information: Debian Release: 8.7 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 4.8.0-0.bpo.2-amd64 (SMP w/4 CPU cores) Locale: LANG=de_CH.utf8, LC_CTYPE=de_CH.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages dh-make-perl depends on: ii debhelper 9.20150101+deb8u2 ii dpkg-dev 1.17.27 ii fakeroot 1.20.2-1 ii libapt-pkg-perl 0.1.29+b2 ii libarray-unique-perl 0.08-1 ii libclass-accessor-perl 0.34-1 ii libcpan-meta-perl 2.142690-1 ii libdpkg-perl 1.17.27 ii libemail-address-perl 1.905-2 ii libemail-date-format-perl 1.005-1 ii libfile-which-perl 1.09-1 ii liblist-moreutils-perl 0.33-2+b1 ii libmodule-depends-perl 0.16-1 ii libparse-debcontrol-perl 2.005-4 ii libparse-debianchangelog-perl 1.2.0-1.1 ii libsoftware-license-perl 0.103010-3 ii libtie-ixhash-perl 1.23-1 ii libwww-mechanize-perl 1.73-2 ii libyaml-libyaml-perl 0.41-6 ii libyaml-perl 1.13-1 ii make 4.0-8.1 ii perl 5.20.2-3+deb8u6 ii perl-modules [libcpan-meta-perl] 5.20.2-3+deb8u6 Versions of packages dh-make-perl recommends: ii apt-file 2.5.4 ii git 1:2.1.4-2.1+deb8u2 ii pristine-tar 1.33 dh-make-perl suggests no packages. -- debconf-show failed
>From d18535572869a6a3e526bfb4ad08e667ce479c71 Mon Sep 17 00:00:00 2001 From: Manfred Stock <[email protected]> Date: Thu, 19 Jan 2017 09:34:13 +0100 Subject: [PATCH] Support Contents files without header Current versions of the Contents files in the Debian archive don't seem to contain a header anymore, which kind-of breaks the parser, as it only processed lines after the line matched by the regular expression ^FILE\s+LOCATION. Since the regular expression which is used to parse the file column of the Contents files looks robust enough, it seems like this check can be dropped (which gets done in a rather unrelated change in dh-make-perl commit 885b31c44b4a61d6f6ca44d3335c20506ab41ee9, too, so current versions are not affected by this problem). --- lib/Debian/AptContents.pm | 38 ++++++++++------------- t/AptContents.t | 16 +++++++++- t/contents/sources.list | 1 + t/contents/test_debian_dists_stable_main_Contents | 2 ++ 4 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 t/contents/test_debian_dists_stable_main_Contents diff --git a/lib/Debian/AptContents.pm b/lib/Debian/AptContents.pm index e47af51..5844847 100644 --- a/lib/Debian/AptContents.pm +++ b/lib/Debian/AptContents.pm @@ -315,30 +315,24 @@ sub read_cache { } $self->warning( 1, "Parsing $_ ..." ); - my $capturing = 0; my $line; while ( defined( $line = $f->getline ) ) { - if ($capturing) { - 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 - } - else { - $capturing = 1 if $line =~ /^FILE\s+LOCATION/; - } + 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 } } diff --git a/t/AptContents.t b/t/AptContents.t index 4aec946..9348e49 100755 --- a/t/AptContents.t +++ b/t/AptContents.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 26; +use Test::More tests => 29; BEGIN { use_ok 'Debian::AptContents'; @@ -125,6 +125,8 @@ $apt_contents = instance(); is( $apt_contents->source, 'cache', 'cache was used' ); +is(scalar keys %{$apt_contents->cache()->{apt_contents}}, 185, 'all Perl-related Contents lines read'); + sleep(1); # allow the clock to tick so the timestamp actually differs touch( glob "$Bin/contents/*Contents*" ); @@ -143,6 +145,7 @@ is( $apt_contents->find_perl_module_package('Moose') . '', is_deeply( $apt_contents->get_contents_files, [ "$Bin/contents/test_debian_dists_sid_main_Contents", + "$Bin/contents/test_debian_dists_stable_main_Contents", "$Bin/contents/test_debian_dists_testing_main_Contents" ] ); @@ -159,6 +162,17 @@ is( $apt_contents->find_perl_module_package('GD') . '', ); is_deeply( + [ $apt_contents->find_file_packages('Catalyst/Runtime.pm') ], + [ 'libcatalyst-perl' ], + "Catalyst/Runtime.pm is in libcatalyst-perl" +); + +is( $apt_contents->find_perl_module_package('Catalyst::Runtime') . '', + 'libcatalyst-perl', + 'Catalyst::Runtime found by module name' +); + +is_deeply( [ $apt_contents->find_file_packages('Image/Magick.pm') ], [ 'perlmagick', 'graphicsmagick-libmagick-dev-compat' ], "Image/Magick.pm in perlmagick and graphicsmagick-libmagick-dev-compat, but different paths" diff --git a/t/contents/sources.list b/t/contents/sources.list index bb7f14b..f7a11d4 100644 --- a/t/contents/sources.list +++ b/t/contents/sources.list @@ -3,6 +3,7 @@ deb http://test/debian sid main deb http://test/debian testing main deb http://test/debian testing main +deb http://test/debian stable main deb http://security.debian.org/ stable/updates main contrib non-free deb http://www.toastfreeware.priv.at/debian stable/ deb http://www.kiberpipa.org/~minmax/cinelerra/builds/sid/ ./ diff --git a/t/contents/test_debian_dists_stable_main_Contents b/t/contents/test_debian_dists_stable_main_Contents new file mode 100644 index 0000000..d3b8354 --- /dev/null +++ b/t/contents/test_debian_dists_stable_main_Contents @@ -0,0 +1,2 @@ +bin/afio utils/afio +usr/share/perl5/Catalyst/Runtime.pm perl/libcatalyst-perl -- 2.1.4

