From a464eeecda20fefa64490f6454aa5650de67f119 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Thu, 12 Jul 2007 19:52:09 +0000 Subject: Get rid of the legacy local variable got_it. Allow to download files without extension. Allow to specify a preffered extension when downloading a file. diff --git a/scripts/functions b/scripts/functions index c47ee90..60b8370 100644 --- a/scripts/functions +++ b/scripts/functions @@ -256,7 +256,6 @@ CT_DoYes() { CT_GetFileExtension() { local ext local file="$1" - local got_it=1 CT_Pushd "${CT_TARBALLS_DIR}" # we need to also check for an empty extension for those very @@ -265,7 +264,6 @@ CT_GetFileExtension() { for ext in .tar.gz .tar.bz2 .tgz .tar ''; do if [ -f "${file}${ext}" ]; then echo "${ext}" - got_it=0 break fi done @@ -310,13 +308,19 @@ CT_DoGetFile() { } # Download the file from one of the URLs passed as argument -# Usage: CT_GetFile [ ...] +# Usage: CT_GetFile [extension] [url ...] CT_GetFile() { - local got_it local ext local url local file="$1" + local first_ext="" shift + case "$1" in + .tar.bz2|.tar.gz|.tgz|.tar) + first_ext="$1" + shift + ;; + esac # Do we already have it? ext=`CT_GetFileExtension "${file}"` @@ -326,11 +330,10 @@ CT_GetFile() { fi CT_Pushd "${CT_TARBALLS_DIR}" - # File not yet downloaded, try to get it - got_it=0 - # We'd rather have a bzip2'ed tarball, then gzipped, and finally plain tar. + # We'd rather have a bzip2'ed tarball, then gzipped tarball, plain tarball, + # or, as a failover, a file without extension. # Try local copy first, if it exists - for ext in .tar.bz2 .tar.gz .tgz .tar; do + for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do if [ -r "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" -a \ "${CT_FORCE_DOWNLOAD}" != "y" ]; then CT_DoLog EXTRA "Copying \"${file}\" from local copy" @@ -340,7 +343,7 @@ CT_GetFile() { done # Try to download it CT_DoLog EXTRA "Retrieving \"${file}\"" - for ext in .tar.bz2 .tar.gz .tgz .tar; do + for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do # Try all urls in turn for url in "$@"; do case "${url}" in -- cgit v0.10.2-6-g49f6