From f4653bb963b671683ec7e0d55569922c3d3a6ca7 Mon Sep 17 00:00:00 2001
From: Pete Peterson <petersonpf@ornl.gov>
Date: Tue, 14 Aug 2018 13:37:57 -0400
Subject: [PATCH] Change back the name of the mantidplot launcher script

---
 buildconfig/CMake/LinuxPackageScripts.cmake            |  2 +-
 .../CMake/Packaging/deb/scripts/deb_post_inst.in       |  5 ++++-
 .../CMake/Packaging/deb/scripts/deb_pre_inst.in        |  3 +++
 buildconfig/CMake/Packaging/deb/scripts/deb_pre_rm.in  |  7 +++++--
 .../CMake/Packaging/rpm/scripts/rpm_post_install.sh.in | 10 +++++-----
 .../Packaging/rpm/scripts/rpm_post_uninstall.sh.in     |  2 +-
 .../CMake/Packaging/rpm/scripts/rpm_pre_install.sh.in  |  3 ---
 7 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/buildconfig/CMake/LinuxPackageScripts.cmake b/buildconfig/CMake/LinuxPackageScripts.cmake
index e43e83c5038..8fb1be25b6b 100644
--- a/buildconfig/CMake/LinuxPackageScripts.cmake
+++ b/buildconfig/CMake/LinuxPackageScripts.cmake
@@ -250,7 +250,7 @@ if (ENABLE_MANTIDPLOT)
   configure_file ( ${CMAKE_MODULE_PATH}/Packaging/launch_mantidplot.sh.in
                    ${CMAKE_CURRENT_BINARY_DIR}/launch_mantidplot.sh.install @ONLY )
   install ( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/launch_mantidplot.sh.install
-            DESTINATION ${BIN_DIR} RENAME mantidplot )
+            DESTINATION ${BIN_DIR} RENAME launch_mantidplot.sh )
 endif ()
 if (PACKAGE_WORKBENCH) # will eventually switch to ENABLE_WORKBENCH
   set ( MANTIDWORKBENCH_EXEC workbench ) # what the actual thing is called
diff --git a/buildconfig/CMake/Packaging/deb/scripts/deb_post_inst.in b/buildconfig/CMake/Packaging/deb/scripts/deb_post_inst.in
index 06b53a0d62d..4a132cd63d0 100644
--- a/buildconfig/CMake/Packaging/deb/scripts/deb_post_inst.in
+++ b/buildconfig/CMake/Packaging/deb/scripts/deb_post_inst.in
@@ -32,7 +32,10 @@ case "$1" in
     if [ -f @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot ]; then
       mv @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot_exe
       if [ ! -s @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot ]; then
-        ln -s @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot
+        ln -s @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/launch_mantidplot.sh @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot
+      fi
+      if [ ! -s @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot ]; then
+        ln -s @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/launch_mantidplot.sh @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot
       fi
     fi
     # Environment updates if required
diff --git a/buildconfig/CMake/Packaging/deb/scripts/deb_pre_inst.in b/buildconfig/CMake/Packaging/deb/scripts/deb_pre_inst.in
index 9ab9b6397ed..68ca982e0df 100644
--- a/buildconfig/CMake/Packaging/deb/scripts/deb_pre_inst.in
+++ b/buildconfig/CMake/Packaging/deb/scripts/deb_pre_inst.in
@@ -18,6 +18,9 @@ ENVVARS_ON_INSTALL=@ENVVARS_ON_INSTALL_INT@
 case "$1" in
     install|upgrade)
 	# Remove stale links if left around
+	if [  -h @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot ]; then
+	    rm @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot
+	fi
 	if [  -h @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot ]; then
 	    rm @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot
 	fi
diff --git a/buildconfig/CMake/Packaging/deb/scripts/deb_pre_rm.in b/buildconfig/CMake/Packaging/deb/scripts/deb_pre_rm.in
index 80d6bbb8c4c..04630f097c3 100644
--- a/buildconfig/CMake/Packaging/deb/scripts/deb_pre_rm.in
+++ b/buildconfig/CMake/Packaging/deb/scripts/deb_pre_rm.in
@@ -21,6 +21,9 @@ ENVVARS_ON_INSTALL=@ENVVARS_ON_INSTALL_INT@
 case "$1" in
     remove|upgrade|deconfigure)
 	# Remove links and _exe in package directory
