ソースを参照

HPCC-17224 Fix INIT_PATH in configure target for development builds

Signed-off-by: Michael Gardner <michael.gardner@lexisnexis.com>
Michael Gardner 8 年 前
コミット
a2fc9a5871
1 ファイル変更69 行追加19 行削除
  1. 69 19
      initfiles/etc/DIR_NAME/CMakeLists.txt

+ 69 - 19
initfiles/etc/DIR_NAME/CMakeLists.txt

@@ -14,37 +14,87 @@
 #    See the License for the specific language governing permissions and
 #    limitations under the License.
 ################################################################################
+
 configure_file("version.in" "version")
 configure_file("environment.conf.in" "environment.conf" IMMEDIATE)
 configure_file("environment.xml.in" "environment.xml" IMMEDIATE)
-FOREACH( iFILES
+foreach(iFILES
     ${CMAKE_CURRENT_BINARY_DIR}/environment.conf
-    ${CMAKE_CURRENT_BINARY_DIR}/version
-)
-    Install ( FILES ${iFILES}  DESTINATION etc/${DIR_NAME} COMPONENT Runtime )
-ENDFOREACH ( iFILES)
+    ${CMAKE_CURRENT_BINARY_DIR}/version)
+    install(FILES ${iFILES}  DESTINATION etc/${DIR_NAME} COMPONENT Runtime)
+endforeach(iFILES)
 
-Install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/environment.xml DESTINATION etc/${DIR_NAME}/rpmnew COMPONENT Runtime )
-Install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/environment.conf DESTINATION etc/${DIR_NAME}/rpmnew COMPONENT Runtime )
-Install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/genenvrules.conf DESTINATION etc/${DIR_NAME}/rpmnew COMPONENT Runtime )
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/environment.xml DESTINATION etc/${DIR_NAME}/rpmnew COMPONENT Runtime)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/environment.conf DESTINATION etc/${DIR_NAME}/rpmnew COMPONENT Runtime)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/genenvrules.conf DESTINATION etc/${DIR_NAME}/rpmnew COMPONENT Runtime)
 
-ADD_SUBDIRECTORY(configmgr)
+add_subdirectory(configmgr)
 
+# Developer build
+# target: configure
 if(NOT "${DESTDIR}" STREQUAL "")
     message(STATUS "DESTDIR is set to ${DESTDIR}. Enabling configure target.")
-    add_custom_command(OUTPUT 
-        ${HOME_DIR}/${RUNTIME_USER}/.ssh/authorized_keys
-        ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa.pub
-        ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa
+
+    set(dirlist ${RUNTIME_PATH} ${LOG_PATH} ${LOCK_PATH} ${PID_PATH} ${INIT_PATH} ${CONFIG_DIR})
+    foreach(dir ${dirlist})
+        add_custom_command(OUTPUT ${dir}
+            COMMAND ${CMAKE_COMMAND} -E make_directory ${dir}
+            COMMENT "creating ${dir}")
+    endforeach()
+    add_custom_target(configure_directories
+        DEPENDS ${dirlist})
+
+    add_custom_command(
+        OUTPUT  ${HOME_DIR}/${RUNTIME_USER}/.ssh/authorized_keys
+                ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa.pub
+                ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa
         COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure_keys.sh
         COMMENT "Attempting to generate ssh keys if not present"
-        WORKING_DIRECTORY ${HOME_DIR}/${RUNTIME_USER}/.ssh VERBATIM)
-    add_custom_target(configure
-        COMMAND ${CMAKE_COMMAND} -E make_directory ${CONFIG_DIR}
+        WORKING_DIRECTORY ${HOME_DIR}/${RUNTIME_USER}/.ssh
+        VERBATIM)
+    add_custom_target(configure_ssh_keys
+        DEPENDS ${HOME_DIR}/${RUNTIME_USER}/.ssh/authorized_keys
+                ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa.pub
+                ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa)
+    
+    add_custom_command(OUTPUT ${CONFIG_DIR}/${ENV_XML_FILE}
         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ENV_XML_FILE} ${CONFIG_DIR}
+        DEPENDS configure_directories ${CMAKE_CURRENT_BINARY_DIR}/environment.xml)
+    add_custom_target(configure_environment_xml
+        DEPENDS ${CONFIG_DIR}/${ENV_XML_FILE})
+
+    add_custom_command(OUTPUT ${CONFIG_DIR}/${ENV_CONF_FILE}
         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ENV_CONF_FILE} ${CONFIG_DIR}
+        DEPENDS configure_directories ${CMAKE_CURRENT_BINARY_DIR}/environment.conf)
+    add_custom_target(configure_environment_conf
+        DEPENDS ${CONFIG_DIR}/${ENV_CONF_FILE})
+    
+    add_custom_command(OUTPUT ${CONFIG_DIR}/genenvrules.conf
         COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/genenvrules.conf ${CONFIG_DIR}
-        DEPENDS ${HOME_DIR}/${RUNTIME_USER}/.ssh/authorized_keys
-        ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa.pub
-        ${HOME_DIR}/${RUNTIME_USER}/.ssh/id_rsa)
+        DEPENDS configure_directories ${CMAKE_CURRENT_SOURCE_DIR}/genenvrules.conf)
+    add_custom_target(configure_genenvrules_conf
+        DEPENDS ${CONFIG_DIR}/genenvrules.conf)
+   
+    add_custom_command(OUTPUT ${INIT_PATH}/dafilesrv
+        COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/dafilesrv ${INIT_PATH}/dafilesrv
+        DEPENDS configure_directories
+                ProcessFiles-initfiles-bash-etc-init.d
+                ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/dafilesrv)
+    add_custom_command(OUTPUT ${INIT_PATH}/hpcc-init
+        COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/hpcc-init ${INIT_PATH}/hpcc-init
+        DEPENDS configure_directories
+                ProcessFiles-initfiles-bash-etc-init.d
+                ${CMAKE_BINARY_DIR}/initfiles/bash/etc/init.d/hpcc-init)
+    add_custom_target(configure_service_files
+        DEPENDS ${INIT_PATH}/hpcc-init
+                ${INIT_PATH}/dafilesrv)
+
+    add_custom_target(configure ALL
+        DEPENDS configure_ssh_keys
+                configure_directories
+                configure_environment_xml
+                configure_environment_conf
+                configure_genenvrules_conf
+                configure_service_files
+        COMMENT "Configuring ${DESTDIR} for deployment")
 endif()