crosstool-ng/scripts/saveSample.sh
Yann E. MORIN" 0c4633c37f Get rid of all command (which is a bashism), and replace them with $(command), which is POSIX.
Get rid of all remaining \"text\" in log messages and replace them with 'text'.
Optimise the progress bar, should go un-noticed at log level DEBUG and below.

 /trunk/scripts/build/tools/200-sstrip.sh  |   16     8     8     0 ++--
 /trunk/scripts/build/libc_glibc.sh        |   50    25    25     0 +++++++-------
 /trunk/scripts/build/libc_uClibc.sh       |    4     2     2     0
 /trunk/scripts/build/debug/100-dmalloc.sh |    2     1     1     0
 /trunk/scripts/build/debug/400-ltrace.sh  |    2     1     1     0
 /trunk/scripts/build/debug/300-gdb.sh     |    8     4     4     0 +-
 /trunk/scripts/build/debug/200-duma.sh    |    6     3     3     0 +-
 /trunk/scripts/build/kernel_linux.sh      |   30    15    15     0 ++++----
 /trunk/scripts/build/cc_gcc.sh            |   14     7     7     0 ++--
 /trunk/scripts/crosstool.sh               |   54    27    27     0 ++++++++--------
 /trunk/scripts/functions                  |  128    64    64     0 ++++++++++++++++++------------------
 /trunk/scripts/saveSample.sh              |    4     2     2     0
 /trunk/scripts/tarball.sh.broken          |   20    10    10     0 +++---
 /trunk/tools/addToolVersion.sh            |    8     4     4     0 +-
 /trunk/tools/populate.in                  |   18     9     9     0 ++--
 15 files changed, 182 insertions(+), 182 deletions(-)
2008-05-20 21:32:39 +00:00

88 lines
3.0 KiB
Bash
Executable File

#!/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_LIB_DIR}/scripts/functions"
# Don't care about any log file
exec >/dev/null
rm -f "${tmp_log_file}"
# Parse the configuration file
CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
. "${CT_TOP_DIR}/.config"
# Parse the architecture-specific functions
. "${CT_LIB_DIR}/arch/${CT_ARCH}/functions"
# Target tuple: CT_TARGET needs a little love:
CT_DoBuildTargetTuple
# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
# re-parse them:
. "${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"
# Create the sample directory
if [ ! -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then
mkdir -p "${CT_TOP_DIR}/samples/${CT_TARGET}"
fi
# Save the crosstool-NG config file
cp "${CT_TOP_DIR}/.config" "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
# Function to copy a file to the sample directory
# Needed in case the file is already there (think of a previously available sample)
# Usage: CT_DoAddFileToSample <source> <dest>
CT_DoAddFileToSample() {
source="$1"
dest="$2"
inode_s=$(ls -i "${source}")
inode_d=$(ls -i "${dest}" 2>/dev/null || true)
if [ "${inode_s}" != "${inode_d}" ]; then
cp "${source}" "${dest}"
fi
}
if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then
samp_top_dir="\${CT_LIB_DIR}"
else
samp_top_dir="\${CT_TOP_DIR}"
fi
# 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
CT_DoAddFileToSample "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"
sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"'"${samp_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 rm -f "${f}"; 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
CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"'"${samp_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 rm -f "${f}"; fi
done
fi