|
|
@ -2,7 +2,7 @@ |
|
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
|
|
# |
|
|
|
# Filename: lib/sde-download/validate.sh |
|
|
|
# Copyright (C) 2006 The OpenSDE Project |
|
|
|
# Copyright (C) 2006 - 2008 The OpenSDE Project |
|
|
|
# |
|
|
|
# More information can be found in the files COPYING and README. |
|
|
|
# |
|
|
@ -44,32 +44,38 @@ case "${gzfile##*.}" in |
|
|
|
*) format=raw |
|
|
|
extractor=cat ;; |
|
|
|
esac |
|
|
|
|
|
|
|
echo -n "cksum-test ($format): $gzfile... " |
|
|
|
|
|
|
|
mkdir -p 'tmp/' |
|
|
|
efective=$( $extractor < $gzfile | tee tmp/down.$$.dat | cksum - | cut -f1 -d' ' ) |
|
|
|
if [ "$bzfile" = "$gzfile" ]; then |
|
|
|
tmpfile= |
|
|
|
effective=$( $extractor < $gzfile | cksum - | cut -f1 -d' ' ) |
|
|
|
else |
|
|
|
mkdir -p 'tmp/' |
|
|
|
tmpfile="tmp/down.$$.dat" |
|
|
|
effective=$( $extractor < $gzfile | tee "$tmpfile" | cksum - | cut -f1 -d' ' ) |
|
|
|
fi |
|
|
|
|
|
|
|
case "$expected" in |
|
|
|
X) echo "Ignoring Checksum ($efective)." ;; |
|
|
|
0) echo "Missing Checksum ($efective)." ;; |
|
|
|
*) if [ "$efective" != "$expected" ]; then |
|
|
|
X) echo "Ignoring Checksum ($effective)." ;; |
|
|
|
0) echo "Missing Checksum ($effective)." ;; |
|
|
|
*) if [ "$effective" != "$expected" ]; then |
|
|
|
echo "Wrong Checksum!" |
|
|
|
echo "Moving to $gzfile.cksum-err ($efective)." |
|
|
|
echo "Moving to $gzfile.cksum-err ($effective)." |
|
|
|
mv "$gzfile" "$gzfile.cksum-err" |
|
|
|
rm tmp/down.$$.dat |
|
|
|
[ -z "$tmpfile" ] || rm -f "$tmpfile" |
|
|
|
exit 1 |
|
|
|
else |
|
|
|
echo "OK." |
|
|
|
fi |
|
|
|
esac |
|
|
|
|
|
|
|
case "$format" in |
|
|
|
raw) mv -f tmp/down.$$.dat "$bzfile" |
|
|
|
if [ -n "$tmpfile" ]; then |
|
|
|
case "$format" in |
|
|
|
raw) mv -f "$tmpfile" "$bzfile" |
|
|
|
;; |
|
|
|
*) bzip2 < tmp/down.$$.dat > "$bzfile" |
|
|
|
if [ "$gzfile" != "$bzfile" ]; then |
|
|
|
rm -f "$gzfile" |
|
|
|
fi |
|
|
|
rm -f tmp/down.$$.dat |
|
|
|
*) bzip2 < "$tmpfile" > "$bzfile" |
|
|
|
rm -f "$gzfile" "$tmpfile" |
|
|
|
;; |
|
|
|
esac |
|
|
|
esac |
|
|
|
fi |