mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-18 20:37:56 +00:00
Basic framework for checking config file version
Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
parent
127c6cc64d
commit
57e5be632d
@ -1,14 +1,47 @@
|
||||
# Overall toolchain configuration: paths, jobs, etc...
|
||||
|
||||
config CT_VERSION
|
||||
config VERSION
|
||||
string
|
||||
option env="CT_VERSION"
|
||||
|
||||
# Config version checking framework. If CONFIG_VERSION is unset in the current .config
|
||||
# or defconfig, it is loaded as 0 (possibly triggering a user prompt during 'ct-ng oldconfig').
|
||||
# If the value of CONFIG_VERSION is older than CONFIG_VERSION_CURRENT, we'll advice the user
|
||||
# to run the configuration through an upgrade. If it is newer, we'll error out - I have no
|
||||
# crystal orb to perform the downgrade.
|
||||
|
||||
# Hack to make kconfig save/load the value for CONFIG_VERSION. Set to empty value (for
|
||||
# normal operations like 'ct-ng menuconfig'); 'load' for creating a configuration from a (potentially)
|
||||
# old file, i.e. 'ct-ng <sample>' or 'ct-ng oldconfig'; 'save' for saving the current configuration,
|
||||
# i.e. 'ct-ng saveconfig' or 'ct-ng savedefconfig'.
|
||||
config VCHECK
|
||||
string
|
||||
option env="CT_VCHECK"
|
||||
|
||||
config CONFIG_VERSION_CURRENT
|
||||
string
|
||||
default -1 if VCHECK = "save"
|
||||
default 1
|
||||
|
||||
config CONFIG_VERSION
|
||||
string
|
||||
prompt "** make it changeable **" if VCHECK = "load" || VCHECK = "save"
|
||||
default 0 if VCHECK = "load" || VCHECK = "save"
|
||||
default CONFIG_VERSION_CURRENT
|
||||
|
||||
if VCHECK = "warning"
|
||||
comment "*************************************************************************"
|
||||
comment "Loaded configuration was generated by a previous version of crosstool-NG."
|
||||
comment "Saving it will mark the configuration as up-to-date without verifying it."
|
||||
comment "It is recommended to run \"ct-ng upgradeconfig\" before making any "
|
||||
comment "changes to the configuration. "
|
||||
comment "*************************************************************************"
|
||||
endif
|
||||
|
||||
# Allow unconditional usage of tristates
|
||||
config MODULES
|
||||
bool
|
||||
def_bool y
|
||||
option modules
|
||||
default y
|
||||
|
||||
menu "Paths and misc options"
|
||||
|
||||
|
30
ct-ng.in
30
ct-ng.in
@ -1,4 +1,5 @@
|
||||
#!@MAKE@ -rf
|
||||
# vim: set filetype=make :
|
||||
# Makefile for crosstool-NG.
|
||||
# Copyright 2006 Yann E. MORIN <yann.morin.1998@free.fr>
|
||||
|
||||
@ -32,6 +33,10 @@ endif
|
||||
# This is crosstool-NG version string
|
||||
export CT_VERSION:=@PACKAGE_VERSION@
|
||||
|
||||
# Export with an empty value: this masks the version detection variable in
|
||||
# user-visible configurators, and suppresses a warning from kconfig.
|
||||
export CT_VCHECK=
|
||||
|
||||
# Download agents used by scripts.mk
|
||||
CT_WGET := @wget@
|
||||
CT_CURL := @curl@
|
||||
@ -93,10 +98,9 @@ FORCE:
|
||||
# Top file of crosstool-NG configuration
|
||||
export KCONFIG_TOP = $(CT_LIB_DIR)/config/config.in
|
||||
|
||||
# We need CONF for savedefconfig in scripts/saveSample.sh
|
||||
export CONF := $(CT_LIBEXEC_DIR)/conf
|
||||
MCONF := $(CT_LIBEXEC_DIR)/mconf
|
||||
NCONF := $(CT_LIBEXEC_DIR)/nconf
|
||||
CONF := $(CT_LIBEXEC_DIR)/conf
|
||||
CONF-menuconfig := $(CT_LIBEXEC_DIR)/mconf
|
||||
CONF-nconfig := $(CT_LIBEXEC_DIR)/nconf
|
||||
|
||||
# Used by conf/mconf/nconf to find the .in files
|
||||
# TBD needed? We do supply the defconfig name explicitly below
|
||||
@ -107,26 +111,26 @@ export srctree=$(CT_LIB_DIR)
|
||||
check-config:
|
||||
@[ ! -e .config -o -f .config ] || { echo ".config is not a regular file:"; ls -dl .config; exit 1; } >&2
|
||||
|
||||
menuconfig: check-config
|
||||
menuconfig nconfig: check-config
|
||||
@$(CT_ECHO) " CONF $@"
|
||||
$(SILENT)$(MCONF) $(KCONFIG_TOP)
|
||||
|
||||
nconfig: check-config
|
||||
@$(CT_ECHO) " CONF $@"
|
||||
$(SILENT)$(NCONF) $(KCONFIG_TOP)
|
||||
$(SILENT)if [ ! -f .config ] || CT_VCHECK=strict $(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config; then \
|
||||
$(CONF-$@) $(KCONFIG_TOP); \
|
||||
else \
|
||||
CT_VCHECK=warning $(CONF-$@) $(KCONFIG_TOP); \
|
||||
fi
|
||||
|
||||
oldconfig: .config check-config
|
||||
@$(CT_ECHO) " CONF $@"
|
||||
$(SILENT)$(sed) -i -r -f $(CT_LIB_DIR)/scripts/upgrade.sed $<
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
|
||||
$(SILENT)$(CONF) --silent$@ $(KCONFIG_TOP)
|
||||
|
||||
savedefconfig: .config check-config
|
||||
@$(CT_ECHO) ' GEN $@'
|
||||
$(SILENT)$(CONF) --savedefconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP)
|
||||
$(SILENT)CT_VCHECK=save $(CONF) --savedefconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP)
|
||||
|
||||
defconfig: check-config
|
||||
@$(CT_ECHO) ' CONF $@'
|
||||
$(SILENT)$(CONF) --defconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP)
|
||||
$(SILENT)CT_VCHECK=save $(CONF) --defconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP)
|
||||
|
||||
# Always be silent, the stdout an be >.config
|
||||
extractconfig:
|
||||
|
@ -19,13 +19,14 @@ CT_UPDATE_SAMPLES := no
|
||||
# This part deals with the samples help entries
|
||||
|
||||
help-config::
|
||||
@echo ' show-config - show a brief overview of current configuration'
|
||||
@echo ' show-config - Show a brief overview of current configuration'
|
||||
@echo ' saveconfig - Save current config as a preconfigured target'
|
||||
@echo ' upgradeconfig - Upgrade config file to current crosstool-NG'
|
||||
|
||||
help-samples::
|
||||
@echo ' list-samples - prints the list of all samples (for scripting)'
|
||||
@echo ' show-<sample> - show a brief overview of <sample> (list with list-samples)'
|
||||
@echo ' <sample> - preconfigure crosstool-NG with <sample> (list with list-samples)'
|
||||
@echo ' list-samples - Prints the list of all samples (for scripting)'
|
||||
@echo ' show-<sample> - Show a brief overview of <sample> (list with list-samples)'
|
||||
@echo ' <sample> - Preconfigure crosstool-NG with <sample> (list with list-samples)'
|
||||
@echo ' build-all[.#] - Build *all* samples (list with list-samples) and install in'
|
||||
@echo ' $${CT_PREFIX} (set to ~/x-tools by default)'
|
||||
|
||||
@ -34,7 +35,7 @@ help-distrib::
|
||||
@echo ' update-samples - Regenerate sample configurations using the current Kconfig'
|
||||
|
||||
help-env::
|
||||
@echo ' CT_PREFIX=dir - install samples in dir (see action "build-all", above).'
|
||||
@echo ' CT_PREFIX=dir - Install samples in dir (see action "build-all", above).'
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# This part deals with printing samples information
|
||||
@ -43,6 +44,7 @@ help-env::
|
||||
PHONY += show-config
|
||||
show-config: .config
|
||||
@cp .config .config.sample
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/show-config.sh -v current
|
||||
@rm -f .config.sample
|
||||
|
||||
@ -50,8 +52,10 @@ show-config: .config
|
||||
PHONY += $(patsubst %,show-%,$(CT_SAMPLES))
|
||||
$(patsubst %,show-%,$(CT_SAMPLES)): show-%:
|
||||
@KCONFIG_CONFIG=$$(pwd)/.config.sample \
|
||||
$(CONF) --defconfig=$(call sample_dir,$*)/crosstool.config \
|
||||
CT_VCHECK=load \
|
||||
$(CONF) --defconfig=$(call sample_dir,$*)/crosstool.config \
|
||||
$(KCONFIG_TOP) >/dev/null
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config.sample
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/show-config.sh -v $*
|
||||
@rm -f .config.sample
|
||||
|
||||
@ -74,8 +78,10 @@ list-samples-pre: FORCE
|
||||
PHONY += $(patsubst %,list-%,$(CT_SAMPLES))
|
||||
$(patsubst %,list-%,$(CT_SAMPLES)): list-%:
|
||||
@KCONFIG_CONFIG=$$(pwd)/.config.sample \
|
||||
CT_VCHECK=load \
|
||||
$(CONF) --defconfig=$(call sample_dir,$*)/crosstool.config \
|
||||
$(KCONFIG_TOP) >/dev/null
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config.sample
|
||||
@$(bash) $(CT_LIB_DIR)/scripts/show-config.sh $*
|
||||
@rm -f .config.sample
|
||||
|
||||
@ -88,19 +94,20 @@ list-samples-short: FORCE
|
||||
# Check one sample
|
||||
PHONY += $(patsubst %,check-%,$(CT_SAMPLES))
|
||||
$(patsubst %,check-%,$(CT_SAMPLES)): check-%:
|
||||
@export KCONFIG_CONFIG=$$(pwd)/.config.sample; \
|
||||
@eset -e; xport KCONFIG_CONFIG=$$(pwd)/.config.sample; \
|
||||
CT_NG_SAMPLE=$(call sample_dir,$*)/crosstool.config; \
|
||||
$(CONF) -s --defconfig=$${CT_NG_SAMPLE} $(KCONFIG_TOP) &>/dev/null; \
|
||||
$(CONF) -s --savedefconfig=$$(pwd)/.defconfig $(KCONFIG_TOP) &>/dev/null; \
|
||||
CT_VCHECK=load $(CONF) -s --defconfig=$${CT_NG_SAMPLE} $(KCONFIG_TOP) &>/dev/null; \
|
||||
CT_UPGRADECONFIG=yes $(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config.sample; \
|
||||
CT_VCHECK=save $(CONF) -s --savedefconfig=$$(pwd)/.defconfig $(KCONFIG_TOP) &>/dev/null; \
|
||||
old_sha1=$$( sha1sum "$${CT_NG_SAMPLE}" |cut -d ' ' -f 1 ); \
|
||||
new_sha1=$$( sha1sum .defconfig |cut -d ' ' -f 1 ); \
|
||||
if [ $${old_sha1} != $${new_sha1} ]; then \
|
||||
if [ $(CT_UPDATE_SAMPLES) = yes ]; then \
|
||||
echo "Updating $*"; \
|
||||
mv .defconfig "$${CT_NG_SAMPLE}"; \
|
||||
if [ $(CT_UPDATE_SAMPLES) = yes ]; then \
|
||||
echo "Updating $*"; \
|
||||
mv .defconfig "$${CT_NG_SAMPLE}"; \
|
||||
else \
|
||||
echo "$* needs update:"; \
|
||||
diff -d -U 0 "$${CT_NG_SAMPLE}" .defconfig |tail -n +4; \
|
||||
echo "$* needs update:"; \
|
||||
diff -d -U 0 "$${CT_NG_SAMPLE}" .defconfig |tail -n +4; \
|
||||
fi; \
|
||||
fi
|
||||
@rm -f .config.sample* .defconfig
|
||||
@ -120,7 +127,10 @@ samples:
|
||||
|
||||
# Save a sample
|
||||
saveconfig: .config samples
|
||||
$(SILENT)$(bash) $(CT_LIB_DIR)/scripts/saveSample.sh
|
||||
$(SILENT)CT_VCHECK=save CONF=$(CONF) $(bash) $(CT_LIB_DIR)/scripts/saveSample.sh
|
||||
|
||||
upgradeconfig: .config
|
||||
$(SILENT)CT_UPGRADECONFIG=yes $(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
|
||||
|
||||
# The 'sample_dir' function prints the directory in which the sample is,
|
||||
# searching first in local samples, then in global samples
|
||||
@ -132,7 +142,8 @@ endef
|
||||
PHONY += $(CT_SAMPLES)
|
||||
$(CT_SAMPLES): check-config
|
||||
@$(CT_ECHO) " CONF $@"
|
||||
$(SILENT)$(CONF) --defconfig=$(call sample_dir,$@)/crosstool.config $(KCONFIG_TOP)
|
||||
$(SILENT)CT_VCHECK=load $(CONF) --defconfig=$(call sample_dir,$@)/crosstool.config $(KCONFIG_TOP)
|
||||
@CT_VCHECK=strict $(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
|
||||
@echo
|
||||
@echo '***********************************************************'
|
||||
@echo
|
||||
@ -169,7 +180,7 @@ target_triplet = $(if $(findstring $(__comma),$(1)),$(word 2,$(subst $(__comma),
|
||||
# $1: sample name (target tuple, or host/target tuples separated by a comma)
|
||||
define build_sample
|
||||
@$(CT_ECHO) ' CONF $(1)'
|
||||
$(SILENT)$(CONF) -s --defconfig=$(call sample_dir,$(1))/crosstool.config $(KCONFIG_TOP)
|
||||
$(SILENT)CT_VCHECK=load $(CONF) -s --defconfig=$(call sample_dir,$(1))/crosstool.config $(KCONFIG_TOP)
|
||||
$(SILENT)[ -n "$(CT_PREFIX)" ] && $(sed) -i -r -e 's:^(CT_PREFIX=).*$$:\1"$(CT_PREFIX)":;' .config || :
|
||||
$(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config
|
||||
$(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config
|
||||
|
38
scripts/version-check.sh
Normal file
38
scripts/version-check.sh
Normal file
@ -0,0 +1,38 @@
|
||||
# This script checks the version of the configuration file and either
|
||||
# alerts the user about the need to run the upgrade, or attempts to
|
||||
# perform such an upgrade.
|
||||
|
||||
CFGFILE="${1}"
|
||||
|
||||
. "${CT_LIB_DIR}/scripts/functions"
|
||||
. "${CFGFILE}"
|
||||
if [ "${CT_CONFIG_VERSION_CURRENT}" == "${CT_CONFIG_VERSION}" ]; then
|
||||
# Nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${CT_UPGRADECONFIG}" ]; then
|
||||
if [ "${CT_CONFIG_VERSION}" != "0" ]; then
|
||||
oldversion="is version ${CT_CONFIG_VERSION}"
|
||||
else
|
||||
oldversion="has no version"
|
||||
fi
|
||||
cat 2>&1 <<EOF
|
||||
|
||||
Configuration file was generated by an older version of crosstool-NG;
|
||||
configuration file ${oldversion}; crosstool-NG currently expects
|
||||
version ${CT_CONFIG_VERSION_CURRENT}. If this configuration file was generated by a crosstool-NG
|
||||
version 1.23.0 or later, you can run 'ct-ng upgradeconfig'.
|
||||
Compatibility with previous releases is not guaranteed. In any case,
|
||||
verify the resulting configuration.
|
||||
|
||||
EOF
|
||||
if [ "${CT_VCHECK}" = "strict" ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "TBD not implemented yet" >&2
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user