summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
authorYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2007-07-12 19:52:09 (GMT)
committerYann E. MORIN" <yann.morin.1998@anciens.enib.fr>2007-07-12 19:52:09 (GMT)
commita464eeecda20fefa64490f6454aa5650de67f119 (patch)
tree26faabf938b57f8b4f3612f2b615c01a879c27f3 /scripts/functions
parent1e7411cce77b5f32b2f3fb6354de718f87f51b5d (diff)
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.
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions21
1 files changed, 12 insertions, 9 deletions
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 <filename> <url> [<url> ...]
+# Usage: CT_GetFile <filename> [extension] <url> [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