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 uClibc .config file if uClibc selected
|
2008-10-14 21:30:27 +00:00
|
|
|
# - info about who reported the sample
|
|
|
|
|
|
|
|
# We'll need the stdout later, save it
|
|
|
|
exec 7>&1
|
2007-05-07 09:04:02 +00:00
|
|
|
|
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
|
2008-10-14 21:30:27 +00:00
|
|
|
CT_TestOrAbort "Configuration file not found. Please create one." -f .config
|
|
|
|
. .config
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2008-07-18 15:18:09 +00:00
|
|
|
# Do not use a progress bar
|
|
|
|
unset CT_LOG_PROGRESS_BAR
|
|
|
|
|
2008-10-23 21:13:50 +00:00
|
|
|
# Parse architecture and kernel specific functions
|
2008-10-14 16:53:13 +00:00
|
|
|
. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
|
2008-10-23 21:13:50 +00:00
|
|
|
. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
|
2007-09-16 08:52:26 +00:00
|
|
|
|
2007-08-15 16:18:35 +00:00
|
|
|
# Target tuple: CT_TARGET needs a little love:
|
|
|
|
CT_DoBuildTargetTuple
|
2007-05-07 09:04:02 +00:00
|
|
|
|
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:
|
2008-10-14 21:30:27 +00:00
|
|
|
. .config
|
2007-05-07 15:57:02 +00:00
|
|
|
|
2008-07-18 15:18:09 +00:00
|
|
|
# Override log options
|
|
|
|
unset CT_LOG_PROGRESS_BAR CT_LOG_ERROR CT_LOG_INFO CT_LOG_EXTRA CT_LOG_DEBUG LOG_ALL
|
2008-06-22 17:30:37 +00:00
|
|
|
CT_LOG_WARN=y
|
|
|
|
CT_LOG_LEVEL_MAX="WARN"
|
2007-05-23 19:07:54 +00:00
|
|
|
|
2007-05-07 09:04:02 +00:00
|
|
|
# Create the sample directory
|
2008-10-14 21:30:27 +00:00
|
|
|
if [ ! -d "samples/${CT_TARGET}" ]; then
|
|
|
|
mkdir -p "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
|
2008-07-27 10:54:14 +00:00
|
|
|
sed -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;' \
|
|
|
|
-e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;' \
|
|
|
|
-e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \
|
2008-10-14 16:54:20 +00:00
|
|
|
-e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;' \
|
2008-10-14 21:30:27 +00:00
|
|
|
<.config \
|
|
|
|
>"samples/${CT_TARGET}/crosstool.config"
|
2007-05-07 09:04:02 +00:00
|
|
|
|
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"
|
2008-10-29 22:27:30 +00:00
|
|
|
inode_s=$(ls -i "${source}" |gawk '{ print $1; }')
|
|
|
|
inode_d=$(ls -i "${dest}" 2>/dev/null |gawk '{ print $1; }' || 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 uClibc .config file
|
|
|
|
if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
|
|
|
|
# We save the file, and then point the saved sample to this file
|
2008-10-14 21:30:27 +00:00
|
|
|
CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "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"|;' \
|
2008-10-14 21:30:27 +00:00
|
|
|
"samples/${CT_TARGET}/crosstool.config"
|
2007-05-07 09:04:02 +00:00
|
|
|
else
|
|
|
|
# remove any dangling files
|
2008-10-14 21:30:27 +00:00
|
|
|
for f in "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
|
2008-10-14 21:30:27 +00:00
|
|
|
|
|
|
|
# Restore stdout now, to be interactive
|
|
|
|
exec >&7
|
|
|
|
|
|
|
|
# Fill-in the reported-by info
|
|
|
|
[ -f "samples/${CT_TARGET}/reported.by" ] && . "samples/${CT_TARGET}/reported.by"
|
|
|
|
old_name="${reporter_name}"
|
|
|
|
old_url="${reporter_url}"
|
|
|
|
read -p "Reporter name [${reporter_name}]: " reporter_name
|
|
|
|
read -p "Reporter URL [${reporter_url}]: " reporter_url
|
|
|
|
if [ -n "${reporter_comment}" ]; then
|
|
|
|
echo "Old comment if you need to copy-paste:"
|
2008-10-21 21:31:23 +00:00
|
|
|
printf "${reporter_comment}\n"
|
2008-10-14 21:30:27 +00:00
|
|
|
fi
|
|
|
|
echo "Reporter comment (Ctrl-D to finish):"
|
|
|
|
reporter_comment=$(cat)
|
|
|
|
|
|
|
|
( echo "reporter_name=\"${reporter_name:=${old_name}}\""
|
|
|
|
echo "reporter_url=\"${reporter_url:=${old_url}}\""
|
|
|
|
printf "reporter_comment=\"${reporter_comment}\"\n"
|
|
|
|
) >"samples/${CT_TARGET}/reported.by"
|