scripts/functions: always prefer the mirror
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 02 23:11:25 2011 +0200 (2011-08-02)
changeset 25932472b2f24e3a
parent 2592 4908eb2b6f17
child 2594 b132d22c912a
scripts/functions: always prefer the mirror

Currently, the mirror can be used either:
- as a fallback in case upstream is unavailable (default behavior)
- as the preferred source for downloads

But the most common use-case seems to provide a truely-LAN mirror
to speed up downloads in big corpos', and/or provide a 'trusted'
source for the tarballs.

So, make the following changes;
- if a mirror is specified, always try that before trying upstream

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
config/global/download.in
scripts/functions
     1.1 --- a/config/global/download.in	Tue Aug 02 18:26:53 2011 +0200
     1.2 +++ b/config/global/download.in	Tue Aug 02 23:11:25 2011 +0200
     1.3 @@ -37,17 +37,10 @@
     1.4        *not* on your LAN, for example on another subnet of your company's
     1.5        network, or a mirror on the Internet.
     1.6  
     1.7 -if USE_MIRROR
     1.8 -
     1.9 -config PREFER_MIRROR
    1.10 -    bool
    1.11 -    prompt "Prefer the mirror"
    1.12 -    help
    1.13 -      Say 'Y' here if you prefer the LAN mirror over the upstream sources.
    1.14 -
    1.15  config MIRROR_BASE_URL
    1.16      string
    1.17      prompt "Base URL"
    1.18 +    depends on USE_MIRROR
    1.19      default "http://ymorin.is-a-geek.org/mirrors/"
    1.20      help
    1.21        This is the base URL searched in for tarballs.
    1.22 @@ -63,8 +56,6 @@
    1.23        The mirror is available at:
    1.24          http://ymorin.is-a-geek.org/mirrors/
    1.25  
    1.26 -endif # USE_MIRROR
    1.27 -
    1.28  config CONNECT_TIMEOUT
    1.29      int
    1.30      prompt "Connection timeout"
     2.1 --- a/scripts/functions	Tue Aug 02 18:26:53 2011 +0200
     2.2 +++ b/scripts/functions	Tue Aug 02 23:11:25 2011 +0200
     2.3 @@ -513,7 +513,7 @@
     2.4  # Usage: CT_GetFile <basename> [.extension] <url> [url ...]
     2.5  CT_GetFile() {
     2.6      local ext
     2.7 -    local url URLS LAN_URLS
     2.8 +    local url URLS
     2.9      local file="$1"
    2.10      local first_ext
    2.11      shift
    2.12 @@ -532,23 +532,13 @@
    2.13      # Try to retrieve the file
    2.14      CT_DoLog EXTRA "Retrieving '${file}'"
    2.15  
    2.16 -    URLS="$@"
    2.17 -
    2.18      # Add URLs on the LAN mirror
    2.19 -    LAN_URLS=
    2.20      if [ "${CT_USE_MIRROR}" = "y" ]; then
    2.21          CT_TestOrAbort "Please set the mirror base URL" -n "${CT_MIRROR_BASE_URL}"
    2.22 -        LAN_URLS="${LAN_URLS} ${CT_MIRROR_BASE_URL}/${file%-*}"
    2.23 -        LAN_URLS="${LAN_URLS} ${CT_MIRROR_BASE_URL}"
    2.24 +        URLS="${CT_MIRROR_BASE_URL}/${file%-*} ${CT_MIRROR_BASE_URL}"
    2.25 +    fi
    2.26  
    2.27 -        if [ "${CT_PREFER_MIRROR}" = "y" ]; then
    2.28 -            CT_DoLog DEBUG "Pre-pending LAN mirror URLs"
    2.29 -            URLS="${LAN_URLS} ${URLS}"
    2.30 -        else
    2.31 -            CT_DoLog DEBUG "Appending LAN mirror URLs"
    2.32 -            URLS="${URLS} ${LAN_URLS}"
    2.33 -        fi
    2.34 -    fi
    2.35 +    URLS+="${URLS:+ }${*}"
    2.36  
    2.37      # Scan all URLs in turn, and try to grab a tarball from there
    2.38      # Do *not* try git trees (ext=/.git), this is handled in a specific