summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2008-07-19 22:45:17 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2008-07-19 22:45:17 (GMT)
commit2f6bd7b7949f9f078d398579a8008700ac0b5fb8 (patch)
treec7108bd3b48d05951ac9a1893cdeaf44b428a1cd /scripts
parentdef4ca3905a2566e4823831442e1212769f690a0 (diff)
Introduce using a LAN mirror for retrieving tarballs.
/trunk/scripts/functions | 40 36 4 0 ++++++++++++- /trunk/config/global/download.in | 146 115 31 0 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 151 insertions(+), 35 deletions(-)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/functions40
1 files changed, 36 insertions, 4 deletions
diff --git a/scripts/functions b/scripts/functions
index e44c29b..9ec0693 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -361,18 +361,50 @@ CT_GetFile() {
return 0
fi
done
- # Try to download it
+
+ # Not found locally, try from the network
CT_DoLog EXTRA "Retrieving '${file}' from network"
+
+ # Start with LAN mirror
+ if [ "${CT_USE_LAN_MIRROR}" = "y" ]; then
+ LAN_URLs=
+ for pat in ${CT_LAN_MIRROR_PATTERNS}; do
+ # Please note: we just have the file's basename in a single piece.
+ # So we have to just try and split it back into name and version... :-(
+ pat="${pat//\%pkg/${file%-*}}"
+ pat="${pat//\%ver/${file##*-}}"
+ LAN_URLs="${LAN_URLs} ${CT_LAN_MIRROR_SCHEME}://${CT_LAN_MIRROR_HOSTNAME}/${pat}"
+ done
+ for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
+ for url in ${LAN_URLs}; do
+ CT_DoLog DEBUG "Trying '${url}/${file}${ext}'"
+ CT_DoGetFile "${url}/${file}${ext}"
+ if [ -f "${file}${ext}" ]; then
+ if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
+ # No need to test if the file already exists because
+ # it does NOT. If it did exist, we'd have been stopped
+ # above, when looking for local copies.
+ CT_DoLog EXTRA "Saving '${file}' to local storage"
+ mv "${file}${ext}" "${CT_LOCAL_TARBALLS_DIR}" |CT_DoLog ALL
+ ln -sv "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" "${file}${ext}" |CT_DoLog ALL
+ fi
+ return 0
+ fi
+ done
+ done
+ fi
+
+ # OK, available neither localy, nor from the LAN mirror (if any).
for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
# Try all urls in turn
for url in "$@"; do
CT_DoLog DEBUG "Trying '${url}/${file}${ext}'"
CT_DoGetFile "${url}/${file}${ext}"
if [ -f "${file}${ext}" ]; then
- # No need to test if the file already exists because
- # it does NOT. If it did exist, we'd have been stopped
- # above, when looking for local copies.
if [ "${CT_SAVE_TARBALLS}" = "y" ]; then
+ # No need to test if the file already exists because
+ # it does NOT. If it did exist, we'd have been stopped
+ # above, when looking for local copies.
CT_DoLog EXTRA "Saving '${file}' to local storage"
mv "${file}${ext}" "${CT_LOCAL_TARBALLS_DIR}" |CT_DoLog ALL
ln -sv "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" "${file}${ext}" |CT_DoLog ALL