2007-05-07 09:04:02 +00:00
|
|
|
#!/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
|
|
|
|
|
2007-07-01 19:04:20 +00:00
|
|
|
. "${CT_LIB_DIR}/scripts/functions"
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2007-06-16 22:23:53 +00:00
|
|
|
# Don't care about any log file
|
2007-05-22 20:33:43 +00:00
|
|
|
exec >/dev/null
|
2007-06-16 22:23:53 +00:00
|
|
|
rm -f "${tmp_log_file}"
|
2007-05-10 16:22:44 +00:00
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Parse the configuration file
|
|
|
|
CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
|
|
|
|
. "${CT_TOP_DIR}/.config"
|
|
|
|
|
|
|
|
# Target triplet: CT_TARGET needs a little love:
|
|
|
|
CT_DoBuildTargetTriplet
|
|
|
|
|
2007-05-07 15:57:02 +00:00
|
|
|
# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR,
|
|
|
|
# re-parse them:
|
|
|
|
. "${CT_TOP_DIR}/.config"
|
|
|
|
|
2007-05-23 19:07:54 +00:00
|
|
|
# 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"
|
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Create the sample directory
|
2007-07-01 19:04:20 +00:00
|
|
|
if [ ! -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then
|
|
|
|
mkdir -p "${CT_TOP_DIR}/samples/${CT_TARGET}"
|
2007-05-19 22:52:47 +00:00
|
|
|
fi
|
2007-05-07 09:04:02 +00:00
|
|
|
|
|
|
|
# Save the crosstool-NG config file
|
|
|
|
cp "${CT_TOP_DIR}/.config" "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
|
|
|
|
|
2007-05-07 15:57:02 +00:00
|
|
|
# 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}"`
|
2007-05-19 22:52:47 +00:00
|
|
|
inode_d=`ls -i "${dest}" 2>/dev/null || true`
|
2007-05-07 15:57:02 +00:00
|
|
|
if [ "${inode_s}" != "${inode_d}" ]; then
|
|
|
|
cp "${source}" "${dest}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-07-01 19:04:20 +00:00
|
|
|
if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then
|
|
|
|
samp_top_dir="\${CT_LIB_DIR}"
|
|
|
|
else
|
|
|
|
samp_top_dir="\${CT_TOP_DIR}"
|
|
|
|
fi
|
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# 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
|
2007-05-07 15:57:02 +00:00
|
|
|
CT_DoAddFileToSample "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"
|
2007-07-01 19:04:20 +00:00
|
|
|
sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \
|
2007-05-07 09:04:02 +00:00
|
|
|
"${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
|
2007-07-01 19:04:20 +00:00
|
|
|
if [ -f "${f}" ]; then rm -f "${f}"; fi
|
2007-05-07 09:04:02 +00:00
|
|
|
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
|
2007-05-07 15:57:02 +00:00
|
|
|
CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
|
2007-07-01 19:04:20 +00:00
|
|
|
sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \
|
2007-05-07 09:04:02 +00:00
|
|
|
"${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
|
2007-07-01 19:04:20 +00:00
|
|
|
if [ -f "${f}" ]; then rm -f "${f}"; fi
|
2007-05-07 09:04:02 +00:00
|
|
|
done
|
|
|
|
fi
|