Skip to content

Commit

Permalink
Add Debian pre & post install scripts
Browse files Browse the repository at this point in the history
Refs #10271
  • Loading branch information
martyngigg committed Nov 25, 2014
1 parent fa84dd3 commit 91db9e8
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Code/Mantid/Build/CMake/LinuxPackageScripts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ endif()
set ( PRE_INSTALL_FILE ${CMAKE_CURRENT_BINARY_DIR}/preinst )
set ( POST_INSTALL_FILE ${CMAKE_CURRENT_BINARY_DIR}/postinst )
set ( PRE_UNINSTALL_FILE ${CMAKE_CURRENT_BINARY_DIR}/prerm )
set ( PRE_UNINSTALL_FILE ${CMAKE_CURRENT_BINARY_DIR}/postrm )
set ( POST_UNINSTALL_FILE ${CMAKE_CURRENT_BINARY_DIR}/postrm )

if ( "${UNIX_DIST}" MATCHES "RedHatEnterprise" OR "${UNIX_DIST}" MATCHES "^Fedora" ) # RHEL/Fedora
set ( PKG_INSTALL_PREFIX \$RPM_INSTALL_PREFIX0 ) # used in mainter scripts

if ( NOT MPI_BUILD )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/rpm/scripts/rpm_pre_install.sh.in
${PRE_INSTALL_FILE} )
${PRE_INSTALL_FILE} @ONLY )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/rpm/scripts/rpm_post_install.sh.in
${POST_INSTALL_FILE} )
${POST_INSTALL_FILE} @ONLY )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/rpm/scripts/rpm_pre_uninstall.sh.in
${PRE_UNINSTALL_FILE} )
${PRE_UNINSTALL_FILE} @ONLY )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/rpm/scripts/rpm_post_install.sh.in
${POST_UNINSTALL_FILE} )
${POST_UNINSTALL_FILE} @ONLY )
# CPack variables
set ( CPACK_RPM_PRE_INSTALL_SCRIPT_FILE ${PRE_INSTALL_FILE} )
set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${POST_INSTALL_FILE} )
Expand All @@ -112,11 +112,17 @@ elseif ( "${UNIX_DIST}" MATCHES "Ubuntu" )
set ( MANTIDPLOT_LAUNCHER_PREFIX "LD_PRELOAD=${EXTRA_LDPRELOAD_LIBS} eval" )

if ( NOT MPI_BUILD )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/deb/scripts/deb_pre_inst.in
${PRE_INSTALL_FILE} @ONLY )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/deb/scripts/deb_post_inst.in
${POST_INSTALL_FILE} )
${POST_INSTALL_FILE} @ONLY )
configure_file ( ${CMAKE_MODULE_PATH}/Packaging/deb/scripts/deb_pre_rm.in
${PRE_UNINSTALL_FILE} @ONLY )
# No postrm script as dpkg removes empty directories if everything else is tidied away.

# CPack variables
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${POST_INSTALL_FILE}" )
"${PRE_INSTALL_FILE};${POST_INSTALL_FILE};${PRE_UNINSTALL_FILE}" )
endif()
# Launcher prefix
set ( MANTIDPLOT_LAUNCHER_PREFIX "LD_PRELOAD=\${EXTRA_LDPRELOAD_LIBS} eval" )
Expand Down
52 changes: 52 additions & 0 deletions Code/Mantid/Build/CMake/Packaging/deb/scripts/deb_pre_inst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh
# postinst script for mantid
#

set -e

# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

# Configured by cmake
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
# Stale _exe
if [ -f @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot_exe ]; then
rm @CMAKE_INSTALL_PREFIX@/@BIN_DIR@/MantidPlot_exe
fi

if [ ${ENVVARS_ON_INSTALL} -eq 1 ]; then
# Profiles
if [ -h /etc/profile.d/mantid.sh ]; then
rm /etc/profile.d/mantid.sh
fi
if [ -h /etc/profile.d/mantid.csh ]; then
rm /etc/profile.d/mantid.csh
fi
fi
;;

abort-upgrade)
;;

*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

exit 0
51 changes: 51 additions & 0 deletions Code/Mantid/Build/CMake/Packaging/deb/scripts/deb_pre_rm.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh
# postinst script for mantid
#

set -e

# summary of how this script can be called:
# * <prerm> `remove'
# * <old-prerm> `upgrade' <new-version>
# * <new-prerm> `failed-upgrade' <old-version>
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
# * <deconfigured's-prerm> `deconfigure' `in-favour'
# <package-being-installed> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

# Configured by cmake
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

# If we were configured to install profile scripts, remove them
if [ ${ENVVARS_ON_INSTALL} -eq 1 ]; then
if [ -h /etc/profile.d/mantid.sh ]; then
rm /etc/profile.d/mantid.sh
fi
if [ -h /etc/profile.d/mantid.csh ]; then
rm /etc/profile.d/mantid.csh
fi
fi
;;

failed-upgrade)
;;

*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac

exit 0

0 comments on commit 91db9e8

Please sign in to comment.