scripts: add option to only use the mirror
authorAustin Morton <austinpmorton@gmail.com>
Sun Aug 12 07:45:42 2012 -0400 (2012-08-12)
changeset 30482858a24a5846
parent 3047 6d88d6558b7a
child 3049 f0ae157444dc
scripts: add option to only use the mirror

Currently, if downloads are forbidden, the mirror is still tried for.

Change this way:
- if downlaods forbidden, do not try neither upstream locations nor mirror
- add option to only use the mirror, and avoid upstream locations

Signed-off-by: Austin Morton <austinpmorton@gmail.com>
[yann.morin.1998@free.fr: broaden the if USE_MIRRORto enclode mirror location]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
config/global/download.in
scripts/functions
     1.1 --- a/config/global/download.in	Sun Sep 16 14:12:22 2012 -0400
     1.2 +++ b/config/global/download.in	Sun Aug 12 07:45:42 2012 -0400
     1.3 @@ -55,8 +55,6 @@
     1.4        
     1.5        Useful to pre-retrieve the tarballs before going off-line.
     1.6  
     1.7 -endif # ! FORBID_DOWNLOAD
     1.8 -
     1.9  config USE_MIRROR
    1.10      bool
    1.11      prompt "Use a mirror"
    1.12 @@ -69,10 +67,19 @@
    1.13        *not* on your LAN, for example on another subnet of your company's
    1.14        network, or a mirror on the Internet.
    1.15  
    1.16 +if USE_MIRROR
    1.17 +
    1.18 +config FORCE_MIRROR
    1.19 +    bool
    1.20 +    prompt "Only use mirror"
    1.21 +    help
    1.22 +      Only allow downloading from the mirror specified, other download locations
    1.23 +      will NOT be used, and the package will fail to be located if not present
    1.24 +      on the mirror provided
    1.25 +
    1.26  config MIRROR_BASE_URL
    1.27      string
    1.28      prompt "Base URL"
    1.29 -    depends on USE_MIRROR
    1.30      default "http://crosstool-ng.org/mirrors/"
    1.31      help
    1.32        This is the base URL searched in for tarballs.
    1.33 @@ -90,3 +97,7 @@
    1.34        
    1.35        The mirror is available at:
    1.36          http://crosstool-ng.org/mirrors/
    1.37 +
    1.38 +endif # USE_MIRROR
    1.39 +
    1.40 +endif # ! FORBID_DOWNLOAD
     2.1 --- a/scripts/functions	Sun Sep 16 14:12:22 2012 -0400
     2.2 +++ b/scripts/functions	Sun Aug 12 07:45:42 2012 -0400
     2.3 @@ -555,6 +555,12 @@
     2.4      fi
     2.5      # No, it does not...
     2.6  
     2.7 +    # If not allowed to download from the Internet, don't
     2.8 +    if [ "${CT_FORBID_DOWNLOAD}" = "y" ]; then
     2.9 +        CT_DoLog DEBUG "Not allowed to download from the Internet, aborting ${file} download"
    2.10 +        return 1
    2.11 +    fi
    2.12 +
    2.13      # Try to retrieve the file
    2.14      CT_DoLog EXTRA "Retrieving '${file}'"
    2.15  
    2.16 @@ -565,7 +571,7 @@
    2.17          URLS+=( "${CT_MIRROR_BASE_URL}" )
    2.18      fi
    2.19  
    2.20 -    if [ "${CT_FORBID_DOWNLOAD}" != "y" ]; then
    2.21 +    if [ "${CT_FORCE_MIRROR}" != "y" ]; then
    2.22          URLS+=( "${@}" )
    2.23      fi
    2.24