From d55dbc6ecfc573448ad0c1251b1bee6e6eb9894b Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Tue, 7 Feb 2012 11:49:15 +0100 Subject: [PATCH] config-lib: handle all deprecated config variables and try to migrate to new values we migrate the old config by using the old dirs and move them to the new locations: if the new location already exists - nothing is migrated. if the old location does not exist - nothing is migrated. also we warn about renamed variables, if they are set. --- src/beelib.config.sh.in | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/beelib.config.sh.in b/src/beelib.config.sh.in index f8e9bca..bc0ef3a 100644 --- a/src/beelib.config.sh.in +++ b/src/beelib.config.sh.in @@ -75,14 +75,35 @@ function config_init_base_config() { XDG_DATA_DIRS=$(beeuniq -d : ${XDG_DATA_DIRS//:/ }) } + +function deprecated_mv() { + local what=${1} + local from=${2} + local to=${3} + + if [ -e "${from}" -a ! -e "${to}" ] ; then + print_error "WARNING: migrating deprecated config ${what}:" + print_error "WARNING: moving ${from} -> ${to}" + mkdir -vp "${to%/*}" + mv -v "${from}" "${to}" + fi +} + function config_handle_deprecated_config() { - : ${DOTBEERC:=${HOME}/.beerc} - if [ -r "${DOTBEERC}" ] ; then - print_error \ - "ERROR: support for ~/.beerc is" \ - " deprecated please move it to" \ - " ${XDG_CONFIG_HOME}/bee/beerc" - exit 1 + deprecated_mv "DOTBEERC" "${HOME}/.beerc" "${XDG_CONFIG_HOME}/bee/beerc" + deprecated_mv "BEE_REPOSITORY_PREFIX" "${XDG_DATA_HOME}/beeroot" "${BEE_REPOSITORY_PREFIX}" + deprecated_mv "BEE_METADIR" "${XDG_DATA_HOME}/beemeta" "${BEE_METADIR}" + deprecated_mv "BEE_REPOSITORY_BEEDIR" "${BEE_REPOSITORY_PREFIX}/bees" "${BEE_REPOSITORY_BEEDIR}" + deprecated_mv "BEE_REPOSITORY_PKGDIR" "${BEE_REPOSITORY_PREFIX}/pkgs" "${BEE_REPOSITORY_PKGDIR}" + deprecated_mv "BEE_DOWNLOADDIR" "${BEE_REPOSITORY_PREFIX}/downloads" "${BEE_DOWNLOADDIR}" + deprecated_mv "BEE_TMP_BUILDROOT" "${BEE_TMP_TMPDIR}/beeroot-${USER}" "${BEE_TMP_BUILDROOT}" + + if [ ! -z "${BEE_REPOSITORY_BUILDARCHIVEDIR}" ] ; then + print_error "WARNING: ignored deprecated variable BEE_REPOSITORY_BUILDARCHIVEDIR please use BEE_BUILDARCHIVEDIR=${BEE_REPOSITORY_BUILDARCHIVEDIR}" + fi + + if [ ! -z "${DOTBEERC}" ] ; then + print_error "WARNING: ignored deprecated variable DOTBEERC please use BEE_USER_CONFIG_FILE=${DOTBEERC}" fi } @@ -242,12 +263,12 @@ function expand_prefix_variables() { function config_init() { config_init_base_config - config_handle_deprecated_config config_load_local_config config_load_user_config config_load_system_config config_verify_builtin_config config_verify_builtin_prefixes + config_handle_deprecated_config } function config_export() {