1999-11-11 16:10:37 -01:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
2001-07-10 14:42:54 +00:00
|
|
|
use Digest::MD5;
|
1999-11-11 16:10:37 -01:00
|
|
|
|
|
|
|
my $mirror = shift || $ENV{'MIRROR'};
|
|
|
|
my $nonus = shift || $ENV{'NONUS'};
|
2002-07-11 21:40:17 +00:00
|
|
|
my $security = shift || $ENV{'SECURITY'};
|
1999-11-11 16:10:37 -01:00
|
|
|
my ($p, $filename, $size, $md5sum, $file) = ('', '', 0, '', '');
|
|
|
|
|
|
|
|
my $ok = 1;
|
|
|
|
my ($ctx, $digest);
|
|
|
|
|
|
|
|
$/=''; # Browse paragraph by paragraph
|
|
|
|
|
|
|
|
while (defined($_ = <>)) {
|
|
|
|
# Get the infos about a package
|
2000-11-12 21:41:45 -01:00
|
|
|
m/^Package: (\S+)/mi and $p = $1;
|
|
|
|
m/^Size: (\d+)/mi and $size = $1;
|
2000-09-05 23:12:54 +00:00
|
|
|
m/^Filename: (\S+)/mi and $filename = $1;
|
2000-11-12 21:41:45 -01:00
|
|
|
m/^MD5sum: (\S+)/mi and $md5sum = $1;
|
1999-11-11 16:10:37 -01:00
|
|
|
|
|
|
|
next if not $p;
|
|
|
|
|
2002-07-11 21:40:17 +00:00
|
|
|
$file = ( ( -e "$mirror/$filename" ) ? "$mirror/$filename" :
|
2004-05-17 22:30:58 +00:00
|
|
|
( exists $ENV{LOCALDEBS} && -e "$ENV{LOCALDEBS}/$filename" ) ? "$ENV{LOCALDEBS}/$filename" :
|
2002-07-11 21:40:17 +00:00
|
|
|
( -e "$nonus/$filename" ) ? "$nonus/$filename" :
|
|
|
|
"$security/$filename" );
|
1999-11-11 16:10:37 -01:00
|
|
|
|
|
|
|
# Check if the file exists
|
|
|
|
if (! -e $file) {
|
|
|
|
print STDERR "File $filename can't be found ...\n";
|
|
|
|
$ok = 0;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check for the size
|
|
|
|
if (-s _ != $size) {
|
|
|
|
print STDERR "The size doesn't match for $file.\n";
|
|
|
|
print STDERR "It's `@{ [ -s _ ]}' instead of `$size'.\n";
|
|
|
|
$ok = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Compute the MD5sum
|
|
|
|
open(FILE, "< $file") || die "Can't open $file : $!\n";
|
2001-07-10 14:42:54 +00:00
|
|
|
$ctx = Digest::MD5->new;
|
1999-11-11 16:10:37 -01:00
|
|
|
$ctx->addfile(*FILE);
|
|
|
|
$digest = $ctx->hexdigest;
|
|
|
|
undef $ctx;
|
|
|
|
close FILE;
|
|
|
|
|
|
|
|
# Check the MD5sum
|
|
|
|
if ($digest ne $md5sum) {
|
|
|
|
print STDERR "MD5sum does not match for $file ...\n";
|
|
|
|
print STDERR "It's `$digest' instead of `$md5sum'.\n";
|
|
|
|
$ok = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ok) {
|
|
|
|
exit 0;
|
|
|
|
} else {
|
|
|
|
print STDERR <<EOF;
|
|
|
|
|
|
|
|
The mirror has some problems. Please correct them before trying to build
|
|
|
|
Debian CDs. To do so you could sync your mirror from one of the primary
|
|
|
|
mirror sites listed on the Debian web pages.
|
|
|
|
EOF
|
|
|
|
exit 1;
|
|
|
|
}
|