summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2019-01-21 00:42:12 (GMT)
committerAlexey Neyman <stilor@att.net>2019-01-26 21:13:32 (GMT)
commit57e5be632d4e40314cd8d1a67973ee1e58d3dfb8 (patch)
tree21fd3ff534587fc94aef3c622e3e2a00e8eee102 /scripts
parent127c6cc64dcb5b1e47e7e5eecb0aac6f6ae0b48e (diff)
Basic framework for checking config file version
Signed-off-by: Alexey Neyman <stilor@att.net>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/version-check.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/version-check.sh b/scripts/version-check.sh
new file mode 100644
index 0000000..c4a2bd0
--- /dev/null
+++ b/scripts/version-check.sh
@@ -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