Skip to content

Commit 2f8cf84

Browse files
author
gabriel pettier
committed
allow checking sha1 instead of md5
1 parent 5c8fa66 commit 2f8cf84

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

distribute.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ if [ "X$MD5SUM" == "X" ]; then
6969
fi
7070
fi
7171

72+
SHA1SUM=$(which sha1sum)
73+
if [ "X$SHA1SUM" == "X" ]; then
74+
echo "Error: you need sha1sum installed."
75+
exit 1
76+
fi
77+
7278
WGET=$(which wget)
7379
if [ "X$WGET" == "X" ]; then
7480
WGET=$(which curl)
@@ -543,9 +549,13 @@ function run_get_packages() {
543549

544550
url="URL_$module"
545551
url=${!url}
552+
546553
md5="MD5_$module"
547554
md5=${!md5}
548555

556+
sha1="SHA1_$module"
557+
sha1=${!sha1}
558+
549559
if [ ! -d "$BUILD_PATH/$module" ]; then
550560
try mkdir -p $BUILD_PATH/$module
551561
fi
@@ -581,6 +591,17 @@ function run_get_packages() {
581591
error "Module $module have invalid md5, redownload."
582592
rm $filename
583593
fi
594+
elif [ -n "$sha1" ]; then
595+
# check if the sha1 is correct
596+
current_sha1=$($SHA1SUM $filename | cut -d\ -f1)
597+
if [ "X$current_sha1" == "X$sha1" ]; then
598+
# correct, no need to download
599+
do_download=0
600+
else
601+
# invalid download, remove the file
602+
error "Module $module have invalid sha1, redownload."
603+
rm $filename
604+
fi
584605
else
585606
do_download=0
586607
fi

0 commit comments

Comments
 (0)