changeset 959:5a2afff0d00c

Rename try_download() to download_from().
author Rob Landley <rob@landley.net>
date Sun, 24 Jan 2010 01:19:54 -0600
parents 0581a13cadb3
children d5bc99d01812
files sources/functions.sh
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sources/functions.sh	Sat Jan 23 06:16:59 2010 -0600
+++ b/sources/functions.sh	Sun Jan 24 01:19:54 2010 -0600
@@ -296,8 +296,10 @@
   return 1
 }
 
+# Attempt to obtain file from a specific location, returning success if file
+# is already there and has appropriate checksum.
 
-function try_download()
+function download_from()
 {
   # Return success if we have a valid copy of the file
 
@@ -334,12 +336,17 @@
   # so cleanup_oldfiles doesn't delete them
   touch -c "$SRCDIR"/{"$FILENAME","$ALTFILENAME"} 2>/dev/null
 
-  # Is the unstable version selected?
+  # If unstable version selected, try from listed location, and fall back
+  # to PREFERRED_MIRROR.  Do not try normal mirror locations for unstable.
+
   if unstable "$(basename "$FILENAME")"
   then
+    FILENAME="$ALTFILENAME"
+    SHA1=
     # Download new one as alt-packagename.tar.ext
-    FILENAME="$ALTFILENAME" SHA1= try_download "$UNSTABLE" ||
-      ([ ! -z "$PREFERRED_MIRROR" ] && SHA1= FILENAME="$ALTFILENAME" try_download "$PREFERRED_MIRROR/$ALTFILENAME")
+    download_from "$UNSTABLE" ||
+      ([ ! -z "$PREFERRED_MIRROR" ] &&
+        download_from "$PREFERRED_MIRROR/$ALTFILENAME")
     return $?
   fi
 
@@ -347,16 +354,16 @@
 
   if [ ! -z "$PREFERRED_MIRROR" ]
   then
-    try_download "$PREFERRED_MIRROR/$FILENAME" && return 0
+    download_from "$PREFERRED_MIRROR/$FILENAME" && return 0
   fi
 
-  # Try standard locations
+  # Try original location, then mirrors.
   # Note: the URLs in mirror list cannot contain whitespace.
 
-  try_download "$URL" && return 0
+  download_from "$URL" && return 0
   for i in $MIRROR_LIST
   do
-    try_download "$i/$FILENAME" && return 0
+    download_from "$i/$FILENAME" && return 0
   done
 
   # Return failure.