2005-12-06 23:21:22 -01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# grab_md5
|
|
|
|
# (c) 2004 Steve McIntyre <steve@einval.com>
|
|
|
|
#
|
|
|
|
# GPL v2
|
|
|
|
#
|
|
|
|
# Parse Packages and Sources files out of a mirror and pre-process
|
|
|
|
# them into a single list ready for mkisofs to check later
|
|
|
|
|
|
|
|
MIRROR=$1
|
2006-11-30 21:13:42 -01:00
|
|
|
ARCHES="$2"
|
2007-07-30 07:36:39 +00:00
|
|
|
CODENAME=$3
|
|
|
|
DI_CODENAME=$4
|
2006-11-30 21:13:42 -01:00
|
|
|
OUT=$5
|
2005-12-06 23:21:22 -01:00
|
|
|
|
2006-11-30 21:13:42 -01:00
|
|
|
for ARCH in $ARCHES
|
|
|
|
do
|
2008-07-06 21:08:21 +00:00
|
|
|
LOCATIONS="$MIRROR/dists/$CODENAME/ $MIRROR/dists/$DI_CODENAME/"
|
|
|
|
echo "Looking in $LOCATIONS"
|
2006-03-09 00:27:20 -01:00
|
|
|
|
2008-07-06 21:08:21 +00:00
|
|
|
case $ARCH in
|
|
|
|
source)
|
|
|
|
FILES=`find $LOCATIONS -name Sources.gz`
|
|
|
|
echo "Using MD5 sums from Sources files:"
|
2008-07-06 21:01:18 +00:00
|
|
|
echo $FILES
|
2011-05-11 10:54:06 +00:00
|
|
|
zcat -f $FILES | MIRROR=$MIRROR perl -ne '
|
|
|
|
chomp;
|
|
|
|
my %files;
|
|
|
|
my $dir;
|
|
|
|
my $mirror = $ENV{"MIRROR"};
|
|
|
|
my $filename;
|
|
|
|
while (<>) {
|
|
|
|
if (m/^ ([[:xdigit:]]{32}) (\d+) (\S+)/sg) {
|
|
|
|
$files{$3}{"md5"} = $1;
|
|
|
|
$files{$3}{"size"} = $2;
|
|
|
|
}
|
|
|
|
if (m/^Directory: (\S+)/sg) {
|
|
|
|
$dir = $1;
|
|
|
|
}
|
|
|
|
if (m/^$/) {
|
|
|
|
for $filename (keys %files) {
|
|
|
|
printf("%s %12s %s/%s/%s\n",
|
|
|
|
$files{$filename}{"md5"},
|
|
|
|
$files{$filename}{"size"},
|
|
|
|
$mirror, $dir, $filename);
|
|
|
|
}
|
|
|
|
undef %files;
|
|
|
|
}
|
|
|
|
}' | sort | uniq >> $OUT
|
2008-07-06 21:08:21 +00:00
|
|
|
;;
|
2011-06-09 15:27:00 +00:00
|
|
|
*)
|
2008-07-06 21:08:21 +00:00
|
|
|
FILES=`find $LOCATIONS -name Packages.gz | grep binary-$ARCH`
|
|
|
|
echo "Using MD5 sums from Packages files:"
|
2008-07-06 21:01:18 +00:00
|
|
|
echo $FILES
|
2011-06-09 15:27:00 +00:00
|
|
|
NUM_FILES=`echo $FILES | wc -w`
|
|
|
|
if [ $NUM_FILES -eq 1 ] ; then
|
|
|
|
echo "No files found for arch $ARCH. Abort!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-05-11 10:54:06 +00:00
|
|
|
zcat -f $FILES | MIRROR=$MIRROR perl -ne '
|
|
|
|
chomp;
|
|
|
|
my $mirror = $ENV{"MIRROR"};
|
|
|
|
my $filename;
|
|
|
|
my $size;
|
|
|
|
my $md5;
|
|
|
|
while (<>) {
|
|
|
|
if (m/^Filename: (\S+)/sg) {
|
|
|
|
$filename = $1;
|
|
|
|
}
|
|
|
|
if (m/^Size: (\S+)/sg) {
|
|
|
|
$size = $1;
|
|
|
|
}
|
|
|
|
if (m/^MD5sum: (\S+)/sg) {
|
|
|
|
$md5 = $1;
|
|
|
|
}
|
|
|
|
if (m/^$/) {
|
|
|
|
printf("%s %12s %s/%s\n", $md5, $size, $mirror, $filename);
|
|
|
|
}
|
|
|
|
}' | sort | uniq >> $OUT
|
2006-11-30 21:13:42 -01:00
|
|
|
# Use the new D-I images. Do NOT use the "current"
|
|
|
|
# link; it causes problems with overlaid files...
|
2007-07-30 07:36:39 +00:00
|
|
|
for VER in $MIRROR/dists/$DI_CODENAME/main/installer-$ARCH/*
|
2006-11-30 21:13:42 -01:00
|
|
|
do
|
|
|
|
if [ -d $VER ] && [ ! -L $VER ] ; then
|
|
|
|
FILE=$VER/images/MD5SUMS
|
2008-07-06 21:08:21 +00:00
|
|
|
echo "Using MD5 sums from d-i: $FILE"
|
2007-07-30 07:36:39 +00:00
|
|
|
LOC=dists/$DI_CODENAME/main/installer-$ARCH/`basename $VER`/images
|
2006-11-30 21:13:42 -01:00
|
|
|
for ENTRY in `cat $FILE | sed 's/ /:/g'`
|
|
|
|
do
|
|
|
|
PATH=`echo $ENTRY | /bin/sed "s?^.*:\./?$MIRROR/$LOC/?g"`
|
|
|
|
MD5=`echo $ENTRY | /bin/sed 's/:.*$//g'`
|
|
|
|
SIZE=`/usr/bin/stat -c %s $PATH`
|
|
|
|
printf '%s %12.12s %s\n' $MD5 $SIZE $PATH
|
|
|
|
done | sort | uniq >> $OUT
|
|
|
|
fi
|
|
|
|
done
|
2008-07-06 21:08:21 +00:00
|
|
|
;;
|
|
|
|
esac
|
2006-11-30 21:13:42 -01:00
|
|
|
done
|
2005-12-06 23:21:22 -01:00
|
|
|
|
|
|
|
exit 0
|