From 99a6ddf3be35bd49566cf3d0e942729696684a6e Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Mon, 7 May 2012 00:27:05 +0200 Subject: samples: use savedefconfig when saving samples When saving a sample, use savedefconfig instead of copying the full .config file. This reduces the saved .config, and reduces clutter when it is later upgraded. Also use defconfig when retrieving a sample. Reported-by: Thomas Petazzoni Signed-off-by: "Yann E. MORIN" diff --git a/config/config.mk b/config/config.mk index fe45075..dc1e56c 100644 --- a/config/config.mk +++ b/config/config.mk @@ -6,7 +6,8 @@ # List all config files, wether sourced or generated # The top-level config file to be used be configurators -KCONFIG_TOP = config/config.in +# We need it to savedefconfig in scripts/saveSample.sh +export KCONFIG_TOP = config/config.in # Build the list of all source config files STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f \( -name '*.in' -o -name '*.in.2' \) 2>/dev/null)) diff --git a/kconfig/kconfig.mk b/kconfig/kconfig.mk index d930d37..cc6aa46 100644 --- a/kconfig/kconfig.mk +++ b/kconfig/kconfig.mk @@ -10,7 +10,8 @@ PHONY += $(configurators) $(configurators): config_files -CONF := $(CT_LIB_DIR)/kconfig/conf +# We need CONF for savedefconfig in scripts/saveSample.sh +export CONF := $(CT_LIB_DIR)/kconfig/conf MCONF := $(CT_LIB_DIR)/kconfig/mconf NCONF := $(CT_LIB_DIR)/kconfig/nconf diff --git a/samples/samples.mk b/samples/samples.mk index fa5134d..411d97d 100644 --- a/samples/samples.mk +++ b/samples/samples.mk @@ -83,9 +83,9 @@ endef # How we do recall one sample PHONY += $(CT_SAMPLES) -$(CT_SAMPLES): - $(SILENT)cp $(call sample_dir,$@)/crosstool.config .config - $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) oldconfig +$(CT_SAMPLES): config_files + @$(ECHO) " CONF $(KCONFIG_TOP)" + $(SILENT)$(CONF) --defconfig=$(call sample_dir,$@)/crosstool.config $(KCONFIG_TOP) @echo @echo '***********************************************************' @echo diff --git a/scripts/saveSample.sh.in b/scripts/saveSample.sh.in index e885972..792f033 100644 --- a/scripts/saveSample.sh.in +++ b/scripts/saveSample.sh.in @@ -72,15 +72,16 @@ esac samp_dir="samples/${samp_name}" mkdir -p "${samp_dir}" -# Save the crosstool-NG config file -# We need to save the real .config with kconfig's values, -# not our mangled .config.2 with arrays +# Tweak the .config file +# We need to be based on the real .config with kconfig's values, +# not our mangled .config.2 with shell arrays +cp .config .defconfig "${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|;' \ -e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;' \ <.config \ - >"${samp_dir}/crosstool.config" + >.defconfig # Function to copy a file to the sample directory # Needed in case the file is already there (think of a previously available sample) @@ -106,7 +107,7 @@ 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}" "${samp_dir}/${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"|;' \ - "${samp_dir}/crosstool.config" + .defconfig else # remove any dangling files for f in "${samp_dir}/${CT_LIBC}-"*.config; do @@ -114,6 +115,11 @@ else done fi +# Now, actually save the defconfig +export KCONFIG_CONFIG="$(pwd)/.defconfig" +${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}" +rm -f .defconfig + # Restore stdout now, to be interactive exec >&7 -- cgit v0.10.2-6-g49f6