2006-11-25 01:08:38 -01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cd $1
|
|
|
|
|
2008-12-17 22:34:11 -01:00
|
|
|
if [ "$2"x != ""x ] ; then
|
2008-12-26 00:08:44 -01:00
|
|
|
EXT="$2"
|
2008-12-17 22:34:11 -01:00
|
|
|
fi
|
|
|
|
|
2009-05-10 23:12:52 +00:00
|
|
|
CHECKSUMS="sha1 md5" # sha512 sha256
|
|
|
|
|
|
|
|
for SUM in $CHECKSUMS; do
|
|
|
|
UPSUM=`echo $SUM | tr 'a-z' 'A-Z'`
|
|
|
|
FILE=$UPSUM"SUMS"$EXT
|
|
|
|
echo "Clearing $FILE"
|
|
|
|
:> $FILE
|
|
|
|
done
|
2006-11-25 01:08:38 -01:00
|
|
|
|
2008-09-10 22:16:18 +00:00
|
|
|
# 2 calls to find here to get the ordering right - we *really* want to
|
|
|
|
# get the jigdo files first
|
|
|
|
for file in `find * -name \*.jigdo` `find * -name \*.iso`; do
|
|
|
|
case $file in
|
|
|
|
*.jigdo)
|
2008-04-20 14:33:19 +00:00
|
|
|
iso=${file%%.jigdo}.iso
|
2008-09-10 22:16:18 +00:00
|
|
|
JIGDO=1
|
|
|
|
;;
|
|
|
|
*.iso)
|
|
|
|
iso=$file
|
|
|
|
JIGDO=0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Found unexpected file $file!"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2008-04-20 14:33:19 +00:00
|
|
|
|
2009-05-10 23:12:52 +00:00
|
|
|
for SUM in $CHECKSUMS; do
|
|
|
|
UPSUM=`echo $SUM | tr 'a-z' 'A-Z'`
|
|
|
|
FILE=$UPSUM"SUMS"$EXT
|
|
|
|
SEARCH="$UPSUM"Sum
|
|
|
|
CMD="$SUM"sum
|
|
|
|
|
|
|
|
grep -q $iso $FILE
|
|
|
|
if [ $? -ne 0 ] ; then
|
|
|
|
CKSUM=""
|
|
|
|
if [ "$JIGDO" == 1 ] ; then
|
|
|
|
CKSUM=`zcat -f $file | awk "/Image Hex $SEARCH/ {print \\$5}"`
|
|
|
|
fi
|
|
|
|
if [ "$CKSUM"x != ""x ] ; then
|
|
|
|
echo "$CKSUM $iso" >> $FILE
|
|
|
|
else
|
|
|
|
echo "No Jigdo help for $SUM, doing it the long way with $CMD"
|
|
|
|
$CMD $iso >> $FILE
|
|
|
|
grep $iso $FILE
|
|
|
|
fi
|
|
|
|
fi
|
2008-09-10 22:16:18 +00:00
|
|
|
|
2009-05-10 23:12:52 +00:00
|
|
|
done
|
2008-09-10 22:16:18 +00:00
|
|
|
done
|