| 1 |
#!/usr/bin/perl |
| 2 |
use warnings; |
| 3 |
use strict; |
| 4 |
use integer; |
| 5 |
use FindBin; |
| 6 |
|
| 7 |
our @kind = ( |
| 8 |
{ cmd => 'md5sum' , name => undef }, |
| 9 |
{ cmd => 'sha1sum' , name => 'Sha1' }, |
| 10 |
{ cmd => 'sha256sum', name => 'Sha256' }, |
| 11 |
); |
| 12 |
|
| 13 |
my @saved_line; |
| 14 |
sub getline { |
| 15 |
my ($lineref) = @_; |
| 16 |
$_ = @saved_line ? pop(@saved_line) : shift @$lineref; |
| 17 |
return defined; |
| 18 |
} |
| 19 |
sub ungetline { push @saved_line, $_; return; } |
| 20 |
|
| 21 |
local $/ = ''; |
| 22 |
while (<>) { |
| 23 |
1 while chomp; $_ .= "\n"; |
| 24 |
my (@line) = /(.*)\n/g; |
| 25 |
my $dir; |
| 26 |
for (@line) { |
| 27 |
if (/^Directory:\s*(\S+)/) { |
| 28 |
$dir = $1; |
| 29 |
} |
| 30 |
} |
| 31 |
defined $dir or die "$0: missing Directory field\n"; |
| 32 |
while (getline \@line) { |
| 33 |
print "$_\n"; |
| 34 |
if (/^Files:\s*$/) { |
| 35 |
my @file; |
| 36 |
while (getline \@line) { |
| 37 |
if (/^\S/) { |
| 38 |
ungetline(); |
| 39 |
last; |
| 40 |
} |
| 41 |
s/^.*?(\S+)\s*$/$1/; |
| 42 |
push @file, $_; |
| 43 |
} |
| 44 |
for my $kind (@kind) { |
| 45 |
print "Checksums-$kind->{name}:\n" if defined $kind->{name}; |
| 46 |
for (@file) { |
| 47 |
my $cmd = "${FindBin::RealBin}/calculate-sum " |
| 48 |
. "Sources $kind->{cmd} debian/$dir/$_"; |
| 49 |
print `$cmd`; |
| 50 |
#print "$cmd\n"; |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
print "\n"; |
| 56 |
} |