2009-02-01 17:11:46 +00:00
|
|
|
#!@@CT_bash@@
|
2007-05-07 09:04:02 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2009-02-01 17:11:46 +00:00
|
|
|
# Parse the tools' paths configuration
|
2012-01-16 22:36:42 +00:00
|
|
|
. "${CT_LIB_DIR}/paths.sh"
|
2007-07-01 19:04:20 +00:00
|
|
|
. "${CT_LIB_DIR}/scripts/functions"
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2016-12-14 06:18:50 +00:00
|
|
|
CT_LoadConfig
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2009-03-03 21:53:50 +00:00
|
|
|
# We can not reliably save a sample which either uses local patches
|
|
|
|
# and/or custom Linux kernel headers. Warn the user about this issue
|
|
|
|
# and continue if he/she confirms sving the sample.
|
|
|
|
if [ "${CT_CUSTOM_PATCH}" = "y" ]; then
|
|
|
|
echo "You are using local patches."
|
|
|
|
echo "You will not be able to (easily) share this sample in this case."
|
|
|
|
read -p "Press Ctrl-C to stop now, or Enter to continue..."
|
|
|
|
fi
|
|
|
|
|
2008-07-18 15:18:09 +00:00
|
|
|
# Do not use a progress bar
|
|
|
|
unset CT_LOG_PROGRESS_BAR
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2009-06-26 17:09:22 +00:00
|
|
|
# Compute the name of the sample directory
|
|
|
|
case "${CT_TOOLCHAIN_TYPE}" in
|
|
|
|
cross) samp_name="${CT_TARGET}";;
|
2009-06-26 17:09:22 +00:00
|
|
|
canadian) samp_name="${CT_HOST},${CT_TARGET}";;
|
2009-06-26 17:09:22 +00:00
|
|
|
*) CT_Abort "Unsupported toolchain type '${CT_TOOLCHAIN_TYPE}'";;
|
|
|
|
esac
|
|
|
|
samp_dir="samples/${samp_name}"
|
|
|
|
mkdir -p "${samp_dir}"
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2016-12-14 02:40:47 +00:00
|
|
|
# Tweak the .config file: remove the options that we want to keep
|
|
|
|
# at default setting in samples.
|
|
|
|
force_default_opts=( \
|
|
|
|
PREFIX_DIR LOG_TO_FILE LOG_FILE_COMPRESS \
|
|
|
|
LOCAL_TARBALLS_DIR SAVE_TARBALLS \
|
|
|
|
LOG_ERROR LOG_WARN LOG_INFO LOG_EXTRA LOG_ALL LOG_DEBUG \
|
|
|
|
LOG_PROGRESS_BAR
|
|
|
|
)
|
|
|
|
regexp=${force_default_opts[*]}
|
|
|
|
regexp=${regexp// /|}
|
2017-02-13 02:53:23 +00:00
|
|
|
${grep} -v -E '^(# )?CT_('"${regexp}"')' .config > .defconfig
|
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"
|
2015-05-10 03:09:05 +00:00
|
|
|
inode_s=$(ls -i "${source}" | ${awk} '{ print $1; }')
|
|
|
|
inode_d=$(ls -i "${dest}" 2>/dev/null | ${awk} '{ 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
|
2009-06-26 17:09:22 +00:00
|
|
|
CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${samp_dir}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
|
2017-02-16 20:45:51 +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"|;' \
|
2012-05-06 22:27:05 +00:00
|
|
|
.defconfig
|
2007-05-07 09:04:02 +00:00
|
|
|
else
|
|
|
|
# remove any dangling files
|
2009-06-26 17:09:22 +00:00
|
|
|
for f in "${samp_dir}/${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
|
|
|
|
2012-05-06 22:27:05 +00:00
|
|
|
# Now, actually save the defconfig
|
|
|
|
export KCONFIG_CONFIG="$(pwd)/.defconfig"
|
|
|
|
${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}"
|
|
|
|
rm -f .defconfig
|
|
|
|
|
2008-10-14 21:30:27 +00:00
|
|
|
# Fill-in the reported-by info
|
2009-06-26 17:09:22 +00:00
|
|
|
[ -f "${samp_dir}/reported.by" ] && . "${samp_dir}/reported.by"
|
2008-10-14 21:30:27 +00:00
|
|
|
old_name="${reporter_name}"
|
|
|
|
old_url="${reporter_url}"
|
2012-04-09 09:19:51 +00:00
|
|
|
old_comment="${reporter_comment}"
|
2008-10-14 21:30:27 +00:00
|
|
|
read -p "Reporter name [${reporter_name}]: " reporter_name
|
|
|
|
read -p "Reporter URL [${reporter_url}]: " reporter_url
|
|
|
|
if [ -n "${reporter_comment}" ]; then
|
2012-04-09 09:19:51 +00:00
|
|
|
echo "Old comment:"
|
2017-02-13 02:53:23 +00:00
|
|
|
printf "${reporter_comment}\n" | ${sed_r} -e 's/^/ > /;'
|
2008-10-14 21:30:27 +00:00
|
|
|
fi
|
2012-04-09 09:19:51 +00:00
|
|
|
echo "Reporter comment (Ctrl-D to finish, '.' to use previous):"
|
2008-10-14 21:30:27 +00:00
|
|
|
reporter_comment=$(cat)
|
2012-04-09 09:19:51 +00:00
|
|
|
if [ "${reporter_comment}" = "." ]; then
|
|
|
|
reporter_comment="${old_comment}"
|
|
|
|
fi
|
2008-10-14 21:30:27 +00:00
|
|
|
|
|
|
|
( echo "reporter_name=\"${reporter_name:=${old_name}}\""
|
|
|
|
echo "reporter_url=\"${reporter_url:=${old_url}}\""
|
|
|
|
printf "reporter_comment=\"${reporter_comment}\"\n"
|
2009-06-26 17:09:22 +00:00
|
|
|
) >"${samp_dir}/reported.by"
|