scripts/functions
changeset 1022 7b3e8b8d392e
parent 1017 34267fb0912e
child 1081 10d1270080e6
     1.1 --- a/scripts/functions	Wed Oct 29 22:27:30 2008 +0000
     1.2 +++ b/scripts/functions	Fri Oct 31 18:27:27 2008 +0000
     1.3 @@ -474,40 +474,27 @@
     1.4  
     1.5      # Not found locally, try from the network
     1.6  
     1.7 -    # Start with LAN mirror
     1.8 -    if [ "${CT_USE_LAN_MIRROR}" = "y" ]; then
     1.9 -        CT_DoSetProxy ${CT_LAN_MIRROR_USE_PROXY:+${CT_PROXY_TYPE}}
    1.10 -        CT_DoLog DEBUG "Trying to retrieve a copy of '${file}' from LAN mirror '${CT_LAN_MIRROR_HOSTNAME}'"
    1.11 -        CT_TestOrAbort "Please set the LAN mirror hostname" -n "${CT_LAN_MIRROR_HOSTNAME}"
    1.12 -        CT_TestOrAbort "Please tell me where to find tarballs on the LAN mirror '${CT_LAN_MIRROR_HOSTNAME}'" -n "${CT_LAN_MIRROR_BASE}"
    1.13 -        for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
    1.14 -            # Please note: we just have the file's basename in a single piece.
    1.15 -            # So we have to just try and split it back into name and version... :-(
    1.16 -            for url in "${CT_LAN_MIRROR_SCHEME}://${CT_LAN_MIRROR_HOSTNAME}/${CT_LAN_MIRROR_BASE}/${file%-*}"  \
    1.17 -                       "${CT_LAN_MIRROR_SCHEME}://${CT_LAN_MIRROR_HOSTNAME}/${CT_LAN_MIRROR_BASE}";            \
    1.18 -            do
    1.19 -                CT_DoLog DEBUG "Trying '${url}/${file}${ext}'"
    1.20 -                CT_DoGetFile "${url}/${file}${ext}"
    1.21 -                if [ -f "${file}${ext}" ]; then
    1.22 -                    CT_DoLog DEBUG "Got '${file}' from the LAN mirror"
    1.23 -                    if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
    1.24 -                        # The file may already exist if downloads are forced: remove it first
    1.25 -                        CT_DoLog EXTRA "Saving '${file}' to local storage"
    1.26 -                        CT_DoExecLog ALL rm -f "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}"
    1.27 -                        CT_DoExecLog ALL mv -f "${file}${ext}" "${CT_LOCAL_TARBALLS_DIR}"
    1.28 -                        CT_DoExecLog ALL ln -s "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" "${file}${ext}"
    1.29 -                    fi
    1.30 -                    return 0
    1.31 -                fi
    1.32 -            done
    1.33 -        done
    1.34 +    # Add URLs on the LAN mirror
    1.35 +    LAN_URLS=
    1.36 +    if [ "${CT_USE_MIRROR}" = "y" ]; then
    1.37 +        CT_DoLog DEBUG "Trying to retrieve a copy of '${file}' from LAN mirror '${CT_MIRROR_HOSTNAME}'"
    1.38 +        CT_TestOrAbort "Please set the LAN mirror hostname" -n "${CT_MIRROR_HOSTNAME}"
    1.39 +        CT_TestOrAbort "Please tell me where to find tarballs on the LAN mirror '${CT_MIRROR_HOSTNAME}'" -n "${CT_MIRROR_BASE}"
    1.40 +        LAN_URLS="${LAN_URLS} ${CT_MIRROR_SCHEME}://${CT_MIRROR_HOSTNAME}/${CT_MIRROR_BASE}/${file%-*}"
    1.41 +        LAN_URLS="${LAN_URLS} ${CT_MIRROR_SCHEME}://${CT_MIRROR_HOSTNAME}/${CT_MIRROR_BASE}"
    1.42      fi
    1.43  
    1.44 -    # OK, available neither localy, nor from the LAN mirror (if any).
    1.45 +    if [ "${CT_PREFER_MIRROR}" = "y" ]; then
    1.46 +        URLS="${LAN_URLS} ${@}"
    1.47 +    else
    1.48 +        URLS="${@} ${LAN_URLS}"
    1.49 +    fi
    1.50 +
    1.51 +    # Scan all URLs in turn, and try to grab a tarball from there
    1.52      CT_DoSetProxy ${CT_PROXY_TYPE}
    1.53      for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
    1.54          # Try all urls in turn
    1.55 -        for url in "$@"; do
    1.56 +        for url in ${URLS}; do
    1.57              CT_DoLog DEBUG "Trying '${url}/${file}${ext}'"
    1.58              CT_DoGetFile "${url}/${file}${ext}"
    1.59              if [ -f "${file}${ext}" ]; then