scripts/functions
changeset 1690 9030e84dafad
parent 1689 184a960d2fc8
child 1691 e0191807e79a
     1.1 --- a/scripts/functions	Wed Nov 25 20:36:04 2009 +0100
     1.2 +++ b/scripts/functions	Mon Nov 30 00:05:45 2009 +0100
     1.3 @@ -297,8 +297,8 @@
     1.4  
     1.5  # Get the file name extension of a component
     1.6  # Usage: CT_GetFileExtension <component_name-component_version> [extension]
     1.7 -# If found, echoes the extension to stdout
     1.8 -# If not found, echoes nothing on stdout.
     1.9 +# If found, echoes the extension to stdout, and return 0
    1.10 +# If not found, echoes nothing on stdout, and return !0.
    1.11  CT_GetFileExtension() {
    1.12      local ext
    1.13      local file="$1"
    1.14 @@ -311,11 +311,11 @@
    1.15      for ext in ${first_ext} .tar.gz .tar.bz2 .tgz .tar ''; do
    1.16          if [ -f "${CT_TARBALLS_DIR}/${file}${ext}" ]; then
    1.17              echo "${ext}"
    1.18 -            break
    1.19 +            exit 0
    1.20          fi
    1.21      done
    1.22  
    1.23 -    return 0
    1.24 +    exit 1
    1.25  }
    1.26  
    1.27  # Download an URL using wget
    1.28 @@ -389,8 +389,7 @@
    1.29      local ext
    1.30  
    1.31      # Do we already have it in *our* tarballs dir?
    1.32 -    ext=$(CT_GetFileExtension "${basename}" ${first_ext})
    1.33 -    if [ -n "${ext}" ]; then
    1.34 +    if ext="$( CT_GetFileExtension "${basename}" ${first_ext} )"; then
    1.35          CT_DoLog DEBUG "Already have '${basename}'"
    1.36          return 0
    1.37      fi
    1.38 @@ -571,8 +570,11 @@
    1.39  CT_Extract() {
    1.40      local basename="$1"
    1.41      local nochdir="$2"
    1.42 -    local ext=$(CT_GetFileExtension "${basename}")
    1.43 -    CT_TestAndAbort "'${basename}' not found in '${CT_TARBALLS_DIR}'" -z "${ext}"
    1.44 +    local ext
    1.45 +
    1.46 +    if ! ext="$(CT_GetFileExtension "${basename}")"; then
    1.47 +      CT_TestAndAbort "'${basename}' not found in '${CT_TARBALLS_DIR}'" -z "${ext}"
    1.48 +    fi
    1.49      local full_file="${CT_TARBALLS_DIR}/${basename}${ext}"
    1.50  
    1.51      # Check if already extracted