summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfunctions/common.sh3
-rwxr-xr-xfunctions/configuration.sh38
-rwxr-xr-xfunctions/defaults.sh41
-rwxr-xr-xscripts/build/config6
4 files changed, 69 insertions, 19 deletions
diff --git a/functions/common.sh b/functions/common.sh
index 9284ec564..9621e476b 100755
--- a/functions/common.sh
+++ b/functions/common.sh
@@ -12,4 +12,7 @@ PROGRAM="live-build"
VERSION="$(if [ -e ${LIVE_BUILD}/VERSION ]; then cat ${LIVE_BUILD}/VERSION; else cat /usr/share/live/build/VERSION; fi)"
CONFIG_VERSION="$(echo ${VERSION} | awk -F- '{ print $1 }')"
+# FIXME
+LIVE_CONFIGURATION_VERSION="${CONFIG_VERSION}"
+
PATH="${PWD}/local/bin:${PATH}"
diff --git a/functions/configuration.sh b/functions/configuration.sh
new file mode 100755
index 000000000..951e354fa
--- /dev/null
+++ b/functions/configuration.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
+##
+## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+Get_configuration ()
+{
+ _CONFIGURATION_FILE="${1}"
+ _FIELD_NAME="${2}"
+
+ if [ -e "${_CONFIGURATION_FILE}" ]
+ then
+ _FIELD_BODY="$(grep ^${_FIELD_NAME}: ${_CONFIGURATION_FILE} | awk '{ $1=""; print $0 }' | sed -e 's|^ ||')"
+ fi
+
+ echo ${_FIELD_BODY}
+}
+
+Set_configuration ()
+{
+ _CONFIGURATION_FILE="${1}"
+ _FIELD_NAME="${2}"
+ _FIELD_BODY="${3}"
+
+ if grep -qs "^${_FIELD_NAME}:" "${_CONFIGURATION_FILE}"
+ then
+ # Update configuration
+ sed -i -e "s|^${_FIELD_NAME}:.*$|${_FIELD_NAME}: ${_FIELD_BODY}|" "${_CONFIGURATION_FILE}"
+ else
+ # Append configuration
+ echo "${_FIELD_NAME}: ${_FIELD_BODY}" >> "${_CONFIGURATION_FILE}"
+ fi
+}
diff --git a/functions/defaults.sh b/functions/defaults.sh
index d49534c09..2500ddd59 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -1140,32 +1140,41 @@ Set_defaults ()
Check_defaults ()
{
- if [ "${LB_CONFIG_VERSION}" ]
+ if [ -n "${LIVE_CONFIGURATION_VERSION}" ]
then
# We're only checking when we're actually running the checks
# that's why the check for emptyness of the version;
- # however, as live-build always declares LB_CONFIG_VERSION
+ # however, as live-build always declares LIVE_CONFIGURATION_VERSION
# internally, this is safe assumption (no cases where it's unset,
# except when bootstrapping the functions/defaults etc.).
- CURRENT_CONFIG_VERSION="$(echo ${LB_CONFIG_VERSION} | awk -F. '{ print $1 }')"
- if [ ${CURRENT_CONFIG_VERSION} -ne 4 ]
+ CURRENT_CONFIGURATION_VERSION="$(Get_configuration config/control Configuration-Version)"
+ CURRENT_CONFIGURATION_VERSION="$(echo ${CURRENT_CONFIGURATION_VERSION} | awk -F. ' { print $1 }')"
+
+ if [ -n "${CURRENT_CONFIGURATION_VERSION}" ]
then
- if [ ${CURRENT_CONFIG_VERSION} -ge 5 ]
- then
- Echo_error "This config tree is too new for this version of live-build (${VERSION})."
- Echo_error "Aborting build, please get a new version of live-build."
+ CORRECT_VERSION="$(echo ${LIVE_CONFIGURATION_VERSION} | awk -F. '{ print $1 }')"
+ TOO_NEW_VERSION="$((${CORRECT_VERSION} + 1))"
+ TOO_OLD_VERSION="$((${CORRECT_VERSION} - 1))"
- exit 1
- elif [ ${CURRENT_CONFIG_VERSION} -le 3 ]
+ if [ ${CURRENT_CONFIGURATION_VERSION} -ne ${CORRECT_VERSION} ]
then
- Echo_error "This config tree is too old for this version of live-build (${VERSION})."
- Echo_error "Aborting build, please regenerate the config tree."
+ if [ ${CURRENT_CONFIGURATION_VERSION} -ge ${TOO_NEW_VERSION} ]
+ then
+ Echo_error "This config tree is too new for live-build (${VERSION})."
+ Echo_error "Aborting build, please update live-build."
- exit 1
- else
- Echo_warning "This config tree does not specify a format version or has an unknown version number."
- Echo_warning "Continuing build, but it could lead to errors or different results. Please regenerate the config tree."
+ exit 1
+ elif [ ${CURRENT_CONFIGURATION_VERSION} -le ${TOO_OLD_VERSION} ]
+ then
+ Echo_error "This config tree is too old for live-build (${VERSION})."
+ Echo_error "Aborting build, please update the configuration."
+
+ exit 1
+ else
+ Echo_warning "This configuration does not specify a version or has a unknown version."
+ Echo_warning "Continuing build, please correct the configuration."
+ fi
fi
fi
fi
diff --git a/scripts/build/config b/scripts/build/config
index 4edb7cd86..e5562db46 100755
--- a/scripts/build/config
+++ b/scripts/build/config
@@ -969,9 +969,6 @@ mkdir -p config/includes
cat > config/common << EOF
# config/common - common options for live-build(7)
-# LB_CONFIG_VERSION: internal version of the configuration file format
-LB_CONFIG_VERSION="${CONFIG_VERSION}"
-
# \$LB_APT: set package manager
# (Default: ${LB_APT})
LB_APT="${LB_APT}"
@@ -1492,5 +1489,8 @@ then
rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true
fi
+# New style configuration
+Set_configuration "config/control" "Configuration-Version" "${LIVE_CONFIGURATION_VERSION}"
+
# Creating stage file
Create_stagefile .build/config