]> gitweb.fluxo.info Git - downloaders.git/commitdiff
Fixes for debian-dl
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 8 Oct 2022 14:52:32 +0000 (11:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 8 Oct 2022 14:52:32 +0000 (11:52 -0300)
debian-dl

index 8e16718d1977e6756967c7739efe6c6aa4bd7f1a..b9306b257d41f007e2eb8b79d5cad46fd6a7b0fe 100755 (executable)
--- a/debian-dl
+++ b/debian-dl
@@ -4,15 +4,7 @@
 #
 
 # Parameters
-HASHES="MD5SUMS SHA1SUMS SHA256SUMS SHA512SUMS"
-
-# Arguments
 BASENAME="`basename $0`"
-URL="$1"
-BASE="`dirname $URL`"
-RATE="$2"
-FILENAME="`basename $URL`"
-SIGN="sign"
 
 # Syntax
 if [ -z "$1" ]; then
@@ -20,6 +12,14 @@ if [ -z "$1" ]; then
   exit 1
 fi
 
+# Arguments
+URL="$1"
+BASE="`dirname $URL`"
+RATE="$2"
+FILENAME="`basename $URL`"
+SIGN="sign"
+HASHES="MD5SUMS SHA1SUMS SHA256SUMS SHA512SUMS"
+
 # Fetch hashes
 for hash in $HASHES; do
   wget -c $BASE/$hash
@@ -69,13 +69,19 @@ fi
 
 # Check hashes
 for hash in $HASHES; do
-  echo "Checking $FILENAME against $hash file..."
-  check="`echo $hash | tr '[:upper:]' '[:lower:]' | sed -e 's/s$//'`"
-  grep -e "$FILENAME$" $hash | $check -c
+  if [ -e "$hash" ]; then
+    echo "Checking $FILENAME against $hash file..."
+    check="`echo $hash | tr '[:upper:]' '[:lower:]' | sed -e 's/s$//'`"
+    grep -e "$FILENAME$" $hash | $check -c
+  else
+    echo "$BASENAME: cannot check $hash: file not found, skipping"
+  fi
 done
 
 # Check hash integrity
 for hash in $HASHES; do
-  echo "Checking $hash.$SIGN..."
-  gpg --verify $hash.$SIGN
+  if [ -e "$hash" ]; then
+    echo "Checking $hash.$SIGN..."
+    gpg --verify $hash.$SIGN
+  fi
 done