wilde@680: #!/bin/bash wilde@680: # Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik wilde@680: # Software engineering by Intevation GmbH wilde@680: # wilde@680: # This file is Free Software under the GNU GPL (v>=2) wilde@680: # and comes with ABSOLUTELY NO WARRANTY! wilde@680: # See LICENSE.txt for details. wilde@680: wilde@1138: process_includes() wilde@1138: { wilde@1138: # Process include statements of the form: wilde@1138: # ###INCLUDE:filename wilde@1138: # in the file given as $1 wilde@1138: # the path given as $2, it is used as base path for the included files. wilde@1138: wilde@1138: local file="$1" wilde@1138: local include_base="$2" wilde@1138: wilde@1138: local inc_directive wilde@1138: while [ "${inc_directive:=`grep '^###INCLUDE:' "$file" | head -1`}" ] ; do wilde@1138: local include_file="${inc_directive#'###INCLUDE:'}" wilde@1138: sed -i "/${inc_directive}/r ${include_base}/${include_file}" "$file" wilde@1138: sed -i "/${inc_directive}/d" "$file" wilde@1138: inc_directive="" wilde@1138: done wilde@1138: } wilde@1138: wilde@1138: wilde@680: TMPDIR=$(mktemp -d) wilde@700: TMPSHAR=$(mktemp "@CMAKE_BINARY_DIR@/shar.XXXXXXXXXX") wilde@680: andre@972: ARCH="$1" andre@972: andre@972: if [ "$ARCH" != "i386" -a "$ARCH" != "x86_64" ]; then andre@972: echo "Usage $0 " andre@972: echo "with archtiecture either i386 or x86_64" andre@1113: echo "defaulting to x86_64" andre@1113: ARCH=x86_64 andre@972: fi andre@972: wilde@680: INSTALLER="@CMAKE_BINARY_DIR@/TrustBridge-@PROJECT_VERSION@.sh" andre@1177: UNINSTALLER="$TMPDIR/bin/trustbridge-uninstall.sh" wilde@680: andre@1176: EXEFILES=("@CMAKE_BINARY_DIR@/cinst/trustbridge-certificate-installer" andre@1175: "@CMAKE_BINARY_DIR@/cinst/trustbridge-nss-installer" wilde@738: "@CMAKE_BINARY_DIR@/ui/trustbridge" wilde@1150: "@CMAKE_BINARY_DIR@/ui/trustbridge-tray-starter.sh" wilde@1150: "$UNINSTALLER") andre@972: andre@892: ICON="@CMAKE_SOURCE_DIR@/ui/img/logo-128.png" andre@1186: HELPFILES=$(find @CMAKE_BINARY_DIR@/doc/help/client/html \ andre@938: -maxdepth 1 -type f -printf "%p \n") andre@1186: HELPFILES_STATIC=$(find @CMAKE_BINARY_DIR@/doc/help/client/html/_static \ andre@938: -maxdepth 1 -type f -printf "%p \n") andre@1186: HELPFILES_IMG=$(find @CMAKE_BINARY_DIR@/doc/help/client/html/_images \ andre@938: -maxdepth 1 -type f -printf "%p \n") andre@1186: HELPFILES_SOURCES=$(find @CMAKE_BINARY_DIR@/doc/help/client/html/_sources \ andre@938: -maxdepth 1 -type f -printf "%p \n") andre@1249: LICENSES=$(find @CMAKE_SOURCE_DIR@/licenses \ andre@1249: -maxdepth 1 -type f -printf "%p \n") wilde@680: wilde@680: # Make installation in TMPDIR, this is what we will put into the wilde@680: # shar-archive. wilde@680: echo "Using $TMPDIR for temporary installation to build installer..." wilde@680: install -d "$TMPDIR/bin" andre@872: install -d "$TMPDIR/share/pixmaps/trustbridge" andre@938: install -d "$TMPDIR/share/doc/trustbridge" andre@938: install -d "$TMPDIR/share/doc/trustbridge/_static" andre@938: install -d "$TMPDIR/share/doc/trustbridge/_sources" andre@938: install -d "$TMPDIR/share/doc/trustbridge/_images" andre@1249: install -d "$TMPDIR/share/doc/trustbridge/licenses" wilde@711: install "${EXEFILES[@]}" "$TMPDIR/bin" andre@872: install "$ICON" "$TMPDIR/share/pixmaps/trustbridge/trustbridge.png" wilde@711: wilde@711: binnames="" wilde@711: for file in "${EXEFILES[@]}" ; do wilde@711: binnames="`basename $file` $binnames" wilde@711: done andre@938: for file in ${HELPFILES} ; do andre@938: install "$file" "$TMPDIR/share/doc/trustbridge" andre@938: helpnames="`basename $file` $helpnames" andre@938: done andre@980: for file in ${HELPFILES_IMG} ; do andre@938: install "$file" "$TMPDIR/share/doc/trustbridge/_images" andre@938: helpnames_img="`basename $file` $helpnames_img" andre@938: done andre@938: for file in ${HELPFILES_STATIC} ; do andre@938: install "$file" "$TMPDIR/share/doc/trustbridge/_static" andre@938: helpnames_static="`basename $file` $helpnames_static" andre@938: done andre@938: for file in ${HELPFILES_SOURCES}; do andre@938: install "$file" "$TMPDIR/share/doc/trustbridge/_sources" andre@938: helpnames_sources="`basename $file` $helpnames_sources" andre@938: done andre@1249: for file in ${LICENSES}; do andre@1249: install "$file" "$TMPDIR/share/doc/trustbridge/licenses" andre@1249: licensenames="`basename $file` $licensenames" andre@1249: done andre@938: wilde@1150: echo "Building $INSTALLER and $UNINSTALLER ..." wilde@1150: wilde@1150: cp "@CMAKE_BINARY_DIR@/packaging/linux-installer.inc" "$INSTALLER" wilde@1150: cp "@CMAKE_BINARY_DIR@/packaging/linux-uninstaller.inc" "$UNINSTALLER" wilde@1150: wilde@1150: declare -a INSTALLER_SCRIPTS wilde@1150: INSTALLER_SCRIPTS=("$INSTALLER" "$UNINSTALLER") wilde@1150: wilde@1150: for script in "${INSTALLER_SCRIPTS[@]}" ; do wilde@1150: process_includes "$script" "@CMAKE_BINARY_DIR@/packaging" wilde@1150: sed -i "s/###BINNAMES###/${binnames}/" "$script" wilde@1150: sed -i "s/###ICONNAME###/trustbridge.png/" "$script" wilde@1150: sed -i "s/###HELPNAMES###/${helpnames}/" "$script" wilde@1150: sed -i "s/###HELPNAMES_SOURCES###/${helpnames_sources}/" "$script" wilde@1150: sed -i "s/###HELPNAMES_STATIC###/${helpnames_static}/" "$script" wilde@1150: sed -i "s/###HELPNAMES_IMG###/${helpnames_img}/" "$script" wilde@1150: sed -i "s/###ARCH###/${ARCH}/" "$script" andre@1249: sed -i "s/###LICENSES###/${licensenames}/" "$script" wilde@1150: chmod +x "$script" wilde@1150: done wilde@1150: andre@938: echo "Creating shar archive ..." andre@938: cd "$TMPDIR" andre@938: shar -z -B `find -type f` | sed 's/^exit 0//' >>"$TMPSHAR" andre@938: wilde@700: sed -i "/###SHAR###/r $TMPSHAR" "$INSTALLER" andre@938: andre@1367: if [ "$2" != "nosign" ]; then andre@1367: echo "Signing" andre@1367: "@CMAKE_SOURCE_DIR@/ui/tests/append-sig.sh" \ andre@1367: "@CMAKE_SOURCE_DIR@/ui/tests/data/codesign/codesigning.key" \ andre@1367: "$INSTALLER" "${INSTALLER}_signed" andre@1367: mv "${INSTALLER}_signed" "$INSTALLER" andre@1367: else andre@1367: echo "Skipping sign step." andre@1367: fi wilde@680: echo "Cleaning up..." wilde@680: rm -r "$TMPDIR" wilde@700: rm "$TMPSHAR"