diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2007-05-07 09:04:02 +0000 |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2007-05-07 09:04:02 +0000 |
commit | 58b4c6d0a44d57b15d7857ecb27711a2224949e9 (patch) | |
tree | a44e1c3fbeac57ff5601b1cbd1400172b3c64bbe /scripts/saveSample.sh | |
parent | 45e6df196be73e799e220810f9c48f8884d1049c (diff) | |
download | crosstool-ng-58b4c6d0a44d57b15d7857ecb27711a2224949e9.tar.gz crosstool-ng-58b4c6d0a44d57b15d7857ecb27711a2224949e9.tar.bz2 crosstool-ng-58b4c6d0a44d57b15d7857ecb27711a2224949e9.zip |
Merge the save-sample branch to trunk:
- reorder most of the environment setup,
- geting, extracting and patching are now components' sub-actions,
- save the current config as a sample to be used as a pre-configured target.
Diffstat (limited to 'scripts/saveSample.sh')
-rwxr-xr-x | scripts/saveSample.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/saveSample.sh b/scripts/saveSample.sh new file mode 100755 index 00000000..1d01c664 --- /dev/null +++ b/scripts/saveSample.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# This script is responsible for saving the current configuration into a +# sample to be used later on as a pre-configured target. + +# What we need to save: +# - the .config file +# - the kernel .config file if specified +# - the uClibc .config file if uClibc selected + +. "${CT_TOP_DIR}/scripts/functions" + +# Log to a temporary file until we have built our environment +CT_ACTUAL_LOG_FILE="${CT_TOP_DIR}/$$.log" +CT_LOG_INFO=y +CT_LOG_LEVEL_MAX="INFO" + +# Parse the configuration file +CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config" +. "${CT_TOP_DIR}/.config" + +# Override log level +unset CT_LOG_ERROR CT_LOG_WARN CT_LOG_EXTRA CT_LOG_DEBUG +CT_LOG_INFO=y +CT_LOG_LEVEL_MAX="INFO" + +# Target triplet: CT_TARGET needs a little love: +CT_DoBuildTargetTriplet + +# Create the sample directory +[ -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ] || svn mkdir "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1 + +# Save the crosstool-NG config file +cp "${CT_TOP_DIR}/.config" "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" + +# Save the kernel .config file +if [ -n "${CT_KERNEL_LINUX_CONFIG_FILE}" ]; then + # We save the file, and then point the saved sample to this file + cp "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config" + svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config" >/dev/null 2>&1 + sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \ + "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" +else + # remove any dangling files + for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-"*.config; do + if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi + done +fi + +# Save the uClibc .config file +if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then + # We save the file, and then point the saved sample to this file + cp "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config" + svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config" >/dev/null 2>&1 + sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \ + "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" +else + # remove any dangling files + for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-"*.config; do + if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi + done +fi + +# We could svn add earlier, but it's better to +# add a frozen file than modifying it later +svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" >/dev/null 2>&1 + +svn stat "${CT_TOP_DIR}/samples/${CT_TARGET}" 2>/dev/null |CT_DoLog INFO + +rm -f "${CT_ACTUAL_LOG_FILE}" |