1.1 --- a/scripts/functions Fri May 25 19:30:42 2007 +0000
1.2 +++ b/scripts/functions Sun May 27 20:29:22 2007 +0000
1.3 @@ -2,6 +2,7 @@
1.4 # Copyright 2007 Yann E. MORIN
1.5 # Licensed under the GPL v2. See COPYING in the root of this package
1.6
1.7 +# Prepare the fault handler
1.8 CT_OnError() {
1.9 ret=$?
1.10 CT_DoLog ERROR "Build failed in step \"${CT_STEP_MESSAGE[${CT_STEP_COUNT}]}\""
1.11 @@ -17,11 +18,23 @@
1.12 CT_DoEnd ERROR
1.13 exit $ret
1.14 }
1.15 +
1.16 +# Install the fault handler
1.17 trap CT_OnError ERR
1.18
1.19 +# Inherit the fault handler in subshells and functions
1.20 set -E
1.21 +
1.22 +# Make pipes fail on the _first_ failed command
1.23 +# Not supported on bash < 3.x, but we need it, so drop the obsoleting bash-2.x
1.24 set -o pipefail
1.25
1.26 +# Don't hash commands' locations, and search every time it is requested.
1.27 +# This is slow, but needed because of the static/shared core gcc which shall
1.28 +# always match to shared if it exists, and only fallback to static if the
1.29 +# shared is not found
1.30 +set +o hashall
1.31 +
1.32 # The different log levels:
1.33 CT_LOG_LEVEL_ERROR=0
1.34 CT_LOG_LEVEL_WARN=1
1.35 @@ -392,8 +405,16 @@
1.36 # a libc addon, or a plain package. Apply patches now.
1.37 CT_DoLog EXTRA "Patching \"${file}\""
1.38
1.39 - # If libc addon, we're already in the correct place.
1.40 - [ -z "${libc_addon}" ] && cd "${file}"
1.41 + if [ "${libc_addon}" = "y" ]; then
1.42 + # Some addons tarball directly contian the correct addon directory,
1.43 + # while others have the addon directory named ofter the tarball.
1.44 + # Fix that bu always using the short name (eg: linuxthreads, ports, etc...)
1.45 + addon_short_name=`echo "${file}" |sed -r -e 's/^[^-]+-//; s/-[^-]+$//;'`
1.46 + [ -d "${addon_short_name}" ] || ln -s "${file}" "${addon_short_name}"
1.47 + # If libc addon, we're already in the correct place
1.48 + else
1.49 + cd "${file}"
1.50 + fi
1.51
1.52 [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}"
1.53 [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
1.54 @@ -493,14 +514,19 @@
1.55 $0 == "}" { _p = 1; }
1.56 ' |egrep -v '^[^ ]+ \(\)' >"${state_dir}/env.sh"
1.57
1.58 - CT_DoLog DEBUG " Saving CT_CC_CORE_PREFIX_DIR=\"${CT_CC_CORE_PREFIX_DIR}\""
1.59 - CT_Pushd "${CT_CC_CORE_PREFIX_DIR}"
1.60 - tar ${tar_opt} "${state_dir}/cc_core_prefix_dir${tar_ext}" .
1.61 + CT_DoLog DEBUG " Saving CT_CC_CORE_STATIC_PREFIX_DIR=\"${CT_CC_CORE_STATIC_PREFIX_DIR}\""
1.62 + CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
1.63 + tar ${tar_opt} "${state_dir}/cc_core_static_prefix_dir${tar_ext}" .
1.64 + CT_Popd
1.65 +
1.66 + CT_DoLog DEBUG " Saving CT_CC_CORE_SHARED_PREFIX_DIR=\"${CT_CC_CORE_SHARED_PREFIX_DIR}\""
1.67 + CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
1.68 + tar ${tar_opt} "${state_dir}/cc_core_shared_prefix_dir${tar_ext}" .
1.69 CT_Popd
1.70
1.71 CT_DoLog DEBUG " Saving CT_PREFIX_DIR=\"${CT_PREFIX_DIR}\""
1.72 CT_Pushd "${CT_PREFIX_DIR}"
1.73 - tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}" .
1.74 + tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}" --exclude '*.log' .
1.75 CT_Popd
1.76
1.77 if [ "${CT_LOG_TO_FILE}" = "y" ]; then
1.78 @@ -514,7 +540,7 @@
1.79 fi
1.80 }
1.81
1.82 -# This functions restores a previously saved state
1.83 +# This function restores a previously saved state
1.84 # Usage: CT_DoLoadState <state_name>
1.85 CT_DoLoadState(){
1.86 local state_name="$1"
1.87 @@ -534,18 +560,23 @@
1.88 esac
1.89
1.90 CT_DoLog DEBUG " Removing previous build directories"
1.91 - chmod -R u+rwX "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
1.92 - rm -rf "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
1.93 - mkdir -p "${CT_PREFIX_DIR}" "${CT_CC_CORE_PREFIX_DIR}"
1.94 + chmod -R u+rwX "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}"
1.95 + rm -rf "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}"
1.96 + mkdir -p "${CT_PREFIX_DIR}" "${CT_CC_CORE_SHARED_PREFIX_DIR}" "${CT_CC_CORE_STATIC_PREFIX_DIR}"
1.97
1.98 CT_DoLog DEBUG " Restoring CT_PREFIX_DIR=\"${CT_PREFIX_DIR}\""
1.99 CT_Pushd "${CT_PREFIX_DIR}"
1.100 tar ${tar_opt} "${state_dir}/prefix_dir${tar_ext}"
1.101 CT_Popd
1.102
1.103 - CT_DoLog DEBUG " Restoring CT_CC_CORE_PREFIX_DIR=\"${CT_CC_CORE_PREFIX_DIR}\""
1.104 - CT_Pushd "${CT_CC_CORE_PREFIX_DIR}"
1.105 - tar ${tar_opt} "${state_dir}/cc_core_prefix_dir${tar_ext}"
1.106 + CT_DoLog DEBUG " Restoring CT_CC_CORE_SHARED_PREFIX_DIR=\"${CT_CC_CORE_SHARED_PREFIX_DIR}\""
1.107 + CT_Pushd "${CT_CC_CORE_SHARED_PREFIX_DIR}"
1.108 + tar ${tar_opt} "${state_dir}/cc_core_shared_prefix_dir${tar_ext}"
1.109 + CT_Popd
1.110 +
1.111 + CT_DoLog DEBUG " Restoring CT_CC_CORE_STATIC_PREFIX_DIR=\"${CT_CC_CORE_STATIC_PREFIX_DIR}\""
1.112 + CT_Pushd "${CT_CC_CORE_STATIC_PREFIX_DIR}"
1.113 + tar ${tar_opt} "${state_dir}/cc_core_static_prefix_dir${tar_ext}"
1.114 CT_Popd
1.115
1.116 # Restore the environment, discarding any error message