scripts/functions: test for decompressors before use
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed May 04 00:04:23 2011 +0200 (2011-05-04)
changeset 2608aa09a36c3d36
parent 2607 dda4742972e2
child 2609 409fe6b9ede2
scripts/functions: test for decompressors before use

./configure does check for the presence of gz and bzip2, so we can
safely use them in the build scripts.

On the other hand, more recent formats (eg. XZ) are not yet widely
available, and we do not want, and can't, force the user to install
them as a pre-requisite.

So, build up a list of allowed tarball formats based on the available
decompressors. For no, this is a static list, but the upcoming XZ
support will conditionnaly add to this list.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
scripts/functions
     1.1 --- a/scripts/functions	Wed Aug 10 23:13:46 2011 +0200
     1.2 +++ b/scripts/functions	Wed May 04 00:04:23 2011 +0200
     1.3 @@ -397,6 +397,14 @@
     1.4      export LD_LIBRARY_PATH
     1.5  }
     1.6  
     1.7 +# Build up the list of allowed tarball extensions
     1.8 +# Add them in the prefered order; most preferred comes first
     1.9 +CT_DoListTarballExt() {
    1.10 +    printf ".tar.bz2\n"
    1.11 +    printf ".tar.gz\n.tgz\n"
    1.12 +    printf ".tar\n"
    1.13 +}
    1.14 +
    1.15  # Get the file name extension of a component
    1.16  # Usage: CT_GetFileExtension <component_name-component_version> [extension]
    1.17  # If found, echoes the extension to stdout, and return 0
    1.18 @@ -410,7 +418,7 @@
    1.19      # we need to also check for an empty extension for those very
    1.20      # peculiar components that don't have one (such as sstrip from
    1.21      # buildroot).
    1.22 -    for ext in ${first_ext} .tar.gz .tar.bz2 .tgz .tar /.git ''; do
    1.23 +    for ext in ${first_ext} $(CT_DoListTarballExt) /.git ''; do
    1.24          if [ -e "${CT_TARBALLS_DIR}/${file}${ext}" ]; then
    1.25              echo "${ext}"
    1.26              exit 0
    1.27 @@ -480,7 +488,7 @@
    1.28          CT_DoLog DEBUG "Trying to retrieve an already downloaded copy of '${basename}'"
    1.29          # We'd rather have a bzip2'ed tarball, then gzipped tarball, plain tarball,
    1.30          # or, as a failover, a file without extension.
    1.31 -        for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
    1.32 +        for ext in ${first_ext} $(CT_DoListTarballExt) ''; do
    1.33              CT_DoLog DEBUG "Trying '${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}'"
    1.34              if [ -r "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" -a \
    1.35                   "${CT_FORCE_DOWNLOAD}" != "y" ]; then
    1.36 @@ -549,7 +557,7 @@
    1.37      # Scan all URLs in turn, and try to grab a tarball from there
    1.38      # Do *not* try git trees (ext=/.git), this is handled in a specific
    1.39      # wrapper, below
    1.40 -    for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
    1.41 +    for ext in ${first_ext} $(CT_DoListTarballExt) ''; do
    1.42          # Try all urls in turn
    1.43          for url in "${URLS[@]}"; do
    1.44              [ -n "${url}" ] || continue
    1.45 @@ -745,9 +753,9 @@
    1.46      tar_opts+=( "-C" "${basename}" )
    1.47      tar_opts+=( "-xv" )
    1.48      case "${ext}" in
    1.49 -        .tar.bz2)     CT_DoExecLog FILE tar "${tar_opts[@]}" -j "${full_file}";;
    1.50 -        .tar.gz|.tgz) CT_DoExecLog FILE tar "${tar_opts[@]}" -z "${full_file}";;
    1.51 -        .tar)         CT_DoExecLog FILE tar "${tar_opts[@]}" "${full_file}";;
    1.52 +        .tar.bz2)     CT_DoExecLog FILE tar "${tar_opts[@]}" -j -f "${full_file}";;
    1.53 +        .tar.gz|.tgz) CT_DoExecLog FILE tar "${tar_opts[@]}" -z -f "${full_file}";;
    1.54 +        .tar)         CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}";;
    1.55          /.git)        CT_ExtractGit "${basename}" "${@}";;
    1.56          *)            CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension"
    1.57                        return 1