浏览代码

Merge pull request #6718 from Michael-Gardner/HPCC-12223

HPCC-12223 Install-cluster.sh reworked onto candidate-5.2.0

Reviewed-By: Mark Kelly <mark.kelly@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 年之前
父节点
当前提交
05fb62759e

+ 14 - 9
CMakeLists.txt

@@ -175,20 +175,25 @@ elseif ( UNIX )
     message ( "-- Auto Detecting Packaging type")
     message ( "-- distro uses ${packageManagement}, revision is ${packageRevisionArch}" )
     if ( "${packageManagement}" STREQUAL "RPM" AND WITH_PLUGINS )
-        set ( CPACK_RPM_PACKAGE_VERSION "${projname}-with-plugins")
+        set ( CPACK_RPM_PACKAGE_VERSION "${projname}-with-plugins" )
+        set ( CPACK_RPM_SPEC_MORE_DEFINE
+"%define _use_internal_dependency_generator 0
+%define __getdeps() while read file; do /usr/lib/rpm/rpmdeps -%{1} ${file}; done | /bin/sort -u
+%define __find_provides /bin/sh -c '%{__getdeps P}'
+%define __find_requires /bin/sh -c '%{__grep} -v libRembed.so | %{__getdeps R}'" )
     endif()
     if ( "${packageManagement}" STREQUAL "DEB" )
-        set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${version}-${stagever}${packageRevisionArch}")
+        set( CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${version}-${stagever}${packageRevisionArch}" )
     elseif ( "${packageManagement}" STREQUAL "RPM" )
-        set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${version}-${stagever}.${packageRevisionArch}")
+        set( CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${version}-${stagever}.${packageRevisionArch}" )
     else()
-        set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}_${version}-${stagever}${CPACK_SYSTEM_NAME}")
+        set( CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}_${version}-${stagever}${CPACK_SYSTEM_NAME}" )
     endif ()
 endif ()
-MESSAGE ("-- Current release version is ${CPACK_PACKAGE_FILE_NAME}")
-set ( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${version}" )
+MESSAGE ( "-- Current release version is ${CPACK_PACKAGE_FILE_NAME}" )
+set( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${version}" )
 set( CPACK_SOURCE_GENERATOR TGZ )
-set(CPACK_SOURCE_IGNORE_FILES
+set( CPACK_SOURCE_IGNORE_FILES
         "~$"
         "\\\\.cvsignore$"
         "^${PROJECT_SOURCE_DIR}.*/CVS/"
@@ -255,7 +260,7 @@ if ( UNIX )
         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}" )
         ###
@@ -319,7 +324,7 @@ else ( PLATFORM )
 
       file(STRINGS "${SIGN_DIRECTORY}/passphrase.txt" PFX_PASSWORD LIMIT_COUNT 1)
 
-      add_custom_target(SIGN 
+      add_custom_target(SIGN
           COMMAND signtool sign /f "${SIGN_DIRECTORY}/hpcc_code_signing.pfx"
 /p "${PFX_PASSWORD}" /t "http://timestamp.verisign.com/scripts/timstamp.dll"
 "${CMAKE_BINARY_DIR}/${PACKAGE_FILE_NAME_PREFIX}*.exe"

+ 1 - 1
initfiles/bash/etc/init.d/hpcc_common.in

@@ -975,8 +975,8 @@ cluster_tools_init() {
    # workaround inconsistency of stat command
    cluster_log_dir_owner=$(ls -ld $CLUSTER_LOG_DIR | awk '{print $3}')
    [ "$cluster_log_dir_owner" != "${user}" ] && ${_cmd_prefix} chown ${user}:${user} $CLUSTER_LOG_DIR
-
 }
+
 ##
 ## Cleanup component
 ##

+ 3 - 4
initfiles/sbin/install-cluster.sh.in

@@ -22,7 +22,7 @@
 # Flow:
 #
 # 1. SSH Keys Generated.
-# 2. Run install-hpcc.sh through cluster-script.py to perform HPCC install and 
+# 2. Run install-hpcc.sh through cluster-script.py to perform HPCC install and
 #        configuration on remote hosts
 # 3. Return.
 #
@@ -114,7 +114,7 @@ createPayload(){
 
     echo "tar -zcvf /tmp/remote_install.tgz ${REMOTE_INSTALL}/*"
     tar -zcvf /tmp/remote_install.tgz ${REMOTE_INSTALL}/*
-    ls -l /tmp/remote_install.tgz 
+    ls -l /tmp/remote_install.tgz
     rm -rf ${REMOTE_INSTALL}
 }
 
@@ -148,7 +148,7 @@ while true ; do
     case "$1" in
         -k|--newkey) NEW_KEY=1
             shift ;;
-        -n|--concurrent) 
+        -n|--concurrent)
             if [ -n "$2" ] && [[ $2 =~ ^[0-9]+$ ]]
             then
                [ $2 -gt 0 ] && OPTOINS="${OPTIONS:+"$OPTIONS "}-n $2"
@@ -196,5 +196,4 @@ else
    echo ""
    run_cluster ${INSTALL_DIR}/sbin/install-hpcc.exp 0
 fi
-
 removePayload;

+ 22 - 9
initfiles/sbin/install-hpcc.exp

@@ -1,4 +1,4 @@
-#!/usr/bin/env expect 
+#!/usr/bin/env expect
 ################################################################################
 #    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
 #
@@ -53,7 +53,7 @@ proc checkSSHConnection {} {
    global ip user password prompt
 
    set timeout 60
-   spawn ssh ${user}@${ip} 
+   spawn ssh ${user}@${ip}
    expect {
       *?assword:* {
          send "${password}\r";
@@ -68,18 +68,19 @@ proc checkSSHConnection {} {
          exit 1;
       } eof {
          exit 1;
-      }  -re "${prompt}" { 
+      }  -re "${prompt}" {
          puts "Connection is OK"
          send "exit\r"
       }
    }
-   expect -re .*
+
+   expect -re $
    interact;
 }
 
 proc copyPayload {} {
    global ip user password prompt
-   
+
    set timeout 300
    spawn scp /tmp/remote_install.tgz ${user}@${ip}:~;
    expect {
@@ -126,7 +127,7 @@ proc expandPayload {} {
          if { [lindex $result 3] != 0 } {
             exit [lindex $result 3]
          }
-      } 
+      }
    }
    sleep 1
 }
@@ -136,6 +137,8 @@ proc runPayload {} {
 
    set basepkg  [file tail  ${pkg}]
    set timeout 60
+
+   expect -re $
    spawn ssh ${user}@${ip}
    expect {
       *?assword:* {
@@ -153,6 +156,8 @@ proc runPayload {} {
          exit 1;
       } -re "${prompt}" {}
    }
+
+   expect -re $
    send "${cmd_prefix} ${remote_install}/remote-install-engine.sh ${remote_install}/${basepkg}\r"
    expect {
       *?assword:* {
@@ -168,16 +173,24 @@ proc runPayload {} {
       }  -re "${prompt}" {}
    }
 
-   expect  -re .*
+   expect  -re $
    send "echo \$?\r"
    expect   -re "(\r\n| )(\[0-9]*)\r\n" {
       if { [string compare $expect_out(2,string) "0" ] == 0 } {
          puts "${ip}: Done."
+         set remotelog 0
       } else {
-         puts "${ip}: Cannot Ping host? (Host Alive?)"
-         exit 1
+         set remotelog 1
       }
    }
+
+   if { $remotelog == 1 } {
+      expect -re $
+      send "cat ${remote_install}/remote-install.log\r"
+      expect -re "${prompt}" {}
+      exit 1
+   }
+
    send "exit\r"
    interact
 }

+ 25 - 34
initfiles/sbin/remote-install-engine.sh.in

@@ -58,24 +58,13 @@ checkUser(){
 
 pkgCmd(){
     if [ "$1" == "deb" ]; then
-        if [ "$2" == "install" ]; then
-            PKGCMD="dpkg -i"
-        elif [ "$2" == "upgrade" ]; then
-            PKGCMD="dpkg -i"
-        else
-            echo "Bad option type."
-            exit 1
-        fi
+        PKGCMD="dpkg -i $PKG &> $outputFile; apt-get install -f -y &> $outputFile;"
     elif [ "$1" == "rpm" ]; then
-        if [ "$2" == "install" ]; then
-            PKGCMD="rpm  -ivh"
-        elif [ "$2" == "upgrade" ]; then
-            PKGCMD="rpm -Uvh"
-        else
-            echo "Bad option type."
-            exit 1
+        if [ "$2" == "install" ] || [[ "$2" != "reinstall" ]]; then
+            PKGCMD="yum install --nogpgcheck -y $PKG &> $outputFile"
+        elif [ "$2" == "reinstall" ]; then
+            PKGCMD="yum reinstall --nogpgcheck -y $PKG &> $outputFile"
         fi
-        [ $WITH_PLUGINS -eq 1 ] && PKGCMD="$PKGCMD --nodeps"
     else
         echo "BAD Package type."
         exit 1
@@ -88,37 +77,35 @@ checkInstall(){
     _USER=$?
     if [ "${_FILE}" == 0 ] && [ ${_USER} -eq 1 ]; then
         _INSTALLED=1
-        checkUpgrade
+        checkReinstall
     else
         _INSTALLED=0
     fi
 }
 
-checkUpgrade(){
-    if [ "${_INSTALLED}" == "1" ]; then
-        _VERSION=`cat ${INSTALL_DIR}${CONFIG_DIR}/version`
-        _PKG=`echo $PKG | grep -c "${_VERSION}"`
-        if [ "${_PKG}" == "1" ]; then
-            _UPGRADE=0
-        else
-            _UPGRADE=1
-        fi
+checkReinstall(){
+  if [ "${OSPKG}" == "rpm" ]; then
+    local current=$( yum info hpccsystems-platform | grep "^Release" | awk '{print $3}' )
+    local new=$( rpm -qp --info ${PKG} | grep "^Release" | awk '{print $3}' )
+    if [[ $current == $new ]]; then
+      _REINSTALL=1
+    else
+      _REINSTALL=0
     fi
+  fi
 }
 
 installPkg(){
     checkInstall
     if [ "${_INSTALLED}" == "0" ]; then
         pkgCmd $OSPKG "install"
-        $PKGCMD $PKG 1>/dev/null 2>&1;
-    elif [ "${_UPGRADE}" == "1" ]; then
-        pkgCmd $OSPKG "upgrade"
-        $PKGCMD $PKG 1>/dev/null 2>&1;
+    elif [ "${_REINSTALL}" == "1" ]; then
+        pkgCmd $OSPKG "reinstall"
     fi
-    checkInstall
-    if [ "${_INSTALLED}" == "0" ]; then
-        echo "Failed to install ${PKG} (missing dependencies?)"
-        exit 1
+    eval $PKGCMD
+    if [ $? -ne 0 ]; then
+      echo "FAILED on Package Command: ${PKGCMD}"
+      exit 1
     fi
 }
 
@@ -189,6 +176,10 @@ if [ $# -eq 0 ]; then
 fi
 
 PKG=$1
+outputFile="${REMOTE_INSTALL}/remote-install.log"
+if [ -e ${outputFile} ]; then
+    rm -rf ${outputFile}
+fi
 
 pkgtype=`echo "$PKG" | grep -i rpm`
 if [ -z $pkgtype ]; then