2005-12-06 23:21:22 -01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2019-11-21 18:03:11 -01:00
|
|
|
# grab_checksum
|
|
|
|
# (c) 2004-2019 Steve McIntyre <steve@einval.com>
|
2005-12-06 23:21:22 -01:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2012-07-13 21:34:54 +00:00
|
|
|
set -e
|
|
|
|
|
2019-11-21 18:03:11 -01:00
|
|
|
CHECKSUM=$1
|
|
|
|
MIRROR=$2
|
|
|
|
ARCHES="$3"
|
|
|
|
CODENAME=$4
|
|
|
|
DI_CODENAME=$5
|
|
|
|
OUT=$6
|
|
|
|
|
|
|
|
case $CHECKSUM in
|
|
|
|
md5|sha256)
|
|
|
|
# OK
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "$0: Unsupported checksum specified: $CHECKSUM"
|
|
|
|
echo "Abort"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
export CHECKSUM
|
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/"
|
2016-09-20 00:46:15 +00:00
|
|
|
if [ "$BACKPORTS"x != ""x ] ; then
|
|
|
|
LOCATIONS="$LOCATIONS $MIRROR/dists/$CODENAME-backports/"
|
|
|
|
fi
|
2021-02-19 21:57:14 -01:00
|
|
|
if [ "$UNRELEASED" = 1 ] ; then
|
|
|
|
LOCATIONS="$LOCATIONS $MIRROR/dists/unreleased/"
|
|
|
|
fi
|
2008-07-06 21:08:21 +00:00
|
|
|
echo "Looking in $LOCATIONS"
|
2006-03-09 00:27:20 -01:00
|
|
|
|
2012-07-13 21:34:54 +00:00
|
|
|
for LOCATION in $LOCATIONS; do
|
|
|
|
if [ ! -d $LOCATION ]; then
|
|
|
|
echo "Error: $LOCATION is not a directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2008-07-06 21:08:21 +00:00
|
|
|
case $ARCH in
|
|
|
|
source)
|
2021-02-19 18:33:48 -01:00
|
|
|
FILES=`find $LOCATIONS -follow -name Sources.gz -o -name Sources.xz`
|
2019-11-21 18:03:11 -01:00
|
|
|
echo "Using $CHECKSUM sums from Sources files:"
|
2008-07-06 21:01:18 +00:00
|
|
|
echo $FILES
|
2019-11-21 18:03:11 -01:00
|
|
|
$BASEDIR/tools/catz $FILES | \
|
|
|
|
MIRROR=$MIRROR CHECKSUM=$CHECKSUM perl -e '
|
2011-05-11 10:54:06 +00:00
|
|
|
chomp;
|
|
|
|
my %files;
|
|
|
|
my $dir;
|
|
|
|
my $filename;
|
2019-11-21 18:03:11 -01:00
|
|
|
my $mirror = $ENV{"MIRROR"};
|
|
|
|
my $checksum = $ENV{"CHECKSUM"};
|
2011-05-11 10:54:06 +00:00
|
|
|
while (<>) {
|
|
|
|
if (m/^ ([[:xdigit:]]{32}) (\d+) (\S+)/sg) {
|
|
|
|
$files{$3}{"md5"} = $1;
|
|
|
|
$files{$3}{"size"} = $2;
|
|
|
|
}
|
2019-11-21 18:03:11 -01:00
|
|
|
if (m/^ ([[:xdigit:]]{64}) (\d+) (\S+)/sg) {
|
|
|
|
$files{$3}{"sha256"} = $1;
|
|
|
|
$files{$3}{"size"} = $2;
|
|
|
|
}
|
2011-05-11 10:54:06 +00:00
|
|
|
if (m/^Directory: (\S+)/sg) {
|
|
|
|
$dir = $1;
|
|
|
|
}
|
|
|
|
if (m/^$/) {
|
|
|
|
for $filename (keys %files) {
|
|
|
|
printf("%s %12s %s/%s/%s\n",
|
2019-11-21 18:03:11 -01:00
|
|
|
$files{$filename}{$checksum},
|
2011-05-11 10:54:06 +00:00
|
|
|
$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
|
|
|
*)
|
2021-02-19 21:11:33 -01:00
|
|
|
FILES=`find $LOCATIONS -follow -name Packages.gz \
|
2016-11-15 08:06:41 -01:00
|
|
|
-o -name Packages.xz | grep binary-$ARCH`
|
2019-11-21 18:03:11 -01:00
|
|
|
echo "Using $CHECKSUM sums from Packages files:"
|
2008-07-06 21:01:18 +00:00
|
|
|
echo $FILES
|
2016-11-15 08:06:41 -01:00
|
|
|
NUM_FILES=`echo $FILES| wc -w`
|
2011-06-09 15:27:00 +00:00
|
|
|
if [ $NUM_FILES -eq 1 ] ; then
|
|
|
|
echo "No files found for arch $ARCH. Abort!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-21 18:03:11 -01:00
|
|
|
$BASEDIR/tools/catz $FILES | \
|
|
|
|
MIRROR=$MIRROR CHECKSUM=$CHECKSUM perl -e '
|
2011-05-11 10:54:06 +00:00
|
|
|
chomp;
|
|
|
|
my $mirror = $ENV{"MIRROR"};
|
2019-11-21 18:03:11 -01:00
|
|
|
my $checksum = $ENV{"CHECKSUM"};
|
2011-05-11 10:54:06 +00:00
|
|
|
my $filename;
|
|
|
|
my $size;
|
2019-11-21 18:03:11 -01:00
|
|
|
my $sum;
|
2011-05-11 10:54:06 +00:00
|
|
|
while (<>) {
|
|
|
|
if (m/^Filename: (\S+)/sg) {
|
|
|
|
$filename = $1;
|
|
|
|
}
|
|
|
|
if (m/^Size: (\S+)/sg) {
|
|
|
|
$size = $1;
|
|
|
|
}
|
2019-11-21 18:03:11 -01:00
|
|
|
if ($checksum eq "md5" and (m/^MD5sum: (\S+)/sg)) {
|
|
|
|
$sum = $1;
|
|
|
|
} elsif ($checksum eq "sha256" and (m/^SHA256: (\S+)/sg)) {
|
|
|
|
$sum = $1;
|
2011-05-11 10:54:06 +00:00
|
|
|
}
|
|
|
|
if (m/^$/) {
|
2019-11-21 18:03:11 -01:00
|
|
|
printf("%s %12s %s/%s\n", $sum, $size, $mirror, $filename);
|
|
|
|
$sum = "";
|
2011-05-11 10:54:06 +00:00
|
|
|
}
|
|
|
|
}' | 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
|
2019-11-21 18:03:11 -01:00
|
|
|
if [ $CHECKSUM = md5 ]; then
|
|
|
|
FILE=$VER/images/MD5SUMS
|
|
|
|
else
|
|
|
|
FILE=$VER/images/SHA256SUMS
|
|
|
|
fi
|
|
|
|
echo "Using $CHECKSUM 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"`
|
2019-11-21 18:03:11 -01:00
|
|
|
CSUM=`echo $ENTRY | /bin/sed 's/:.*$//g'`
|
2006-11-30 21:13:42 -01:00
|
|
|
SIZE=`/usr/bin/stat -c %s $PATH`
|
2019-11-21 18:03:11 -01:00
|
|
|
printf '%s %12.12s %s\n' $CSUM $SIZE $PATH
|
2006-11-30 21:13:42 -01:00
|
|
|
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
|
2019-11-21 18:03:11 -01:00
|
|
|
|