Mercurial > trustbridge
changeset 706:6bb3018b966d
Merged
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 11:57:32 +0200 |
parents | ff2efc1cb8fa (diff) 2c63bb63de76 (current diff) |
children | 37899f717fa5 |
files | |
diffstat | 1 files changed, 42 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in Wed Jul 02 11:49:39 2014 +0200 +++ b/packaging/linux-installer.inc.in Wed Jul 02 11:57:32 2014 +0200 @@ -1,18 +1,24 @@ #!/bin/bash ME=`basename "$0"` -DEFAULT_PREFIX=/usr/local +DEFAULT_PREFIX="$HOME/TrustBridge" 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]}':"