Package: apt-file Version: 2.0.8.1 Severity: normal Tags: patch Hi,
Attached is the diff for my (proposed) apt-file 2.0.8.2 NMU. It is a cut down version of the previous patch for #382312, that is limited to closing #382312 (and updating the Version String). Since I am not a DD I can't upload this NMU myself. If I don't hear from you soon I will try and find a DD who is willing to sponsor this upload. Note, that I have made this NMU version 2.0.8.2, following the precedent set by the previous NMU. regards Kevin
diff -Nru /tmp/QNYq976uyZ/apt-file-2.0.8.1/apt-file /tmp/wdoamkvcx0/apt-file-2.0.8.2/apt-file --- /tmp/QNYq976uyZ/apt-file-2.0.8.1/apt-file 2006-10-27 13:32:44.000000000 -0500 +++ /tmp/wdoamkvcx0/apt-file-2.0.8.2/apt-file 2006-11-06 16:36:53.000000000 -0600 @@ -28,7 +28,7 @@ use Data::Dumper; use File::Basename; use AptPkg::Config '$_config'; -use constant VERSION => "2.0.7"; +use constant VERSION => "2.0.8.2"; my $Conf; @@ -206,6 +206,32 @@ } } +sub print_winners ($$) { + my ($db, $matchfname) = @_; + my $filtered_db; + + # $db is a hash from package name to array of file names. It is + # a superset of the matching cases, so first we filter this by the + # real pattern. + foreach my $key (keys %$db) { + if ($matchfname || ($key =~ /$Conf->{pattern}/)) { + $filtered_db->{$key} = $db->{$key}; + } + } + + # Now print the winners + if (!defined $Conf->{package_only}) { + foreach my $key (sort keys %$filtered_db) { + foreach (sort @{$filtered_db->{$key}}) { + print "$key: $_\n"; + } + } + } else { + print map {"$_\n"} (sort keys %$filtered_db); + } + exit 0; +} + sub do_grep($$) { my ($data, $pattern) = @_; my $ret; @@ -231,17 +257,7 @@ close ZCAT; debug_line "\n"; } - $ret = reverse_hash($ret); - if (!defined $Conf->{package_only}) { - foreach my $key (sort keys %$ret) { - foreach (sort @{unique $ret->{$key}}) { - print "$key: $_\n"; - } - } - } else { - print map {"$_\n"} (sort keys %$ret); - } - exit 0; + return reverse_hash($ret); } sub grep_file($) { @@ -253,21 +269,24 @@ ")" : '[^\s]*)', '\s+(\S+)\s*$', ); - do_grep $data, $pattern; + my $ret = do_grep $data, $pattern; + print_winners $ret, 1; } sub grep_package($) { my $data = shift; + # File name may contain spaces, so match template is + # ($fname, $pkgs) = (line =~ '^\s*(.*?)\s+(\S+)\s*$') my $pattern = join "", ( - '^(\S+)\s+', + '^\s*(.*?)\s+', '(\S*/', $Conf->{pattern}, defined $Conf->{fixed_strings} ? - "" : ".*", - ")", - '$', + '(,\S*|)' : '\S*', + ')\s*$', ); - do_grep $data, $pattern; + my $ret = do_grep $data, $pattern; + print_winners $ret, 0; } sub purge_cache($) { diff -Nru /tmp/QNYq976uyZ/apt-file-2.0.8.1/debian/changelog /tmp/wdoamkvcx0/apt-file-2.0.8.2/debian/changelog --- /tmp/QNYq976uyZ/apt-file-2.0.8.1/debian/changelog 2006-10-27 13:38:03.000000000 -0500 +++ /tmp/wdoamkvcx0/apt-file-2.0.8.2/debian/changelog 2006-11-06 16:53:59.000000000 -0600 @@ -1,3 +1,20 @@ +apt-file (2.0.8.2) unstable; urgency=low + + * Non-maintainer upload. + * The Contents.gz files map a file to the list of packages that + contain it. do_grep grabs all these packages, this fix + post-processes its result so that we only print out the packages + that do match the given pattern. Also, take account that a file + name may have spaces and avoid false positives by tightening the + grep pattern. NOTE: this is a minimal NMU patch to close + important bug #382312 (it also closes two similar bugs). + There is a more complete patch available in the bts for + #382312 that I think would make apt-file much more useful and + closes other bugs. (Closes: #382312, #376607, #358821) + * Updated Version String to 2.0.8.2 (Closes: #376458) + + -- Kevin Glynn <[EMAIL PROTECTED]> Mon, 6 Nov 2006 15:47:57 -0600 + apt-file (2.0.8.1) unstable; urgency=low * Non-maintainer upload by Gunnar Wolf