On 08/17/2011 04:35 AM, Raphael Hertzog wrote:
On Tue, 16 Aug 2011, Anders Kaseorg wrote:
+sub md5sums_path
+{
+ # Calling dpkg-query --control-path for every package is too slow,
+ # so we cheat a little bit.
+
+ my ($path) = @_;
+ return "$DPKG/info/$path.md5sums" if -e "$DPKG/info/$path.list";
+ return "$DPKG/info/$path:$arch.md5sums" if $path !~ /:/ and -e
"$DPKG/info/$path:$arch.list";
+ die "Cannot find md5sums path for $path\n";
+}
You're only returning the path of an existing file, or you're dying...
I return the path of an .md5sums file if the corresponding .list file
exists. That should be fine for installed packages even if they have no
.md5sums file, and debsums only works on installed packages.
I did find a different bug in this heuristic, though. A Multi-Arch:
foreign package of a different architecture uses package.md5sums instead
of package:arch.md5sums, even though ${PackageSpec} is package:arch.
Here’s an updated patch 1.
Anders
>From 4fd2785923db9eec66590b2ada881262f63844e8 Mon Sep 17 00:00:00 2001
From: Anders Kaseorg <ande...@mit.edu>
Date: Fri, 8 Jul 2011 02:52:22 -0400
Subject: [PATCH 1/6] Read and write .md5sums files at multiarch paths when
needed
Signed-off-by: Anders Kaseorg <ande...@mit.edu>
---
debsums | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/debsums b/debsums
index 855fbf7..b2ade36 100755
--- a/debsums
+++ b/debsums
@@ -151,6 +151,8 @@ my @debpath = '.';
@debpath = map +(length) ? $_ : '.', split /:/, $debpath, -1 if $debpath;
my $arch;
+chomp ($arch = `/usr/bin/dpkg --print-architecture`);
+
my %generate;
if ($gen_opt)
{
@@ -172,8 +174,6 @@ if ($gen_opt)
$generate{missing}++ unless $generate{all} or $generate{missing};
$generate{keep}++ if $generate{nocheck};
- chomp ($arch = `/usr/bin/dpkg --print-architecture`);
-
# ensure generated files are world readable
umask 022;
}
@@ -254,6 +254,23 @@ sub dpkg_cmp
!system '/usr/bin/dpkg', '--compare-versions', $ver, $op, $testver;
}
+sub md5sums_path
+{
+ # Calling dpkg-query --control-path for every package is too slow,
+ # so we cheat a little bit.
+
+ my ($path) = @_;
+ if (-e "$DPKG/info/$path.list") {
+ return "$DPKG/info/$path.md5sums";
+ } elsif ($path !~ /:/ and -e "$DPKG/info/$path:$arch.list") {
+ return "$DPKG/info/$path:$arch.md5sums";
+ } elsif ($path =~ /^(.*):/ and -e "$DPKG/info/$1.list") {
+ return "$DPKG/info/$1.md5sums";
+ } else {
+ die "Cannot find md5sums path for $path\n";
+ }
+}
+
sub is_replaced
{
my ($pack, $path, $sum) = @_;
@@ -273,7 +290,7 @@ sub is_replaced
for my $p (@{$installed{$pack}{ReplacedBy} || []})
{
- open S, "$DPKG/info/$p.md5sums" or next;
+ open S, md5sums_path($p) or next;
while (<S>)
{
if ($_ eq "$sum $path\n")
@@ -460,7 +477,7 @@ for (@ARGV)
}
else
{
- $sums = "$DPKG/info/$pack.md5sums";
+ $sums = md5sums_path($pack);
unless (-f $sums or $config)
{
if ($missing)
@@ -626,7 +643,7 @@ for (@ARGV)
if ($generate{keep})
{
- my $target = "$DPKG/info/$pack.md5sums";
+ my $target = md5sums_path($pack);
copy $sums, $target
or die "$self: can't copy sums to $target ($!)\n";
}
--
1.7.6