|
|
@ -273,17 +273,29 @@ descparser() { |
|
|
|
# Not doing anything if checksum is '0' or a text of 'X'. |
|
|
|
# |
|
|
|
cksum_chk() { |
|
|
|
y="`echo $2 | sed 's,^0*,,;'`" |
|
|
|
[ $nocheck = 1 -o -z "$y" -o -z "${2//X/}" ] && return 0 |
|
|
|
x="`cksum "$1" | cut -f1 -d' ' | sed 's,^0*,,;'`" |
|
|
|
local file="$1" cksum="$2" orig="$3" |
|
|
|
|
|
|
|
do_cksum_chk $cksum || return 0 |
|
|
|
|
|
|
|
x="`cksum "$file" | cut -f1 -d' ' | sed 's,^0*,,;'`" |
|
|
|
y="`echo $cksum | sed 's,^0*,,;'`" |
|
|
|
if [ "$x" != "$y" ] ; then |
|
|
|
# Add .cksum-err extension to filename: |
|
|
|
echo "Cksum ERROR: $3.cksum-err ($x)" |
|
|
|
mv "$3" "$3.cksum-err" ; return 1 |
|
|
|
echo "Cksum ERROR: $orig.cksum-err ($x)" |
|
|
|
mv "$orig" "$orig.cksum-err" ; return 1 |
|
|
|
fi |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
# Determine if a check should be done on files with the given cksum. |
|
|
|
# |
|
|
|
do_cksum_chk() { |
|
|
|
local cksum="$1", y="`echo $cksum | sed 's,^0*,,;'`"; |
|
|
|
|
|
|
|
[ $nocheck = 1 -o -z "$y" -o -z "${cksum//X/}" ] && return 1 |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
# Autodetect best Mirror and safe url in $mirror |
|
|
|
# |
|
|
|
detect_mirror() { |
|
|
@ -513,7 +525,9 @@ download_file() { |
|
|
|
# Convert a .gz to .bz2 and test checksum |
|
|
|
# |
|
|
|
if [ "$gzfile" != "$bzfile" ] ; then |
|
|
|
echo "bzip'ing + cksum-test: $gzfile" |
|
|
|
do_cksum_chk $cksum \ |
|
|
|
&& echo "bzip'ing + cksum-test: $gzfile" \ |
|
|
|
|| echo "bzip'ing: $gzfile" |
|
|
|
gunzip < "$gzfile" > src/down.$$.dat |
|
|
|
if cksum_chk src/down.$$.dat $cksum "$gzfile" ; then |
|
|
|
bzip2 < src/down.$$.dat > "$bzfile" ; rm -f "$gzfile" |
|
|
@ -525,12 +539,12 @@ download_file() { |
|
|
|
elif [ "${gzfile%.bz2}" != "$gzfile" -o \ |
|
|
|
"${gzfile%.tbz2}" != "$gzfile" ] |
|
|
|
then |
|
|
|
echo "cksum-test (bzip2): $bzfile" |
|
|
|
if [ $nocheck = 0 ] ; then |
|
|
|
if [ $nocheck = 0 ] && do_cksum_chk $cksum ; then |
|
|
|
echo "cksum-test (bzip2): $bzfile" |
|
|
|
bunzip2 < "$bzfile" > src/down.$$.dat |
|
|
|
cksum_chk src/down.$$.dat $cksum "$bzfile" |
|
|
|
rm -f src/down.$$.dat |
|
|
|
fi |
|
|
|
rm -f src/down.$$.dat |
|
|
|
|
|
|
|
# Execute a cksum test on a raw data file |
|
|
|
# |
|
|
|