Update the way we handle directories supplied by the user:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu May 10 21:33:35 2007 +0000 (2007-05-10)
changeset 85ac2845835b13
parent 84 dcb02306a338
child 86 2fc16aeb1622
Update the way we handle directories supplied by the user:
- the tarball directory is considered as a local copy, and tarballs are copied to a working area,
- the sources and build directories (CT_SRC_DIR and CT_BUILD_DIR) are now computed, and no longer an option,
- the build dir has been renamed from 'build' to 'targets'.
That should ease preparing a tarball of the resulting target.
Makefile
config/global.in
samples/armeb-unknown-linux-gnu/crosstool.config
samples/armeb-unknown-linux-uclibc/crosstool.config
samples/i586-geode-linux-uclibc/crosstool.config
samples/mips-unknown-linux-uclibc/crosstool.config
scripts/crosstool.sh
scripts/functions
     1.1 --- a/Makefile	Thu May 10 16:22:44 2007 +0000
     1.2 +++ b/Makefile	Thu May 10 21:33:35 2007 +0000
     1.3 @@ -11,7 +11,7 @@
     1.4  export CT_TOP_DIR=$(shell pwd)
     1.5  
     1.6  .PHONY: all
     1.7 -all: _ct_build
     1.8 +all: build
     1.9  
    1.10  HOST_CC = gcc -funsigned-char
    1.11  
    1.12 @@ -39,10 +39,10 @@
    1.13  	@test -f .config
    1.14  
    1.15  # Actual build
    1.16 -_ct_build: .config
    1.17 +build: .config
    1.18  	@$(CT_TOP_DIR)/scripts/crosstool.sh
    1.19  
    1.20  .PHONY: distclean
    1.21  distclean:: clean
    1.22  	@rm -f .config* ..config.tmp
    1.23 -	@rm -rf "$(CT_TOP_DIR)/build"
    1.24 +	@rm -rf "$(CT_TOP_DIR)/targets"
     2.1 --- a/config/global.in	Thu May 10 16:22:44 2007 +0000
     2.2 +++ b/config/global.in	Thu May 10 21:33:35 2007 +0000
     2.3 @@ -70,38 +70,13 @@
     2.4  
     2.5  comment "Paths"
     2.6  
     2.7 -config TARBALLS_DIR
     2.8 +config LOCAL_TARBALLS_DIR
     2.9      string
    2.10 -    prompt "Tarballs directory"
    2.11 -    default "${CT_TOP_DIR}/build/tarballs"
    2.12 +    prompt "Local tarballs directory"
    2.13 +    default ""
    2.14      help
    2.15 -      This is the directory into which tarballs are going to be stored once
    2.16 -      they are downloaded (or otherwise retrieved).
    2.17 -
    2.18 -config SRC_DIR
    2.19 -    string
    2.20 -    prompt "Extract directory"
    2.21 -    default "${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/src"
    2.22 -    help
    2.23 -      This is the directory into which tarballs will be extracted.
    2.24 -      
    2.25 -      If you will build multiple toolchains, you should arrange to have one
    2.26 -      SRC_DIR for each toolchain, as different targets may require different
    2.27 -      patches to be applied.
    2.28 -
    2.29 -      You should not need to change this from the default.
    2.30 -
    2.31 -config BUILD_DIR
    2.32 -    string
    2.33 -    prompt "Build directory"
    2.34 -    default "${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/build"
    2.35 -    help
    2.36 -      This is the directory into which builds will occur.
    2.37 -      
    2.38 -      Once again, arrange for one build directory for each toolchain you build,
    2.39 -      to avoid collision.
    2.40 -
    2.41 -      You should not need to change this from the default.
    2.42 +      If you have previously downloaded the tarballs, enter the PATH where
    2.43 +      you stored them here.
    2.44  
    2.45  config PREFIX_DIR
    2.46      string
     3.1 --- a/samples/armeb-unknown-linux-gnu/crosstool.config	Thu May 10 16:22:44 2007 +0000
     3.2 +++ b/samples/armeb-unknown-linux-gnu/crosstool.config	Thu May 10 21:33:35 2007 +0000
     3.3 @@ -1,7 +1,7 @@
     3.4  #
     3.5  # Automatically generated make config: don't edit
     3.6  # crosstool-NG version: 0.0.2-svn
     3.7 -# Tue May  8 18:48:51 2007
     3.8 +# Thu May 10 23:28:59 2007
     3.9  #
    3.10  
    3.11  #
    3.12 @@ -17,9 +17,7 @@
    3.13  #
    3.14  # Paths
    3.15  #
    3.16 -CT_TARBALLS_DIR="${HOME}/dev/src"
    3.17 -CT_SRC_DIR="${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/src"
    3.18 -CT_BUILD_DIR="${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/build"
    3.19 +CT_LOCAL_TARBALLS_DIR="${HOME}/dev/src"
    3.20  CT_PREFIX_DIR="/opt/x-tools/${CT_TARGET}"
    3.21  CT_INSTALL_DIR="${CT_PREFIX_DIR}"
    3.22  # CT_CUSTOM_PATCH is not set
     4.1 --- a/samples/armeb-unknown-linux-uclibc/crosstool.config	Thu May 10 16:22:44 2007 +0000
     4.2 +++ b/samples/armeb-unknown-linux-uclibc/crosstool.config	Thu May 10 21:33:35 2007 +0000
     4.3 @@ -1,7 +1,7 @@
     4.4  #
     4.5  # Automatically generated make config: don't edit
     4.6  # crosstool-NG version: 0.0.2-svn
     4.7 -# Mon May  7 23:45:42 2007
     4.8 +# Thu May 10 23:29:27 2007
     4.9  #
    4.10  
    4.11  #
    4.12 @@ -17,9 +17,7 @@
    4.13  #
    4.14  # Paths
    4.15  #
    4.16 -CT_TARBALLS_DIR="${HOME}/dev/src"
    4.17 -CT_SRC_DIR="${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/src"
    4.18 -CT_BUILD_DIR="${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/build"
    4.19 +CT_LOCAL_TARBALLS_DIR="${HOME}/dev/src"
    4.20  CT_PREFIX_DIR="/opt/x-tools/${CT_TARGET}"
    4.21  CT_INSTALL_DIR="${CT_PREFIX_DIR}"
    4.22  # CT_CUSTOM_PATCH is not set
    4.23 @@ -45,6 +43,7 @@
    4.24  # CT_LOG_INFO is not set
    4.25  CT_LOG_EXTRA=y
    4.26  # CT_LOG_DEBUG is not set
    4.27 +# CT_LOG_ALL is not set
    4.28  CT_LOG_LEVEL_MAX="EXTRA"
    4.29  # CT_LOG_SEE_TOOLS_WARN is not set
    4.30  # CT_LOG_PROGRESS_BAR is not set
     5.1 --- a/samples/i586-geode-linux-uclibc/crosstool.config	Thu May 10 16:22:44 2007 +0000
     5.2 +++ b/samples/i586-geode-linux-uclibc/crosstool.config	Thu May 10 21:33:35 2007 +0000
     5.3 @@ -1,7 +1,7 @@
     5.4  #
     5.5  # Automatically generated make config: don't edit
     5.6  # crosstool-NG version: 0.0.2-svn
     5.7 -# Tue May  8 00:10:27 2007
     5.8 +# Thu May 10 23:29:48 2007
     5.9  #
    5.10  
    5.11  #
    5.12 @@ -17,9 +17,7 @@
    5.13  #
    5.14  # Paths
    5.15  #
    5.16 -CT_TARBALLS_DIR="${HOME}/dev/src"
    5.17 -CT_SRC_DIR="${HOME}/x-tools/src/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}"
    5.18 -CT_BUILD_DIR="${HOME}/x-tools/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}"
    5.19 +CT_LOCAL_TARBALLS_DIR="${HOME}/dev/src"
    5.20  CT_PREFIX_DIR="${HOME}/x-tools/${CT_TARGET}"
    5.21  CT_INSTALL_DIR="${CT_PREFIX_DIR}"
    5.22  # CT_CUSTOM_PATCH is not set
    5.23 @@ -45,6 +43,7 @@
    5.24  # CT_LOG_INFO is not set
    5.25  CT_LOG_EXTRA=y
    5.26  # CT_LOG_DEBUG is not set
    5.27 +# CT_LOG_ALL is not set
    5.28  CT_LOG_LEVEL_MAX="EXTRA"
    5.29  # CT_LOG_SEE_TOOLS_WARN is not set
    5.30  # CT_LOG_PROGRESS_BAR is not set
     6.1 --- a/samples/mips-unknown-linux-uclibc/crosstool.config	Thu May 10 16:22:44 2007 +0000
     6.2 +++ b/samples/mips-unknown-linux-uclibc/crosstool.config	Thu May 10 21:33:35 2007 +0000
     6.3 @@ -1,7 +1,7 @@
     6.4  #
     6.5  # Automatically generated make config: don't edit
     6.6  # crosstool-NG version: 0.0.2-svn
     6.7 -# Mon May  7 23:45:56 2007
     6.8 +# Thu May 10 23:30:10 2007
     6.9  #
    6.10  
    6.11  #
    6.12 @@ -17,9 +17,7 @@
    6.13  #
    6.14  # Paths
    6.15  #
    6.16 -CT_TARBALLS_DIR="${HOME}/dev/src"
    6.17 -CT_SRC_DIR="${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/src"
    6.18 -CT_BUILD_DIR="${CT_TOP_DIR}/build/${CT_TARGET}/${CT_CC}-${CT_CC_VERSION}-${CT_LIBC}-${CT_LIBC_VERSION}/build"
    6.19 +CT_LOCAL_TARBALLS_DIR="${HOME}/dev/src"
    6.20  CT_PREFIX_DIR="/opt/x-tools/${CT_TARGET}"
    6.21  CT_INSTALL_DIR="${CT_PREFIX_DIR}"
    6.22  # CT_CUSTOM_PATCH is not set
    6.23 @@ -45,6 +43,7 @@
    6.24  # CT_LOG_INFO is not set
    6.25  CT_LOG_EXTRA=y
    6.26  # CT_LOG_DEBUG is not set
    6.27 +# CT_LOG_ALL is not set
    6.28  CT_LOG_LEVEL_MAX="EXTRA"
    6.29  # CT_LOG_SEE_TOOLS_WARN is not set
    6.30  # CT_LOG_PROGRESS_BAR is not set
     7.1 --- a/scripts/crosstool.sh	Thu May 10 16:22:44 2007 +0000
     7.2 +++ b/scripts/crosstool.sh	Thu May 10 21:33:35 2007 +0000
     7.3 @@ -118,16 +118,56 @@
     7.4  # then rescan the options file now:
     7.5  . "${CT_TOP_DIR}/.config"
     7.6  
     7.7 +# Where will we work?
     7.8 +CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
     7.9 +CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
    7.10 +CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
    7.11 +
    7.12 +# Make all path absolute, it so much easier!
    7.13 +CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
    7.14 +
    7.15  # Some more sanity checks now that we have all paths set up
    7.16  case "${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
    7.17      *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
    7.18  esac
    7.19  
    7.20 +# Check now if we can write to the destination directory:
    7.21 +if [ -d "${CT_INSTALL_DIR}" ]; then
    7.22 +    CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
    7.23 +fi
    7.24 +
    7.25 +# Get rid of pre-existing installed toolchain and previous build directories.
    7.26 +# We need to do that _before_ we can safely log, because the log file will
    7.27 +# most probably be in the toolchain directory.
    7.28 +if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
    7.29 +    mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
    7.30 +    nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
    7.31 +fi
    7.32 +if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
    7.33 +    mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
    7.34 +    nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
    7.35 +fi
    7.36 +if [ -d "${CT_BUILD_DIR}" ]; then
    7.37 +    mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
    7.38 +    nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
    7.39 +fi
    7.40 +if [ -d "${CT_INSTALL_DIR}" ]; then
    7.41 +    mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
    7.42 +    nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
    7.43 +fi
    7.44 +
    7.45  # Note: we'll always install the core compiler in its own directory, so as to
    7.46  # not mix the two builds: core and final. Anyway, its generic, wether we use
    7.47  # a different compiler as core, or not.
    7.48  CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
    7.49  
    7.50 +# Create the directories we'll use
    7.51 +mkdir -p "${CT_TARBALLS_DIR}"
    7.52 +mkdir -p "${CT_SRC_DIR}"
    7.53 +mkdir -p "${CT_BUILD_DIR}"
    7.54 +mkdir -p "${CT_INSTALL_DIR}"
    7.55 +mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
    7.56 +
    7.57  # Good, now grab a bit of informations on the system we're being run,
    7.58  # just in case something goes awok, and it's not our fault:
    7.59  CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
    7.60 @@ -144,36 +184,6 @@
    7.61  CT_SYS_GCC=`gcc -dumpversion`
    7.62  CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_SYS_DATE} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME} for ${CT_TARGET}"
    7.63  
    7.64 -# Check now if we can write to the destination directory:
    7.65 -if [ -d "${CT_INSTALL_DIR}" ]; then
    7.66 -    CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
    7.67 -fi
    7.68 -
    7.69 -# Get rid of pre-existing installed toolchain and previous build directories.
    7.70 -# We need to do that _before_ we can safely log, because the log file will
    7.71 -# most probably be in the toolchain directory.
    7.72 -if [ -d "${CT_INSTALL_DIR}" ]; then
    7.73 -    mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
    7.74 -    nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
    7.75 -fi
    7.76 -if [ -d "${CT_BUILD_DIR}" ]; then
    7.77 -    mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
    7.78 -    nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
    7.79 -fi
    7.80 -if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
    7.81 -    mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
    7.82 -    nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
    7.83 -fi
    7.84 -mkdir -p "${CT_INSTALL_DIR}"
    7.85 -mkdir -p "${CT_BUILD_DIR}"
    7.86 -mkdir -p "${CT_TARBALLS_DIR}"
    7.87 -mkdir -p "${CT_SRC_DIR}"
    7.88 -
    7.89 -# Make all path absolute, it so much easier!
    7.90 -# Now we have had the directories created, we even will get rid of embedded .. in paths:
    7.91 -CT_SRC_DIR="`CT_MakeAbsolutePath \"${CT_SRC_DIR}\"`"
    7.92 -CT_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_TARBALLS_DIR}\"`"
    7.93 -
    7.94  # Redirect log to the actual log file now we can
    7.95  # It's quite understandable that the log file will be installed in the install
    7.96  # directory, so we must first ensure it exists and is writeable (above) before
    7.97 @@ -312,16 +322,14 @@
    7.98  . "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
    7.99  
   7.100  # Now for the job by itself. Go have a coffee!
   7.101 -if [ "${CT_NO_DOWNLOAD}" != "y" ]; then
   7.102 -	CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   7.103 -    do_kernel_get
   7.104 -    do_binutils_get
   7.105 -    do_cc_core_get
   7.106 -    do_libfloat_get
   7.107 -    do_libc_get
   7.108 -    do_cc_get
   7.109 -    CT_EndStep
   7.110 -fi
   7.111 +CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   7.112 +do_kernel_get
   7.113 +do_binutils_get
   7.114 +do_cc_core_get
   7.115 +do_libfloat_get
   7.116 +do_libc_get
   7.117 +do_cc_get
   7.118 +CT_EndStep
   7.119  
   7.120  if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
   7.121      if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
   7.122 @@ -348,25 +356,27 @@
   7.123          do_libc
   7.124          do_cc
   7.125          do_libc_finish
   7.126 +
   7.127 +        # Create the aliases to the target tools
   7.128 +        if [ -n "${CT_TARGET_ALIAS}" ]; then
   7.129 +            CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
   7.130 +            CT_Pushd "${CT_PREFIX_DIR}/bin"
   7.131 +            for t in "${CT_TARGET}-"*; do
   7.132 +                _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
   7.133 +                CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
   7.134 +                ln -s "${t}" "${_t}"
   7.135 +            done
   7.136 +            CT_Popd
   7.137 +        fi
   7.138 +
   7.139 +        # Remove the generated documentation files
   7.140 +        if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   7.141 +        	CT_DoLog INFO "Removing installed documentation"
   7.142 +            rm -rf "${CT_PREFIX_DIR}/"{man,info}
   7.143 +        fi
   7.144      fi
   7.145  fi
   7.146  
   7.147 -if [ -n "${CT_TARGET_ALIAS}" ]; then
   7.148 -    CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
   7.149 -    CT_Pushd "${CT_PREFIX_DIR}/bin"
   7.150 -    for t in "${CT_TARGET}-"*; do
   7.151 -        _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
   7.152 -        CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
   7.153 -        ln -s "${t}" "${_t}"
   7.154 -    done
   7.155 -    CT_Popd
   7.156 -fi
   7.157 -
   7.158 -if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   7.159 -	CT_DoLog INFO "Removing installed documentation"
   7.160 -    rm -rf "${CT_PREFIX_DIR}/"{man,info}
   7.161 -fi
   7.162 -
   7.163  CT_STOP_DATE=`CT_DoDate +%s%N`
   7.164  CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
   7.165  CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
     8.1 --- a/scripts/functions	Thu May 10 16:22:44 2007 +0000
     8.2 +++ b/scripts/functions	Thu May 10 21:33:35 2007 +0000
     8.3 @@ -229,6 +229,28 @@
     8.4      yes "$1" || true
     8.5  }
     8.6  
     8.7 +# Get the file name extension of a component
     8.8 +# Usage: CT_GetFileExtension <component_name-component_version>
     8.9 +# If found, echoes the extension to stdout
    8.10 +# If not found, echoes nothing on stdout.
    8.11 +CT_GetFileExtension() {
    8.12 +    local ext
    8.13 +    local file="$1"
    8.14 +    local got_it=1
    8.15 +
    8.16 +    CT_Pushd "${CT_TARBALLS_DIR}"
    8.17 +    for ext in .tar.gz .tar.bz2 .tgz .tar; do
    8.18 +        if [ -f "${file}${ext}" ]; then
    8.19 +            echo "${ext}"
    8.20 +            got_it=0
    8.21 +            break
    8.22 +        fi
    8.23 +    done
    8.24 +    CT_Popd
    8.25 +
    8.26 +    return 0
    8.27 +}
    8.28 +
    8.29  # Download an URL using wget
    8.30  # Usage: CT_DoGetFileWget <URL>
    8.31  CT_DoGetFileWget() {
    8.32 @@ -276,58 +298,39 @@
    8.33      # Do we already have it?
    8.34      ext=`CT_GetFileExtension "${file}"`
    8.35      if [ -n "${ext}" ]; then
    8.36 -        if [ "${CT_FORCE_DOWNLOAD}" = "y" ]; then
    8.37 -            CT_DoLog DEBUG "Removing already present \"${file}\""
    8.38 -            rm -f "${CT_TARBALLS_DIR}/${file}${ext}"
    8.39 -        else
    8.40 -            CT_DoLog DEBUG "Already have \"${file}\""
    8.41 -            return 0
    8.42 -        fi
    8.43 +        CT_DoLog DEBUG "Already have \"${file}\""
    8.44 +        return 0
    8.45      fi
    8.46  
    8.47      CT_DoLog EXTRA "Retrieving \"${file}\""
    8.48      CT_Pushd "${CT_TARBALLS_DIR}"
    8.49      # File not yet downloaded, try to get it
    8.50      got_it=0
    8.51 -    if [ "${got_it}" != "y" ]; then
    8.52 -        # We'd rather have a bzip2'ed tarball, then gzipped, and finally plain tar.
    8.53 -        for ext in .tar.bz2 .tar.gz .tgz .tar; do
    8.54 -            # Try all urls in turn
    8.55 -            for url in "$@"; do
    8.56 -                case "${url}" in
    8.57 -                    *)  CT_DoLog DEBUG "Trying \"${url}/${file}${ext}\""
    8.58 -                        CT_DoGetFile "${url}/${file}${ext}"
    8.59 -                        ;;
    8.60 -                esac
    8.61 -                [ -f "${file}${ext}" ] && got_it=1 && break 2 || true
    8.62 -            done
    8.63 -        done
    8.64 -    fi
    8.65 -    CT_Popd
    8.66 -
    8.67 -    CT_TestAndAbort "Could not download \"${file}\", and not present in \"${CT_TARBALLS_DIR}\"" ${got_it} -eq 0
    8.68 -}
    8.69 -
    8.70 -# Get the file name extension of a component
    8.71 -# Usage: CT_GetFileExtension <component_name-component_version>
    8.72 -# If found, echoes the extension to stdout
    8.73 -# If not found, echoes nothing on stdout.
    8.74 -CT_GetFileExtension() {
    8.75 -    local ext
    8.76 -    local file="$1"
    8.77 -    local got_it=1
    8.78 -
    8.79 -    CT_Pushd "${CT_TARBALLS_DIR}"
    8.80 -    for ext in .tar.gz .tar.bz2 .tgz .tar; do
    8.81 -        if [ -f "${file}${ext}" ]; then
    8.82 -            echo "${ext}"
    8.83 -            got_it=0
    8.84 -            break
    8.85 +    # We'd rather have a bzip2'ed tarball, then gzipped, and finally plain tar.
    8.86 +    for ext in .tar.bz2 .tar.gz .tgz .tar; do
    8.87 +        if [ ${got_it} -ne 1 ]; then
    8.88 +            # Try local copy first, if it exists
    8.89 +            if [ -r "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" -a \
    8.90 +                 "${CT_FORCE_DOWNLOAD}" != "y" ]; then
    8.91 +                cp -v "${CT_LOCAL_TARBALLS_DIR}/${file}${ext}" "${file}${ext}" |CT_DoLog DEBUG
    8.92 +                got_it=1
    8.93 +                break 1
    8.94 +            else
    8.95 +                # Try all urls in turn
    8.96 +                for url in "$@"; do
    8.97 +                    case "${url}" in
    8.98 +                        *)  CT_DoLog DEBUG "Trying \"${url}/${file}${ext}\""
    8.99 +                            CT_DoGetFile "${url}/${file}${ext}"
   8.100 +                            ;;
   8.101 +                    esac
   8.102 +                    [ -f "${file}${ext}" ] && got_it=1 && break 2 || true
   8.103 +                done
   8.104 +            fi
   8.105          fi
   8.106      done
   8.107      CT_Popd
   8.108  
   8.109 -    return 0
   8.110 +    CT_TestAndAbort "Could not download \"${file}\", and not present in \"${CT_LOCAL_TARBALLS_DIR}\"" ${got_it} -eq 0
   8.111  }
   8.112  
   8.113  # Extract a tarball and patch the resulting sources if necessary.