]> https://gitweb.dealii.org/ - candi.git/commitdiff
candi: Tested download looping and download MIRROR; disable SNAPSHOT downloads
authorUwe Köcher <koecher@hsu-hamburg.de>
Fri, 30 Oct 2015 12:45:47 +0000 (13:45 +0100)
committerUwe Köcher <koecher@hsu-hamburg.de>
Fri, 30 Oct 2015 12:45:47 +0000 (13:45 +0100)
candi.sh
project-deal.II.cfg

index dbea518c26b899f996fb519032b0606a8778059d..bcb0a9d03ef664398d3c22ba800034a2bef431dd 100755 (executable)
--- a/candi.sh
+++ b/candi.sh
@@ -83,6 +83,7 @@ fi
 BAD="\033[1;31m"
 GOOD="\033[1;32m"
 WARN="\033[1;34m"
+INFO="\033[1;34m"
 BOLD="\033[1m"
 
 ################################################################################
@@ -143,7 +144,7 @@ verify_archive() {
         return 2
     fi
     
-    cecho ${GOOD} "Verifying ${ARCHIVE_FILE}"
+    cecho ${INFO} "Verifying ${ARCHIVE_FILE}"
     
     # Verify checksum using md5/md5sum
     if builtin command -v md5 > /dev/null; then
@@ -175,7 +176,7 @@ verify_archive() {
 
 download_archive () {
     ARCHIVE_FILE=$1
-
+    
     # Include (local) mirrors
     if [ ! -z "${MIRROR}" ]; then
         SOURCE="${MIRROR} ${SOURCE}"
@@ -183,41 +184,56 @@ download_archive () {
     
     for source in ${SOURCE}
     do
-        # Set up complete url
-        url=${source}${ARCHIVE_FILE}
+        # verify_archive:
+        # * Skip loop if the ARCHIVE_FILE is already downloaded
+        # * Remove corrupted ARCHIVE_FILE
+        verify_archive ${ARCHIVE_FILE}
+        archive_state=$?
+        
+        if [ ${archive_state} = 0 ]; then
+             cecho ${INFO} "${ARCHIVE_FILE} already downloaded and verified."
+             return 0;
         
-        # 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
-                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
+        elif [ ${archive_state} = 1 ]; then
+             cecho ${INFO} "${ARCHIVE_FILE} already downloaded."
+             return 0;
+             
+        elif [ ${archive_state} = 3 ]; then
+            cecho ${BAD} "${ARCHIVE_FILE} in your download folder is corrupted"
+            rm -f ${ARCHIVE_FILE}
+            
+            verify_archive ${ARCHIVE_FILE}
+            if [ $? = 2 ]; then
+                cecho ${GOOD} "corrupted ${ARCHIVE_FILE} has been removed"
             fi
-        else
-            cecho ${GOOD} "Skipping download (archive file exists)"
         fi
+        unset archive_state
+        
+        # Set up complete url
+        url=${source}${ARCHIVE_FILE}
+        cecho ${GOOD} "Trying to download ${url}"
         
-        # 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..."
+        # Download.
+        # If curl or wget is failing, continue this loop for trying an other mirror.
+        if [ ${DOWNLOADER} = "curl" ] && [ ${CURL_DOWNLOADER_AVAILABLE} = "true" ] ; then
+            curl -O ${url} || continue
+        else
+            wget --no-check-certificate ${url} -O ${ARCHIVE_FILE} || continue
         fi
         
         unset url
+        
+        # Verify the download
+        verify_archive ${ARCHIVE_FILE}
+        archive_state=$?
+        if [ ${archive_state} = 0 ] || [ ${archive_state} = 1 ]; then
+            # If the download was successful, and the CHECKSUM is matching or ignored
+            return 0;
+        fi
+        unset archive_state
     done
-
-    # Make sure the archive was downloaded
-    if [ ! -e ${ARCHIVE_FILE} ]; then
-        cecho ${BAD} "${ARCHIVE_FILE} does not exist. Please download first."
-        exit 1
-    fi
     
-    # Verify the download
+    # Unfortunately it seems that (all) download tryouts finally failed for some reason:
     verify_archive ${ARCHIVE_FILE}
     quit_if_fail "Error verifying checksum for ${ARCHIVE_FILE}\nMake sure that you are connected to the internet.\nIf a corrupted file has been downloaded, please remove\n   ${DOWNLOAD_PATH}/${NAME}${PACKING}\nbefore you restart candi!"
 }
index 70995a53370e41fad1bdfcba7f3914e56fde409d..f18968ae5f551c38a05201b12a2011790afa0a70 100644 (file)
@@ -8,8 +8,8 @@ PROJECT=deal.II
 CLEAN_BUILD=false
 
 #########################################################################
-# Set up a (local) mirror server url
-MIRROR="https://www.ces.clemson.edu/dealii/mirror/"
+# Set up a (local) mirror server url, to speed up your package downloads:
+#MIRROR=
 
 #########################################################################
 #Choose components of deal.II

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.