samples: check if update is needed
author"Yann E. MORIN" <yann.morin.1998@free.fr>
Tue Jan 22 00:32:38 2013 +0100 (2013-01-22)
changeset 31689b991363c01c
parent 3167 15f57d843296
child 3169 9d0b37f08a10
samples: check if update is needed

Add a ct-ng action to check if samples needs being updated.
This will be usefull when the config options change.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
ct-ng.comp
samples/samples.mk
     1.1 --- a/ct-ng.comp	Tue Jan 22 00:34:15 2013 +0100
     1.2 +++ b/ct-ng.comp	Tue Jan 22 00:32:38 2013 +0100
     1.3 @@ -9,6 +9,7 @@
     1.4      samples=$( "${COMP_WORDS[0]}" list-samples-short 2>/dev/null )
     1.5      show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;')
     1.6      build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;')
     1.7 +    check_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1check-/g;')
     1.8  
     1.9      steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }')
    1.10      start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;')
    1.11 @@ -17,14 +18,15 @@
    1.12      actions='help menuconfig oldconfig saveconfig extractconfig
    1.13               defconfig savedefconfig
    1.14               build build. build-all build-all.
    1.15 -             wiki-samples list-samples list-samples-short list-steps
    1.16 +             wiki-samples list-samples list-samples-short check-samples
    1.17 +             list-steps
    1.18               show-tuple show-all show-config
    1.19               clean distclean updatetools
    1.20               tarball version'
    1.21  
    1.22      vars="RESTART= STOP= PREFIX= V= DEFCONFIG="
    1.23  
    1.24 -    ct_ng_opts="${samples} ${show_samples} ${build_samples}
    1.25 +    ct_ng_opts="${samples} ${show_samples} ${build_samples} ${check_samples}
    1.26                  ${steps} ${start_steps} ${stop_steps}
    1.27                  ${actions} ${vars}"
    1.28  
     2.1 --- a/samples/samples.mk	Tue Jan 22 00:34:15 2013 +0100
     2.2 +++ b/samples/samples.mk	Tue Jan 22 00:32:38 2013 +0100
     2.3 @@ -79,6 +79,22 @@
     2.4  	    printf "%s\n" "$${s}";          \
     2.5  	done
     2.6  
     2.7 +# Check one sample
     2.8 +PHONY += $(patsubst %,check-%,$(CT_SAMPLES))
     2.9 +$(patsubst %,check-%,$(CT_SAMPLES)): config_files
    2.10 +	@export KCONFIG_CONFIG=$$(pwd)/.config.sample;                                  \
    2.11 +	 CT_NG_SAMPLE=$(call sample_dir,$(patsubst check-%,%,$(@)))/crosstool.config;   \
    2.12 +	 $(CONF) --defconfig=$${CT_NG_SAMPLE} $(KCONFIG_TOP) >/dev/null;                \
    2.13 +	 $(CONF) --savedefconfig=$$(pwd)/.defconfig $(KCONFIG_TOP) >/dev/null;          \
    2.14 +	 old_sha1=$$( sha1sum "$${CT_NG_SAMPLE}" |cut -d ' ' -f 1 );                    \
    2.15 +	 new_sha1=$$( sha1sum .defconfig |cut -d ' ' -f 1 );                            \
    2.16 +	 if [ $${old_sha1} != $${new_sha1} ]; then                                      \
    2.17 +	    echo "$(patsubst check-%,%,$(@)) needs update";                             \
    2.18 +	 fi
    2.19 +	@rm -f .config.sample* .defconfig
    2.20 +
    2.21 +check-samples: $(patsubst %,check-%,$(CT_SAMPLES))
    2.22 +
    2.23  PHONY += wiki-samples
    2.24  wiki-samples: wiki-samples-pre $(patsubst %,wiki-%,$(CT_SAMPLES)) wiki-samples-post
    2.25