From 6174e69955445804b67b25bf0ed056afc426a4bd Mon Sep 17 00:00:00 2001 From: KonstantinosSykas Date: Tue, 10 Jul 2018 18:24:08 +0300 Subject: [PATCH] Linux installer (issue #300): Install/Uninstall scripts updated to handle the case where another systemwide installation is deployed to a different directory than the one that we are trying to install/uninstall. --- installers/posix/setup.body | 18 ++++++++++++++---- installers/posix/uninstall.source | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/installers/posix/setup.body b/installers/posix/setup.body index 2ac47215..b74ec6f0 100644 --- a/installers/posix/setup.body +++ b/installers/posix/setup.body @@ -114,11 +114,21 @@ SELF_FILENAME=$(basename $0) # if there is an Oolite installation in any # user home directory. -# Uninstall if possible the system-wide installation -${INSTALL_ROOT_SYSTEMWIDE}/${OOLITE_ROOT_NAME}/uninstall 2> /dev/null -if [ $? -eq ${ERROR_CODE_UNINSTALL_FAILED} ] +# Uninstall, if possible, the current active system-wide installation +if [ ${USER_IS_ROOT} ] then - exit ${ERROR_CODE_UNINSTALL_FAILED} + OOLITE_SHORTCUT=${STARTUP_SCRIPTS_PATH}/oolite${TRUNK} + if [ -e ${OOLITE_SHORTCUT} ] + then + INSTALL_ROOT_SYSTEMWIDE_ACTIVE=`cat ${OOLITE_SHORTCUT} | head -2 | tail -1` + INSTALL_ROOT_SYSTEMWIDE_ACTIVE=${INSTALL_ROOT_SYSTEMWIDE_ACTIVE%%/Oolite*} + + ${INSTALL_ROOT_SYSTEMWIDE_ACTIVE}/${OOLITE_ROOT_NAME}/uninstall 2> /dev/null + if [ $? -eq ${ERROR_CODE_UNINSTALL_FAILED} ] + then + exit ${ERROR_CODE_UNINSTALL_FAILED} + fi + fi fi # Uninstall user's instalation diff --git a/installers/posix/uninstall.source b/installers/posix/uninstall.source index 37bea329..f5ae20de 100644 --- a/installers/posix/uninstall.source +++ b/installers/posix/uninstall.source @@ -74,6 +74,23 @@ else fi fi +# Check if this is not the active Oolite systemwide installation +if [ ${USER_IS_ROOT} ] +then + OOLITE_SHORTCUT=${STARTUP_SCRIPTS_PATH}/oolite${TRUNK} + if [ -e ${OOLITE_SHORTCUT} ] + then + INSTALL_ROOT_SYSTEMWIDE_ACTIVE=`cat ${OOLITE_SHORTCUT} | head -2 | tail -1` + INSTALL_ROOT_SYSTEMWIDE_ACTIVE=${INSTALL_ROOT_SYSTEMWIDE_ACTIVE%%/Oolite*} + if [ "${INSTALL_ROOT_SYSTEMWIDE}" != "${INSTALL_ROOT_SYSTEMWIDE_ACTIVE}" ] + then + echo + echo "Error: The Oolite${TRUNK} startup scripts indicate another systemwide installation is active. Automatic uninstall will now exit to avoid impairing the active installation." + exit ${ERROR_CODE_UNINSTALL_FAILED} + fi + fi +fi + # Remove Oolite