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