2006-11-25 01:08:38 -01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2010-07-05 14:09:23 +00:00
|
|
|
VERBOSE=0
|
|
|
|
|
|
|
|
if [ "$1" = "-v" ] ; then
|
|
|
|
VERBOSE=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2006-11-25 01:08:38 -01:00
|
|
|
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
|
|
|
|
|
2010-05-27 00:52:25 +00:00
|
|
|
if [ "$CHECKSUMS"x = ""x ] ; then
|
|
|
|
CHECKSUMS="sha1 md5 sha512 sha256"
|
|
|
|
fi
|
2009-05-10 23:12:52 +00:00
|
|
|
|
|
|
|
for SUM in $CHECKSUMS; do
|
2018-02-11 20:13:56 -01:00
|
|
|
UPSUM=$(echo $SUM | tr 'a-z' 'A-Z')
|
2009-05-10 23:12:52 +00:00
|
|
|
FILE=$UPSUM"SUMS"$EXT
|
2010-07-05 14:09:23 +00:00
|
|
|
if [ $VERBOSE -eq 1 ] ; then
|
2010-12-09 15:01:47 -01:00
|
|
|
echo "Clearing $PWD/$FILE"
|
2010-07-05 14:09:23 +00:00
|
|
|
fi
|
2009-05-10 23:12:52 +00:00
|
|
|
:> $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
|
2018-02-11 20:13:56 -01:00
|
|
|
for file in $(find * -name \*.jigdo -o -name \*.template -o -name \*.iso); do
|
|
|
|
iso=""
|
2008-09-10 22:16:18 +00:00
|
|
|
case $file in
|
2018-02-11 20:13:56 -01:00
|
|
|
*.template)
|
|
|
|
JIGDO=1
|
|
|
|
;;
|
2008-09-10 22:16:18 +00:00
|
|
|
*.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
|
2018-02-11 20:13:56 -01:00
|
|
|
UPSUM=$(echo $SUM | tr 'a-z' 'A-Z')
|
2009-05-10 23:12:52 +00:00
|
|
|
FILE=$UPSUM"SUMS"$EXT
|
|
|
|
CMD="$SUM"sum
|
|
|
|
|
2018-02-11 20:13:56 -01:00
|
|
|
if [ "$iso"x != ""x ]; then
|
|
|
|
grep -q $iso $FILE
|
|
|
|
if [ $? -ne 0 ] ; then
|
2009-05-10 23:12:52 +00:00
|
|
|
CKSUM=""
|
|
|
|
if [ "$JIGDO" == 1 ] ; then
|
2018-02-11 20:13:56 -01:00
|
|
|
CKSUM=$(zcat -f $file | \
|
|
|
|
grep -i "Image Hex $CMD" | \
|
|
|
|
awk '{print $5}')
|
2009-05-10 23:12:52 +00:00
|
|
|
fi
|
|
|
|
if [ "$CKSUM"x != ""x ] ; then
|
2018-02-11 20:13:56 -01:00
|
|
|
echo "$CKSUM $iso" >> $FILE
|
|
|
|
grep $iso $FILE
|
2009-05-10 23:12:52 +00:00
|
|
|
else
|
2018-02-11 20:13:56 -01:00
|
|
|
echo "No Jigdo help for $SUM, doing it the long way with $CMD"
|
|
|
|
$CMD $iso >> $FILE
|
|
|
|
grep $iso $FILE
|
2009-05-10 23:12:52 +00:00
|
|
|
fi
|
2018-02-11 20:13:56 -01:00
|
|
|
fi
|
2009-05-10 23:12:52 +00:00
|
|
|
fi
|
2008-09-10 22:16:18 +00:00
|
|
|
|
2018-02-11 20:13:56 -01:00
|
|
|
# Also add the template file and jigdo file to the SUMS, if they exist
|
|
|
|
case $file in
|
|
|
|
*.template|*.jigdo)
|
|
|
|
$CMD $file >> $FILE
|
|
|
|
grep $file $FILE
|
|
|
|
;;
|
|
|
|
esac
|
2009-05-10 23:12:52 +00:00
|
|
|
done
|
2008-09-10 22:16:18 +00:00
|
|
|
done
|