From: Uwe Köcher <koecher@hsu-hamburg.de>
Date: Thu, 29 Oct 2015 17:48:33 +0000 (+0100)
Subject: candi: included loop over MIRROR and SOURCE for archives
X-Git-Tag: v0.7~5^2~4
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8618b1826ff772f880e6770abfaa75689325f40c;p=candi.git

candi: included loop over MIRROR and SOURCE for archives
NOTES:
* untested version
* MIRROR variable in project-deal.II.cfg must be disabled for the final version

TODOs:
* MIRRORS for hg, git, svn ...
---

diff --git a/candi.sh b/candi.sh
index f992041..dbea518 100755
--- a/candi.sh
+++ b/candi.sh
@@ -175,28 +175,41 @@ verify_archive() {
 
 download_archive () {
     ARCHIVE_FILE=$1
+
+    # Include (local) mirrors
+    if [ ! -z "${MIRROR}" ]; then
+        SOURCE="${MIRROR} ${SOURCE}"
+    fi
     
-    # Only download archives that do not exist
-    if [ ! -e ${ARCHIVE_FILE} ]; then
-        if [ ${DOWNLOADER} = "curl" ] && [ ${CURL_DOWNLOADER_AVAILABLE} = "true" ] ; then
-            curl -O ${SOURCE}${ARCHIVE_FILE} || { rm ${SOURCE}${ARCHIVE_FILE}; exit 1; }
-        else
-            if [ ${STABLE_BUILD} = false ] && [ ${USE_SNAPSHOTS} = true ]; then
-                wget --retry-connrefused --no-check-certificate --server-response -c ${SOURCE}${ARCHIVE_FILE} -O ${ARCHIVE_FILE} || { rm ${ARCHIVE_FILE}; exit 1; }
+    for source in ${SOURCE}
+    do
+        # Set up complete url
+        url=${source}${ARCHIVE_FILE}
+        
+        # Only download archives that do not exist
+        if [ ! -e ${ARCHIVE_FILE} ]; then
+            if [ ${DOWNLOADER} = "curl" ] && [ ${CURL_DOWNLOADER_AVAILABLE} = "true" ] ; then
+                curl -O ${url} || { rm ${ARCHIVE_FILE}; exit 1; }
             else
-                wget --retry-connrefused --no-check-certificate -c ${SOURCE}${ARCHIVE_FILE} -O ${ARCHIVE_FILE} || { rm ${ARCHIVE_FILE}; exit 1; }
+                if [ ${STABLE_BUILD} = false ] && [ ${USE_SNAPSHOTS} = true ]; then
+                    wget --retry-connrefused --no-check-certificate --server-response -c ${url} -O ${ARCHIVE_FILE} || { rm ${ARCHIVE_FILE}; exit 1; }
+                else
+                    wget --retry-connrefused --no-check-certificate -c ${url} -O ${ARCHIVE_FILE} || { rm ${ARCHIVE_FILE}; exit 1; }
+                fi
             fi
+        else
+            cecho ${GOOD} "Skipping download (archive file exists)"
         fi
-    else
-        cecho ${GOOD} "Skipping download (archive file exists)"
-    fi
-    
-    # Download again when using snapshots and unstable packages, but
-    # only when the timestamp has changed
-    if [ ${STABLE_BUILD} = false ] && [ ${USE_SNAPSHOTS} = true ]; then
-        wget --timestamping --retry-connrefused --no-check-certificate ${SOURCE}${ARCHIVE_FILE} || { rm ${SOURCE}${ARCHIVE_FILE}; exit 1; }
-        cecho ${GOOD} "Downloading new snap shot archive file..."
-    fi
+        
+        # Download again when using snapshots and unstable packages, but
+        # only when the timestamp has changed
+        if [ ${STABLE_BUILD} = false ] && [ ${USE_SNAPSHOTS} = true ]; then
+            wget --timestamping --retry-connrefused --no-check-certificate ${url} || { rm ${ARCHIVE_FILE}; exit 1; }
+            cecho ${GOOD} "Downloading new snap shot archive file..."
+        fi
+        
+        unset url
+    done
 
     # Make sure the archive was downloaded
     if [ ! -e ${ARCHIVE_FILE} ]; then
diff --git a/project-deal.II.cfg b/project-deal.II.cfg
index 0fd1048..70995a5 100644
--- a/project-deal.II.cfg
+++ b/project-deal.II.cfg
@@ -7,6 +7,10 @@
 PROJECT=deal.II
 CLEAN_BUILD=false
 
+#########################################################################
+# Set up a (local) mirror server url
+MIRROR="https://www.ces.clemson.edu/dealii/mirror/"
+
 #########################################################################
 #Choose components of deal.II
 DEAL_CONFOPTS=" \