[PATCH] Write installation configuration file

Wald Commits scm-commit at wald.intevation.org
Wed Jul 2 10:54:21 CEST 2014


# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1404291223 -7200
# Node ID bf87feccb26cc6e02d08ac601b08c36bcc656bad
# Parent  f12b102b33caf325da271e303398d803f3cf0eb1
Write installation configuration file.

diff -r f12b102b33ca -r bf87feccb26c packaging/linux-createpackage.sh.in
--- a/packaging/linux-createpackage.sh.in	Tue Jul 01 17:22:31 2014 +0200
+++ b/packaging/linux-createpackage.sh.in	Wed Jul 02 10:53:43 2014 +0200
@@ -7,6 +7,7 @@
 # See LICENSE.txt for details.
 
 TMPDIR=$(mktemp -d)
+TMPSHAR=$(mktemp "@CMAKE_BINARY_DIR@/shar.XXXXXXXXXX")
 
 INSTALLER="@CMAKE_BINARY_DIR@/TrustBridge- at PROJECT_VERSION@.sh"
 
@@ -21,10 +22,12 @@
 install "${EXEFILES[@]}" "$TMPDIR/bin" 
 
 echo "Building $INSTALLER..."
-cat "@CMAKE_BINARY_DIR@/packaging/linux-installer.inc" >"$INSTALLER"
+cp "@CMAKE_BINARY_DIR@/packaging/linux-installer.inc" "$INSTALLER"
 cd "$TMPDIR"
-shar -z -B bin/* >>"$INSTALLER"
+shar -z -B bin/* | sed 's/^exit 0//' >>"$TMPSHAR"
+sed -i "/###SHAR###/r $TMPSHAR" "$INSTALLER"
 chmod +x "$INSTALLER"
 
 echo "Cleaning up..."
 rm -r "$TMPDIR"
+rm  "$TMPSHAR"
diff -r f12b102b33ca -r bf87feccb26c packaging/linux-installer.inc.in
--- a/packaging/linux-installer.inc.in	Tue Jul 01 17:22:31 2014 +0200
+++ b/packaging/linux-installer.inc.in	Wed Jul 02 10:53:43 2014 +0200
@@ -1,15 +1,23 @@
 #!/bin/bash
 
 ME=`basename "$0"`
-VERSION='@PROJECT_VERSION@'
 DEFAULT_PREFIX=/usr/local
+CFGPATH="${XDG_DATA_HOME:-$HOME/.local/share}/BSI/TrustBridge"
+SYSCFGPATH="/etc/TrustBridge"
+INSTCFGNAME="installation.cfg"
 
-path=""
+instcfg_file="${CFGPATH}/${INSTCFGNAME}"
+declare -A instcfg
+instcfg=(
+  [TIMESTMP]=`date -u +%Y%m%d%H%M%S`
+  [VERSION]='@PROJECT_VERSION@'
+  [PREFIX]=''
+)
 
 version()
 {
   cat <<EOF
-TrustBridge $VERSION Installer
+TrustBridge ${instcfg[VERSION]} Installer
 
 Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 Software engineering by Intevation GmbH
@@ -54,7 +62,7 @@
   while true ; do
     case "$1" in
       --prefix|-p)
-        path="$2"
+        instcfg[PREFIX]="$2"
         shift 2
         ;;
       --help)
@@ -71,6 +79,15 @@
   done
 }
 
+write_instcfg()
+{
+  install -d `dirname "$instcfg_file"`
+  echo "# Created by TrustBridge-Installer, don't touch!" >"$instcfg_file"
+  for key in "${!instcfg[@]}" ; do
+    echo "${key}=${instcfg[$key]}" >>"$instcfg_file"
+  done
+}
+
 #======================================================================
 # main()
 
@@ -80,27 +97,33 @@
 ------------------------------------------------------------------------
 
    TrustBridge - Installer
-   Version $VERSION
+   Version ${instcfg[VERSION]}
 
 ------------------------------------------------------------------------
 EOF
 
-if [ -z "$path" ] ; then
+if [ -z "${instcfg[PREFIX]}" ] ; then
     echo -n "Select installation prefix for TrustBridge [${DEFAULT_PREFIX}]: "
-    read -e path
+    read -e instcfg[PREFIX]
 
-    [ -z "$path" ] && path="${DEFAULT_PREFIX}"
+    [ -z "${instcfg[PREFIX]}" ] && instcfg[PREFIX]="${DEFAULT_PREFIX}"
 fi
 
-echo "Installing to '$path':"
+echo "Installing to '${instcfg[PREFIX]}':"
 
-if [ ! -d "$path" ] ; then
+if [ ! -d "${instcfg[PREFIX]}" ] ; then
     echo "creating installation directory ..."
-    install -d "$path" || fatal "Could not create '$path'!"
+    install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!"
 fi
 
 echo "unpacking files ..."
-cd "$path"
+cd "${instcfg[PREFIX]}"
 
 # ----------------------------------------------------------------------
-# regular shar archive appended here:
+# regular shar archive inserted here:
+###SHAR###
+# ----------------------------------------------------------------------
+
+echo "Writing installation configuration to: $instcfg_file ..."
+write_instcfg
+exit 0


More information about the Trustbridge-commits mailing list