Skip to content

Commit

Permalink
Fix launch_mantidplot script when not run under bash
Browse files Browse the repository at this point in the history
dirname is a bash function and is not available in all shells.
Refs #10271
  • Loading branch information
martyngigg committed Nov 28, 2014
1 parent ecd9f8f commit dd80a6e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
26 changes: 8 additions & 18 deletions Code/Mantid/Build/CMake/LinuxPackageScripts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,18 @@ endif()
# MantidPlot launcher script
############################################################################
# Local dev version
file ( WRITE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launch_mantidplot.sh "#!/bin/bash\n"
"#\n"
"# Launch Mantidplot using any necessary LD_PRELOAD or software collection behaviour\n"
"#\n"
"INSTALLDIR=$(dirname $(readlink -f \"$0\"))\n"
"LOCAL_PRELOAD=${EXTRA_LDPRELOAD_LIBS}:\${LD_PRELOAD}\n"
"LOCAL_LDPATH=${EXTRA_LDPATH}:\${LD_LIBRARY_PATH}\n"
"if [ -z \"\${TCMALLOC_RELEASE_RATE}\" ]; then\n"
" TCM_RELEASE=10000\n"
"else\n"
" TCM_RELEASE=\${TCMALLOC_RELEASE_RATE}\n"
"fi\n"
"\n"
"LD_PRELOAD=\${LOCAL_PRELOAD} TCMALLOC_RELEASE_RATE=\${TCM_RELEASE} LD_LIBRARY_PATH=\${LOCAL_LDPATH} ${WRAPPER_COMMAND} \"\$INSTALLDIR/MantidPlot_exe $*\" \n"
"\n"
)
set ( MANTIDPLOT_EXEC MantidPlot )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/launch_mantidplot.sh.in
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launch_mantidplot.sh @ONLY )
# Needs to be executable
execute_process ( COMMAND "chmod" "+x" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launch_mantidplot.sh"
OUTPUT_QUIET ERROR_QUIET )
# Package version
install ( FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launch_mantidplot.sh
DESTINATION ${BIN_DIR}
set ( MANTIDPLOT_EXEC MantidPlot_exe )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/launch_mantidplot.sh.in
${CMAKE_CURRENT_BINARY_DIR}/launch_mantidplot.sh.install @ONLY )
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/launch_mantidplot.sh
DESTINATION ${BIN_DIR} RENAME launch_mantidplot.sh
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
Expand Down
21 changes: 21 additions & 0 deletions Code/Mantid/Build/CMake/Packaging/launch_mantidplot.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
#
# Launch Mantidplot using any necessary LD_PRELOAD or software collection behaviour
#
# Script is configured by CMake

# Find out where we are
SCRIPTFILE=$(readlink -f \"$0\")
INSTALLDIR=$(echo $SCRIPTFILE | sed -r -e 's|^(.*)/(.*)$|\1|g') #.* is greedy and eats up until the final slash

# Define extra libraries and load paths
LOCAL_PRELOAD=@EXTRA_LDPRELOAD_LIBS@:${LD_PRELOAD}
LOCAL_LDPATH=@EXTRA_LDPATH@:${LD_LIBRARY_PATH}
if [ -z \"${TCMALLOC_RELEASE_RATE}\" ]; then
TCM_RELEASE=10000
else
TCM_RELEASE=${TCMALLOC_RELEASE_RATE}
fi

# Launch
LD_PRELOAD=${LOCAL_PRELOAD} TCMALLOC_RELEASE_RATE=${TCM_RELEASE} LD_LIBRARY_PATH=${LOCAL_LDPATH} @WRAPPER_COMMAND@ \"$INSTALLDIR/@MANTIDPLOT_EXEC@ $*\"

0 comments on commit dd80a6e

Please sign in to comment.