Explorar o código

HPCC-8528 Creat/remove symbolic links with ClientTools installend/Uninstall

The fix includes followings:
1) A new directory clienttools under the top of source tree. It seperates install
   related scripts from Platform.
2) A new script: /opt/HPCCSystems/<version>/clienttools/etc/init.d/install/post_install.sh
   It will create the symbolic links of binaries (the list is hard-coded in the script) under
   clienttools/bin in /usr/bin.
   Run it with "-u" will remove the links if they belong to current version of clienttools
   The script should be run as user root.
3) If HPCC-Platform does not exist new clienttools install will create the symbolic
   links with script post_install.sh
4) When uninstall a clienttools symbolic links will be removed with "post_install.sh -u"
   It only remove the link if it points to the file under current clienttools/bin/.
5) After clienttools uninstall, if there are still other clienttools left and not HPCC-Platform
   installed, it is user's responsibility to manually pick a clienttools and run post_install.sh
   if it exists.
6) Above fixes will be applied to rpm and deb package (Linux). There should be no change and impact
   on Mac and Windows.
7) There will be another JIRA ticket to address the similar issue on Mac OS X.
Xiaoming Wang %!s(int64=11) %!d(string=hai) anos
pai
achega
c0374c291d

+ 20 - 5
CMakeLists.txt

@@ -117,6 +117,10 @@ if ( NOT MAKE_DOCS_ONLY )
     HPCC_ADD_SUBDIRECTORY (system)
     HPCC_ADD_SUBDIRECTORY (thorlcr "PLATFORM")
     HPCC_ADD_SUBDIRECTORY (testing)
+   if ( NOT WIN32 )
+       HPCC_ADD_SUBDIRECTORY (clienttools "CLIENTTOOLS_ONLY")
+   endif()
+
 endif()
 HPCC_ADD_SUBDIRECTORY (docs "PLATFORM")
 if (APPLE OR WIN32)
@@ -243,7 +247,13 @@ if ( UNIX )
         ## CPack instruction required for Debian
         ###
         message ("-- Packing BASH installation files")
-        set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postinst;${CMAKE_CURRENT_BINARY_DIR}/initfiles/sbin/prerm;${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postrm" )
+        if ( CLIENTTOOLS_ONLY )
+            set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+"${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postinst;${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/prerm; ${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postrm")
+        else ( CLIENTTOOLS_ONLY )
+            set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postinst;${CMAKE_CURRENT_BINARY_DIR}/initfiles/sbin/prerm;${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postrm" )
+        endif ( CLIENTTOOLS_ONLY )
+    
     elseif ( "${packageManagement}" STREQUAL "RPM" )
         set ( CPACK_GENERATOR "${packageManagement}" )
         ###
@@ -251,10 +261,15 @@ if ( UNIX )
         ###
         message("-- Will build RPM package")
         message ("-- Packing BASH installation files")
-        set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postinst" )
-
-        set ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/sbin/prerm" )
-        set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postrm" )
+        if ( CLIENTTOOLS_ONLY )
+            set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postinst" )
+            set ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/prerm" )
+            set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postrm" )
+        else ( CLIENTTOOLS_ONLY )
+            set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postinst" )
+            set ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/sbin/prerm" )
+            set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postrm" )
+        endif ( CLIENTTOOLS_ONLY )
     else()
         message("WARNING: Unsupported package ${packageManagement}.")
     endif ()

+ 1 - 0
clienttools/CMakeLists.txt

@@ -0,0 +1 @@
+add_subdirectory(install)

+ 7 - 0
clienttools/install/CMakeLists.txt

@@ -0,0 +1,7 @@
+if (UNIX)
+    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/postinst.in" "postinst" )
+    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/prerm.in" "prerm" )
+    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/postrm.in" "postrm" )
+endif(UNIX)
+
+install ( PROGRAMS post_install.sh DESTINATION etc/init.d/install COMPONENT Runtime )

+ 77 - 0
clienttools/install/post_install.sh

@@ -0,0 +1,77 @@
+#!/bin/bash
+################################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+################################################################################
+
+
+SRC_DIR=$(dirname $0)
+TARGET_DIR=/usr/bin
+
+# Files in bin/ need to create/remove symbolic links
+####################################################
+files_to_link=(
+   'dfuplus'
+   'ecl'
+   'eclcc'
+   'ecl-packagemap'
+   'eclplus'
+   'ecl-queries'
+   'ecl-roxie'
+   'soapplus'
+   'start-stop-daemon'
+   'wuget'
+)
+
+# Check if this is post uninstall
+#################################
+IS_UNINSTAL=0
+[ "$1" = "-u" ] && IS_UNINSTAL=1
+
+
+
+# Get absolute path of clienttools bin directory
+################################################
+CUR_DIR=$(pwd)
+[ "$SRC_DIR" != "." ] && cd $SRC_DIR 
+SRC_DIR=$(pwd)
+CT_BIN=$(echo $SRC_DIR | sed -n "s/^\(.*clienttools\)\(.*\)/\1/p")/bin
+cd $CUR_DIR
+
+
+# Handle symbolic links
+# Only proceed if HPCC Platform is not installed
+################################################
+[ -e /opt/HPCCSystems/etc/init.d/hpcc-init ] && exit 0
+
+if [ $IS_UNINSTAL -eq 0 ]
+then
+    # Add symbolic link
+    for file in ${files_to_link[@]}
+    do
+       [ -e ${CT_BIN}/${file} ] && \
+           ln -sf ${CT_BIN}/${file}  ${TARGET_DIR}/${file}  
+    done
+
+else
+    # Remove symbolic link
+    for file in ${files_to_link[@]}
+    do
+       [ ! -e ${TARGET_DIR}/${file} ] && continue
+       ls -l ${TARGET_DIR}/${file} | egrep -q "${CT_BIN}/${file}$" 
+       [ $? -eq 0 ] && rm -rf ${TARGET_DIR}/${file}
+    done
+fi
+
+exit 0

+ 1 - 0
clienttools/install/postinst.in

@@ -0,0 +1 @@
+${CMAKE_INSTALL_PREFIX}/etc/init.d/install/post_install.sh 

+ 6 - 0
clienttools/install/postrm.in

@@ -0,0 +1,6 @@
+CLIENT_TOOLS_BASE=${PREFIX}/${DIR_NAME}/${version}
+if [ -e "$CLIENT_TOOLS_BASE" ] &&  [ -n $(ls -A $CLIENT_TOOLS_BASE) ]  
+then
+   rm -rf $CLIENT_TOOLS_BASE > /dev/null 2>&1
+fi
+

+ 1 - 0
clienttools/install/prerm.in

@@ -0,0 +1 @@
+${CMAKE_INSTALL_PREFIX}/etc/init.d/install/post_install.sh -u