changeset 961:1b971ccf5193

More code cleanups (rename try_checksum to confirm_checksum).
author Rob Landley <rob@landley.net>
date Thu, 28 Jan 2010 13:58:18 -0600
parents d5bc99d01812
children 3d2261361009
files sources/functions.sh
diffstat 1 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/sources/functions.sh	Mon Jan 25 11:05:31 2010 -0600
+++ b/sources/functions.sh	Thu Jan 28 13:58:18 2010 -0600
@@ -274,7 +274,10 @@
   done
 }
 
-function try_checksum()
+# Confirm that a file has the appropriate checksum (or exists but SHA1 is blank)
+# Delete invalid file.
+
+function confirm_checksum()
 {
   SUM="$(sha1file "$SRCDIR/$FILENAME" 2>/dev/null)"
   if [ x"$SUM" == x"$SHA1" ] || [ -z "$SHA1" ] && [ -f "$SRCDIR/$FILENAME" ]
@@ -293,33 +296,30 @@
     return $?
   fi
 
-  return 1
-}
-
-# Attempt to obtain file from a specific location, returning success if file
-# is already there and has appropriate checksum.
-
-function download_from()
-{
-  # Return success if we have a valid copy of the file
-
-  try_checksum && return 0
-
   # If there's a corrupted file, delete it.  In theory it would be nice
   # to resume downloads, but wget creates "*.1" files instead.
 
   rm "$SRCDIR/$FILENAME" 2> /dev/null
 
-  # If we have another source, try to download file.
+  return 1
+}
+
+# Attempt to obtain file from a specific location
+
+function download_from()
+{
+  # Return success if we already have a valid copy of the file
 
-  if [ -n "$1" ]
-  then
-    wget -t 2 -T 20 -O "$SRCDIR/$FILENAME" "$1" ||
-      (rm "$SRCDIR/$FILENAME"; return 2)
-    touch -c "$SRCDIR/$FILENAME"
-  fi
+  confirm_checksum && return 0
+
+  # If we have another source, try to download file from there.
 
-  try_checksum
+  [ -n "$1" ] && return 1
+  wget -t 2 -T 20 -O "$SRCDIR/$FILENAME" "$1" ||
+    (rm "$SRCDIR/$FILENAME"; return 2)
+  touch -c "$SRCDIR/$FILENAME"
+
+  confirm_checksum
 }
 
 # Confirm a file matches sha1sum, else try to download it from mirror list.
@@ -333,7 +333,9 @@
   echo -ne "checking $FILENAME\r"
 
   # Update timestamps on both stable and unstable tarballs (if any)
-  # so cleanup_oldfiles doesn't delete them
+  # so cleanup_oldfiles doesn't delete stable when we're building unstable
+  # or vice versa
+
   touch -c "$SRCDIR"/{"$FILENAME","$ALTFILENAME"} 2>/dev/null
 
   # If unstable version selected, try from listed location, and fall back