Skip to content

Commit

Permalink
Add upgrade logic to version-check.sh
Browse files Browse the repository at this point in the history
Slightly rework config version detector to catch the case where neither
CONFIG_VERSION/CONFIG_VERSION_CURRENT is defined in the config file.

Add olddefconfig and use it after the upgrade.

Signed-off-by: Alexey Neyman <stilor@att.net>
  • Loading branch information
stilor committed Jan 28, 2019
1 parent 20c6acc commit adc1604
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 38 deletions.
2 changes: 1 addition & 1 deletion bash-completion/ct-ng.in
Expand Up @@ -16,7 +16,7 @@ _ct_ng () {
stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;')

actions='help menuconfig nconfig oldconfig saveconfig extractconfig
defconfig savedefconfig
defconfig savedefconfig olddefconfig upgradeconfig
build build-all
wiki-samples list-samples list-samples-short check-samples
list-steps
Expand Down
15 changes: 12 additions & 3 deletions config/global.in
Expand Up @@ -18,15 +18,24 @@ config VCHECK
string
option env="CT_VCHECK"

# Kconfig's idiosynchrasy: it does not output the config settings declared with 'option env'
# to the generated .config file. Must use one extra level of indirection.
config CONFIG_VERSION_ENV
string
option env="CT_CONFIG_VERSION_CURRENT"

# Up-to-date version of the configuration file. If saving a defconfig, choose a default that
# is guaranteed not to match - so that kconfig saves the value to .config.
config CONFIG_VERSION_CURRENT
string
default -1 if VCHECK = "save"
default 1
default CONFIG_VERSION_ENV

# Version used by the config being loaded (e.g. as part of 'oldconfig' or recalling
# a defconfig. Make it changeable while loading/saving to force writing it to defconfig.
config CONFIG_VERSION
string
prompt "** make it changeable **" if VCHECK = "load" || VCHECK = "save"
default 0 if VCHECK = "load" || VCHECK = "save"
default "0" if VCHECK = "load" || VCHECK = "save"
default CONFIG_VERSION_CURRENT

if VCHECK = "warning"
Expand Down
22 changes: 20 additions & 2 deletions ct-ng.in
@@ -1,5 +1,5 @@
#!@MAKE@ -rf
# vim: set filetype=make :
# vim: set filetype=make noet :
# Makefile for crosstool-NG.
# Copyright 2006 Yann E. MORIN <yann.morin.1998@free.fr>

Expand Down Expand Up @@ -37,6 +37,12 @@ export CT_VERSION:=@PACKAGE_VERSION@
# user-visible configurators, and suppresses a warning from kconfig.
export CT_VCHECK=

# Current version of the configuration file. Defined here, because we also
# need to pass it to the upgrade script - which may receive an input that
# was not preprocessed by kconfig, and hence have no string for "up-to-date"
# version.
export CT_CONFIG_VERSION_CURRENT=1

# Download agents used by scripts.mk
CT_WGET := @wget@
CT_CURL := @curl@
Expand Down Expand Up @@ -106,7 +112,8 @@ CONF-nconfig := $(CT_LIBEXEC_DIR)/nconf
# TBD needed? We do supply the defconfig name explicitly below
export srctree=$(CT_LIB_DIR)

.PHONY: menuconfig nconfig oldconfig savedefconfig defconfig check-config
.PHONY: menuconfig nconfig oldconfig olddefconfig savedefconfig defconfig check-config extractconfig
.PHONY: upgradeconfig

check-config:
@[ ! -e .config -o -f .config ] || { echo ".config is not a regular file:"; ls -dl .config; exit 1; } >&2
Expand All @@ -124,6 +131,11 @@ oldconfig: .config check-config
@$(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
$(SILENT)$(CONF) --silent$@ $(KCONFIG_TOP)

olddefconfig: .config check-config
@$(CT_ECHO) " CONF $@"
@$(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
$(SILENT)$(CONF) --$@ $(KCONFIG_TOP)

savedefconfig: .config check-config
@$(CT_ECHO) ' GEN $@'
$(SILENT)CT_VCHECK=save $(CONF) --savedefconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP)
Expand All @@ -132,6 +144,11 @@ defconfig: check-config
@$(CT_ECHO) ' CONF $@'
$(SILENT)CT_VCHECK=save $(CONF) --defconfig=$${DEFCONFIG-defconfig} $(KCONFIG_TOP)

upgradeconfig: .config check-config
$(SILENT)CT_UPGRADECONFIG=yes $(bash) $(CT_LIB_DIR)/scripts/version-check.sh .config
$(SILENT)$(CONF) --olddefconfig $(KCONFIG_TOP)
@$(CT_ECHO) "Done. You may now run 'ct-ng menuconfig' to edit the configuration."

# Always be silent, the stdout an be >.config
extractconfig:
@$(awk) 'BEGIN { dump=0; } \
Expand Down Expand Up @@ -206,6 +223,7 @@ help-config::
@echo ' menuconfig - Update current config using a menu based program'
@echo ' nconfig - Update current config using a menu based program'
@echo ' oldconfig - Update current config using a provided .config as base'
@echo ' upgradeconfig - Upgrade config file to current crosstool-NG'
@echo ' extractconfig - Extract to stdout the configuration items from a'
@echo ' build.log file piped to stdin'
@echo ' savedefconfig - Save current config as a mini-defconfig to $${DEFCONFIG}'
Expand Down
6 changes: 1 addition & 5 deletions samples/samples.mk
Expand Up @@ -21,7 +21,6 @@ CT_UPDATE_SAMPLES := no
help-config::
@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)'
Expand Down Expand Up @@ -94,7 +93,7 @@ list-samples-short: FORCE
# Check one sample
PHONY += $(patsubst %,check-%,$(CT_SAMPLES))
$(patsubst %,check-%,$(CT_SAMPLES)): check-%:
@eset -e; xport KCONFIG_CONFIG=$$(pwd)/.config.sample; \
@set -e; export KCONFIG_CONFIG=$$(pwd)/.config.sample; \
CT_NG_SAMPLE=$(call sample_dir,$*)/crosstool.config; \
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; \
Expand Down Expand Up @@ -129,9 +128,6 @@ samples:
saveconfig: .config samples
$(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
define sample_dir
Expand Down
25 changes: 0 additions & 25 deletions scripts/upgrade.sed

This file was deleted.

0 comments on commit adc1604

Please sign in to comment.