From 7f4c0757db974e8fbc32d67a5f2500e2e05fffb2 Mon Sep 17 00:00:00 2001
From: an7s <an7s@git.zephyr-software.com>
Date: Tue, 26 Apr 2016 16:32:05 +0000
Subject: [PATCH] Create desktop shortcut as part of installation process

Former-commit-id: 31f762d6d99593016e9d3d0d9f060aefb2dcd8dc
---
 tools/do_installer.sh | 23 +++++++++++-----
 tools/ps_install.sh   | 64 +++++++++++++++++++++++++++++++++----------
 2 files changed, 66 insertions(+), 21 deletions(-)

diff --git a/tools/do_installer.sh b/tools/do_installer.sh
index 355a11038..afe06896c 100755
--- a/tools/do_installer.sh
+++ b/tools/do_installer.sh
@@ -52,16 +52,25 @@ cd $USER_DOWNLOAD_DIR/$INSTALLER_DIR
 rm -fr *.tar *.tgz *peasoup* *instal* *analysis*
 
 # make install script
-cp $PEASOUP_HOME/tools/ps_install.sh $PROG.install.sh
-chmod +x $PROG.install.sh
+installer_name=${PROG}.installer.sh
+cp $PEASOUP_HOME/tools/ps_install.sh ${ANALYSIS_DIR}/${installer_name}
+chmod +x ${ANALYSIS_DIR}/${installer_name}
+
+# create self-extracting archive/installer
+makeself --notemp ${ANALYSIS_DIR} ${PROG}.installer "Self-extracting installer for ${PROG}" ./${installer_name}
+
+mv ${PROG}.installer ${ANALYSIS_DIR}
+
 # link to analysis dir
-ln -s $ANALYSIS_DIR analysis_dir
+#ln -s $ANALYSIS_DIR analysis_dir
+
+# create self installing archive
 
 # make the tarball
-cd $USER_DOWNLOAD_DIR
-tar -hcvf $PROG.tar $INSTALLER_DIR
-gzip $PROG.tar
-mv $PROG.tar.gz "${ANALYSIS_DIR}/${PROG}.tgz"
+#cd $USER_DOWNLOAD_DIR
+#tar -hcvf $PROG.tar $INSTALLER_DIR
+#gzip $PROG.tar
+#mv $PROG.tar.gz "${ANALYSIS_DIR}/${PROG}.zar"
 
 # cleanup
 #if [ ! -z $USER_DOWNLOAD_DIR ]; then
diff --git a/tools/ps_install.sh b/tools/ps_install.sh
index a33bb8637..a4eb210b0 100644
--- a/tools/ps_install.sh
+++ b/tools/ps_install.sh
@@ -1,20 +1,37 @@
 #!/bin/bash
 
 # Installer name is of the form: program.install.sh
-PROG=$(basename $0 .install.sh)
+PROG=$(basename $0 .installer.sh)
 
 # Default installation directory
-INSTALL_DIR=/tmp/protected/bin
-
-if [ ! -d analysis_dir ]; then
-	echo "Looks like you've already installed ${PROG}"
-	echo
-	echo "Type any key to continue"
-	read anykey
-	exit 1
-fi
+INSTALL_DIR=/tmp/zest_install/bin
+DESKTOP_ZEPHYR_DIR=$HOME/Desktop/ZephyrProtected
+
+create_desktop_shortcut()
+{
+	name=$1
+	pathprotected=$2
+	if [ -d "$HOME/Desktop" ]; then
+		if [ ! -d "$DESKTOP_ZEPHYR_DIR" ]; then
+			mkdir $DESKTOP_ZEPHYR_DIR
+		fi
+		desktopfile=${DESKTOP_ZEPHYR_DIR}/${name}.desktop
+		echo "[Desktop Entry]" > $desktopfile
+		echo "Name=$name" >> $desktopfile
+		echo "Comment=Run $name" >> $desktopfile
+		echo "Exec=${pathprotected}" >> $desktopfile
+		echo 'Terminal=false' >> $desktopfile
+		echo 'Type=Application' >> $desktopfile
+		echo 'Icon=utilities-terminal' >> $desktopfile
+		chmod +x $desktopfile
+		return 0
+	else
+		return 1
+	fi
+}
 
-echo "Installing protected version of $PROG"
+echo ================================================================
+echo "Installing $PROG"
 echo "Installation directory: $INSTALL_DIR"
 echo "Fully qualified path: $INSTALL_DIR/$PROG"
 
@@ -25,19 +42,38 @@ read anykey
 # in case it's not there yet
 mkdir -p $INSTALL_DIR
 
-chmod +x analysis_dir/a.stratafied
+chmod +x ./a.stratafied
 
 # wipe out any old installs
 if [ -d "$INSTALL_DIR/${PROG}_analysis" ]; then
 	rm -fr "$INSTALL_DIR/${PROG}_analysis"
 fi
 
-#cp -r analysis_dir $INSTALL_DIR/${PROG}_analysis
-mv analysis_dir $INSTALL_DIR/${PROG}_analysis
+cp -r . $INSTALL_DIR/${PROG}_analysis
+#mv analysis_dir $INSTALL_DIR/${PROG}_analysis
 echo "$INSTALL_DIR/${PROG}_analysis/ps_run.sh $INSTALL_DIR/${PROG}_analysis \"\$0\" \"\$@\"" > $INSTALL_DIR/$PROG
 chmod +x $INSTALL_DIR/$PROG
 
+echo "Create desktop shortcut (yes|no)?"
+read answer
+case "$answer" in 
+	y|yes)
+		create_desktop_shortcut ${PROG} ${INSTALL_DIR}/${PROG}
+		if [ $? -eq 0 ]; then
+			echo Desktop shortcut succesfully created in $DESKTOP_ZEPHYR_DIR
+		else
+			echo Could not create desktop shortcut in $DESKTOP_ZEPHYR_DIR
+		fi
+		;;
+	*)
+		echo No desktop shortcut created
+		;;
+esac
+
+echo ""
 echo "Installation complete"
 echo ""
+echo ================================================================
 echo "Type any key to continue"
+
 read anykey
-- 
GitLab