Mercurial > trustbridge
changeset 705:ff2efc1cb8fa
Use config from old installation for sensible default prefix.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 11:56:56 +0200 |
parents | 480bc550d2ad |
children | 6bb3018b966d |
files | packaging/linux-installer.inc.in |
diffstat | 1 files changed, 41 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in Wed Jul 02 10:59:31 2014 +0200 +++ b/packaging/linux-installer.inc.in Wed Jul 02 11:56:56 2014 +0200 @@ -5,14 +5,20 @@ CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge" SYSCFGPATH="/etc/TrustBridge" INSTCFGNAME="installation.cfg" +FORCE=0 instcfg_file="${CFGPATH}/${INSTCFGNAME}" -declare -A instcfg +declare -A instcfg oldinstcfg instcfg=( [TIMESTMP]=`date -u +%Y%m%d%H%M%S` [VERSION]='@PROJECT_VERSION@' [PREFIX]='' ) +oldinstcfg=( + [TIMESTMP]='' + [VERSION]='' + [PREFIX]='' +) version() { @@ -44,6 +50,8 @@ Options: -p, --prefix=PATH install files in PATH + -f, --force install to given prefix, even when a current + installation with different prefix exists. --help display this help and exit --version output version information and exit EOF @@ -53,8 +61,8 @@ parse_args() { OPTS=`getopt \ - -l help,prefix:,version \ - -o p: -n "$ME" -- "$@"` + -l force,help,prefix:,version \ + -o f,p: -n "$ME" -- "$@"` [ $? -eq 0 ] || usage 23 eval set -- "$OPTS" @@ -65,6 +73,10 @@ instcfg[PREFIX]="$2" shift 2 ;; + --force|-f) + FORCE=1 + shift 1 + ;; --help) usage 0 ;; @@ -88,10 +100,21 @@ done } +read_oldinstcfg() +{ + if [ -r "$instcfg_file" ] ; then + echo "Reading '$instcfg_file' ..." + for key in "${!oldinstcfg[@]}" ; do + oldinstcfg[$key]=`sed -n "/$key/s/[^=]*=\(.*\)/\1/p" "$instcfg_file"` + done + fi +} + #====================================================================== # main() parse_args "$@" +read_oldinstcfg cat <<EOF ------------------------------------------------------------------------ @@ -103,10 +126,25 @@ EOF if [ -z "${instcfg[PREFIX]}" ] ; then + + if [ "${oldinstcfg[PREFIX]}" ] ; then + DEFAULT_PREFIX="${oldinstcfg[PREFIX]}" + echo "An existing installation (v${oldinstcfg[VERSION]}) was detected!" + echo "It is HIGHLY RECOMMENDED to accept the default prefix" + echo "to update the current installation." + echo "For a new prefix you should deinstall first!" + fi echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: " read -e instcfg[PREFIX] [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${DEFAULT_PREFIX}" +else + # Prefix was given on invocation: + if [ "${oldinstcfg[PREFIX]}" -a \ + "${instcfg[PREFIX]}" != "${oldinstcfg[PREFIX]}" -a \ + $FORCE -ne 1 ] ; then + fatal "Prefix differs from current installation (${oldinstcfg[PREFIX]}). Aborting!" + fi fi echo "Installing to '${instcfg[PREFIX]}':"