+	if [ -h @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot ]; then
+	    rm @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/mantidplot
+	fi
 	if [ -f @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot_exe  ]; then
 	    rm @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot_exe
 	fi
@@ -38,10 +41,10 @@ case "$1" in
 	    fi
 	fi
 	;;
-
+    
     failed-upgrade)
 	;;
-
+    
     *)
 	echo "prerm called with unknown argument \`$1'" >&2
 	exit 1
diff --git a/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_install.sh.in b/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_install.sh.in
index 6950f956706..671583b86c4 100644
--- a/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_install.sh.in
+++ b/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_install.sh.in
@@ -10,11 +10,11 @@ ENVVARS_ON_INSTALL=@ENVVARS_ON_INSTALL_INT@
 if [ -f $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot ]; then
     mv $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot_exe
     if [ ! -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot ]; then
-        ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot
+        ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot
     fi
     # create link to old name so upgrading from old packages doesn't delete the executable
-    if [ ! -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh ]; then
-        ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh
+    if [ ! -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot ]; then
+        ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot
     fi
 fi
 
@@ -26,7 +26,7 @@ if [ ${ENVVARS_ON_INSTALL} -eq 1 ]; then
     ln -s $RPM_INSTALL_PREFIX0/@ETC_DIR@/mantid.pth @PYTHON_SITE@/mantid.pth
 else
     # symbolic links in world's path of mantidplot
-    if [ -f $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot ]; then
+    if [ -e $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot ]; then
       if [ ! -L /usr/bin/mantidplot@CPACK_PACKAGE_SUFFIX@ ]; then
           ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot /usr/bin/mantidplot@CPACK_PACKAGE_SUFFIX@
       fi
@@ -36,7 +36,7 @@ else
         ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidpython /usr/bin/mantidpython@CPACK_PACKAGE_SUFFIX@
     fi
     # link the workbench if it exists
-    if [ -f $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidworkbench ]; then
+    if [ -e $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidworkbench ]; then
         if [ ! -L /usr/bin/mantidworkbench@CPACK_PACKAGE_SUFFIX@ ]; then
             ln -s $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidworkbench /usr/bin/mantidworkbench@CPACK_PACKAGE_SUFFIX@
         fi
diff --git a/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_uninstall.sh.in b/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_uninstall.sh.in
index 89d9a2cceb0..2ab08a710e0 100644
--- a/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_uninstall.sh.in
+++ b/buildconfig/CMake/Packaging/rpm/scripts/rpm_post_uninstall.sh.in
@@ -10,7 +10,7 @@ ENVVARS_ON_INSTALL=@ENVVARS_ON_INSTALL_INT@
 # Remove exe and links only if it looks like we were removed
 # and not upgraded. If launch_mantidplot.sh exists then package
 # has been upgraded and MantidPlot_exe replaced so don't touch anything
-if [ ! -e $RPM_INSTALL_PREFIX0/@BIN_DIR@/mantidplot ]; then
+if [ ! -e $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh ]; then
     if [ -e $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot_exe ]; then
         rm $RPM_INSTALL_PREFIX0/@BIN_DIR@/MantidPlot_exe
     fi
diff --git a/buildconfig/CMake/Packaging/rpm/scripts/rpm_pre_install.sh.in b/buildconfig/CMake/Packaging/rpm/scripts/rpm_pre_install.sh.in
index cb51911398b..cbfabad074a 100644
--- a/buildconfig/CMake/Packaging/rpm/scripts/rpm_pre_install.sh.in
+++ b/buildconfig/CMake/Packaging/rpm/scripts/rpm_pre_install.sh.in
@@ -13,9 +13,6 @@ fi
 if [ -h $RPM_INSTALL_PREFIX0/@BIN_DIR@/Mantidplot ]; then
     rm $RPM_INSTALL_PREFIX0/@BIN_DIR@/Mantidplot
 fi
-if [ -e $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh ]; then
-    rm $RPM_INSTALL_PREFIX0/@BIN_DIR@/launch_mantidplot.sh
-fi
 
 if [ ${ENVVARS_ON_INSTALL} -eq 1 ]; then
   # Profiles
-- 
GitLab