# HG changeset patch # User Sascha Wilde # Date 1404295016 -7200 # Node ID ff2efc1cb8fa489f4ebe30a06e7bd595255e2eaf # Parent 480bc550d2ad3544f8c4a019fa67dbedaf59d0b0 Use config from old installation for sensible default prefix. diff -r 480bc550d2ad -r ff2efc1cb8fa packaging/linux-installer.inc.in --- 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 <