# HG changeset patch # User "Yann E. MORIN" # Date 1304460263 -7200 # Node ID aa09a36c3d360ef39e4e9c41ea0cb4520e8a6945 # Parent dda4742972e2930e3e4988b4cfb64265fb5d826d 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" diff -r dda4742972e2 -r aa09a36c3d36 scripts/functions --- a/scripts/functions Wed Aug 10 23:13:46 2011 +0200 +++ b/scripts/functions Wed May 04 00:04:23 2011 +0200 @@ -397,6 +397,14 @@ export LD_LIBRARY_PATH } +# Build up the list of allowed tarball extensions +# Add them in the prefered order; most preferred comes first +CT_DoListTarballExt() { + printf ".tar.bz2\n" + printf ".tar.gz\n.tgz\n" + printf ".tar\n" +} + # Get the file name extension of a component # Usage: CT_GetFileExtension [extension] # If found, echoes the extension to stdout, and return 0 @@ -410,7 +418,7 @@ # we need to also check for an empty extension for those very # peculiar components that don't have one (such as sstrip from # buildroot). - for ext in ${first_ext} .tar.gz .tar.bz2 .tgz .tar /.git ''; do + for ext in ${first_ext} $(CT_DoListTarballExt) /.git ''; do if [ -e "${CT_TARBALLS_DIR}/${file}${ext}" ]; then echo "${ext}" exit 0 @@ -480,7 +488,7 @@ CT_DoLog DEBUG "Trying to retrieve an already downloaded copy of '${basename}'" # We'd rather have a bzip2'ed tarball, then gzipped tarball, plain tarball, # or, as a failover, a file without extension. - for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do + for ext in ${first_ext} $(CT_DoListTarballExt) ''; do CT_DoLog DEBUG "Trying '${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}'" if [ -r "${CT_LOCAL_TARBALLS_DIR}/${basename}${ext}" -a \ "${CT_FORCE_DOWNLOAD}" != "y" ]; then @@ -549,7 +557,7 @@ # Scan all URLs in turn, and try to grab a tarball from there # Do *not* try git trees (ext=/.git), this is handled in a specific # wrapper, below - for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do + for ext in ${first_ext} $(CT_DoListTarballExt) ''; do # Try all urls in turn for url in "${URLS[@]}"; do [ -n "${url}" ] || continue @@ -745,9 +753,9 @@ tar_opts+=( "-C" "${basename}" ) tar_opts+=( "-xv" ) case "${ext}" in - .tar.bz2) CT_DoExecLog FILE tar "${tar_opts[@]}" -j "${full_file}";; - .tar.gz|.tgz) CT_DoExecLog FILE tar "${tar_opts[@]}" -z "${full_file}";; - .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" "${full_file}";; + .tar.bz2) CT_DoExecLog FILE tar "${tar_opts[@]}" -j -f "${full_file}";; + .tar.gz|.tgz) CT_DoExecLog FILE tar "${tar_opts[@]}" -z -f "${full_file}";; + .tar) CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}";; /.git) CT_ExtractGit "${basename}" "${@}";; *) CT_DoLog WARN "Don't know how to handle '${basename}${ext}': unknown extension" return 1