# HG changeset patch # User "Yann E. MORIN" # Date 1245700389 -7200 # Node ID c9151c9ace1cbf21c918c6e8a3d6128243153aa6 # Parent f1ce1411d67104c6e08adaefb36329ed7ed4384f Check paths sanity before they get used. Don't use the PATHs before they get checked for sanity. diff -r f1ce1411d671 -r c9151c9ace1c scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Mon Jun 22 21:51:14 2009 +0200 +++ b/scripts/crosstool-NG.sh.in Mon Jun 22 21:53:09 2009 +0200 @@ -28,6 +28,31 @@ # Overide the locale early, in case we ever translate crosstool-NG messages [ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C +# Some sanity checks in the environment and needed tools +CT_DoLog INFO "Performing some trivial sanity checks" +CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}" +CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}" +CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}" +CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}" +export GREP_OPTIONS= + +# Some sanity checks on paths content +for d in \ + LOCAL_TARBALLS \ + WORK \ + PREFIX \ + INSTALL \ + ; do + eval dir="\${CT_${d}_DIR}" + case "${dir}" in + *" "*) +# CT_DoLog ERROR "'CT_${d}_DIR'='${dir}' contains a space in it." +# CT_Abort "Don't use spaces in paths, it breaks things." + CT_Abort "'CT_${d}_DIR'='${dir}' contains a space in it.\nDon't use spaces in paths, it breaks things." + ;; + esac +done + # Where will we work? CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/targets}" CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}" @@ -54,6 +79,7 @@ export PATH="${CT_BIN_OVERIDE_DIR}:${PATH}" # Start date. Can't be done until we know the locale +# Also requires the bin-override tools CT_STAR_DATE=$(CT_DoDate +%s%N) CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) @@ -67,20 +93,10 @@ CT_DoExecLog DEBUG grep -E '^(# |)CT_' .config CT_EndStep -# Some sanity checks in the environment and needed tools -CT_DoLog INFO "Checking environment sanity" - CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS" unset MAKEFLAGS export MAKEFLAGS -# Other environment sanity checks -CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}" -CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}" -CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}" -CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}" -export GREP_OPTIONS= - CT_DoLog INFO "Building environment variables" # Include sub-scripts instead of calling them: that way, we do not have to @@ -115,7 +131,7 @@ CT_CC_CORE_EXTRA_CONFIG="${CT_ARCH_CC_CORE_EXTRA_CONFIG} ${CT_CC_CORE_EXTRA_CONFIG}" CT_CC_EXTRA_CONFIG="${CT_ARCH_CC_EXTRA_CONFIG} ${CT_CC_EXTRA_CONFIG}" -# Create the working directories +# Compute the working directories names CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" CT_SRC_DIR="${CT_WORK_DIR}/src" CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build" @@ -146,22 +162,6 @@ CT_SAVE_TARBALLS= fi -# Some more sanity checks now that we have all paths set up -for d in \ - LOCAL_TARBALLS \ - WORK \ - PREFIX \ - INSTALL \ - ; do - eval dir="\${CT_${d}_DIR}" - case "${dir}" in - *" "*) - CT_DoLog ERROR "'CT_${d}_DIR'='${dir}' contains a space in it." - CT_Abort "Don't use spaces in paths, it breaks things." - ;; - esac -done - # Check now if we can write to the destination directory: if [ -d "${CT_INSTALL_DIR}" ]; then CT_TestAndAbort "Destination directory '${CT_INSTALL_DIR}' is not removable" ! -w $(dirname "${CT_INSTALL_DIR}")