my @tarfiles;
my $difffile;
my $debianfile;
+ my %vcsfiles;
my %seen;
for my $file (split(/\n /, $files)) {
- next if $file eq '';
- $file =~ m/^([0-9a-f]{32})[ \t]+(\d+)[ \t]+([0-9a-zA-Z][-+:.,=0-9a-zA-Z_~]+)$/
- || error(_g("Files field contains bad line `%s'"), $file);
- ($md5sum{$3},$size{$3},$file) = ($1,$2,$3);
+ next if $file eq '';
+ $file =~ m/^($check_regex{md5}) # checksum
+ [ \t]+(\d+) # size
+ [ \t]+($rx_fname) # filename
+ $/x
+ || error(_g("Files field contains bad line `%s'"), $file);
+ (my $md5sum,$size{$3},$file) = ($1,$2,$3);
+ if (exists($checksum{$file}{md5})
+ and $checksum{$file}{md5} ne $md5sum) {
+ error(_g("Conflicting checksums \`%s\' and \`%s' for file \`%s'"),
+ $checksum{$file}{md5}, $md5sum, $file);
+ }
+ $checksum{$file}{md5} = $md5sum;
+
local $_ = $file;
error(_g("Files field contains invalid filename `%s'"), $file)
my ($fields, $filename)= @_;
$added_files{$filename}++ &&
internerr(_g("tried to add file `%s' twice"), $filename);
- stat($filename) || syserr(_g("could not stat output file `%s'"), $filename);
- my $size = (stat _)[7];
- my $md5sum= `md5sum <$filename`;
- $? && &subprocerr("md5sum $filename");
- $md5sum = readmd5sum( $md5sum );
- $fields->{'Files'}.= "\n $md5sum $size $filename";
- }
-
- sub readmd5sum {
- (my $md5sum = shift) or return;
- $md5sum =~ s/^([0-9a-f]{32})\s*\*?-?\s*\n?$/$1/o
- || failure(_g("md5sum gave bogus output `%s'"), $md5sum);
- return $md5sum;
+ my (%sums, $size);
+ getchecksums($filename, \%sums, \$size);
+ foreach my $alg (sort keys %sums) {
+ $fields->{"Checksums-$alg"} .= "\n $sums{$alg} $size $filename";
+ }
+ $fields->{'Files'}.= "\n $sums{md5} $size $filename";
}
-# replace \ddd with their corresponding character, refuse \ddd > \377
-# modifies $_ (hs)
-{
- my $backslash;
-sub deoctify {
- my $fn= $_[0];
- $backslash= sprintf("\\%03o", unpack("C", "\\")) if !$backslash;
-
- s/\\{2}/$backslash/g;
- @_= split(/\\/, $fn);
-
- foreach (@_) {
- /^(\d{3})/ or next;
- failure(_g("bogus character `\\%s' in `%s'") . "\n", $1, $fn)
- if oct($1) > 255;
- $_= pack("c", oct($1)) . $POSTMATCH;
- }
- return join("", @_);
-} }
-