samples: use savedefconfig when saving samples
author"Yann E. MORIN" <yann.morin.1998@free.fr>
Mon May 07 00:27:05 2012 +0200 (2012-05-07)
changeset 298180151a249b85
parent 2980 150402ee5468
child 2982 1e35d2fa54d7
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 <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
config/config.mk
kconfig/kconfig.mk
samples/samples.mk
scripts/saveSample.sh.in
     1.1 --- a/config/config.mk	Sun May 06 15:32:56 2012 +0200
     1.2 +++ b/config/config.mk	Mon May 07 00:27:05 2012 +0200
     1.3 @@ -6,7 +6,8 @@
     1.4  # List all config files, wether sourced or generated
     1.5  
     1.6  # The top-level config file to be used be configurators
     1.7 -KCONFIG_TOP = config/config.in
     1.8 +# We need it to savedefconfig in scripts/saveSample.sh
     1.9 +export KCONFIG_TOP = config/config.in
    1.10  
    1.11  # Build the list of all source config files
    1.12  STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f \( -name '*.in' -o -name '*.in.2' \) 2>/dev/null))
     2.1 --- a/kconfig/kconfig.mk	Sun May 06 15:32:56 2012 +0200
     2.2 +++ b/kconfig/kconfig.mk	Mon May 07 00:27:05 2012 +0200
     2.3 @@ -10,7 +10,8 @@
     2.4  
     2.5  $(configurators): config_files
     2.6  
     2.7 -CONF  := $(CT_LIB_DIR)/kconfig/conf
     2.8 +# We need CONF for savedefconfig in scripts/saveSample.sh
     2.9 +export CONF  := $(CT_LIB_DIR)/kconfig/conf
    2.10  MCONF := $(CT_LIB_DIR)/kconfig/mconf
    2.11  NCONF := $(CT_LIB_DIR)/kconfig/nconf
    2.12  
     3.1 --- a/samples/samples.mk	Sun May 06 15:32:56 2012 +0200
     3.2 +++ b/samples/samples.mk	Mon May 07 00:27:05 2012 +0200
     3.3 @@ -83,9 +83,9 @@
     3.4  
     3.5  # How we do recall one sample
     3.6  PHONY += $(CT_SAMPLES)
     3.7 -$(CT_SAMPLES):
     3.8 -	$(SILENT)cp $(call sample_dir,$@)/crosstool.config .config
     3.9 -	$(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) oldconfig
    3.10 +$(CT_SAMPLES): config_files
    3.11 +	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
    3.12 +	$(SILENT)$(CONF) --defconfig=$(call sample_dir,$@)/crosstool.config $(KCONFIG_TOP)
    3.13  	@echo
    3.14  	@echo  '***********************************************************'
    3.15  	@echo
     4.1 --- a/scripts/saveSample.sh.in	Sun May 06 15:32:56 2012 +0200
     4.2 +++ b/scripts/saveSample.sh.in	Mon May 07 00:27:05 2012 +0200
     4.3 @@ -72,15 +72,16 @@
     4.4  samp_dir="samples/${samp_name}"
     4.5  mkdir -p "${samp_dir}"
     4.6  
     4.7 -# Save the crosstool-NG config file
     4.8 -# We need to save the real .config with kconfig's values,
     4.9 -# not our mangled .config.2 with arrays
    4.10 +# Tweak the .config file
    4.11 +# We need to be based on the real .config with kconfig's values,
    4.12 +# not our mangled .config.2 with shell arrays
    4.13 +cp .config .defconfig
    4.14  "${sed}" -r -e 's|^(CT_PREFIX_DIR)=.*|\1="${HOME}/x-tools/${CT_TARGET}"|;'      \
    4.15              -e 's|^# CT_LOG_TO_FILE is not set$|CT_LOG_TO_FILE=y|;'             \
    4.16              -e 's|^# CT_LOG_FILE_COMPRESS is not set$|CT_LOG_FILE_COMPRESS=y|;' \
    4.17              -e 's|^(CT_LOCAL_TARBALLS_DIR)=.*|\1="${HOME}/src"|;'               \
    4.18           <.config                                                               \
    4.19 -    >"${samp_dir}/crosstool.config"
    4.20 +         >.defconfig
    4.21  
    4.22  # Function to copy a file to the sample directory
    4.23  # Needed in case the file is already there (think of a previously available sample)
    4.24 @@ -106,7 +107,7 @@
    4.25      # We save the file, and then point the saved sample to this file
    4.26      CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${samp_dir}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
    4.27      "${sed}" -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE)=.+$|\1="'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \
    4.28 -             "${samp_dir}/crosstool.config"
    4.29 +             .defconfig
    4.30  else
    4.31      # remove any dangling files
    4.32      for f in "${samp_dir}/${CT_LIBC}-"*.config; do
    4.33 @@ -114,6 +115,11 @@
    4.34      done
    4.35  fi
    4.36  
    4.37 +# Now, actually save the defconfig
    4.38 +export KCONFIG_CONFIG="$(pwd)/.defconfig"
    4.39 +${CONF} --savedefconfig="${samp_dir}/crosstool.config" "${KCONFIG_TOP}"
    4.40 +rm -f .defconfig
    4.41 +
    4.42  # Restore stdout now, to be interactive
    4.43  exec >&7
    4.44