From 8ac1fa1b4948a6ce5008d7bfcdd2e8c42d4f5b17 Mon Sep 17 00:00:00 2001 From: "Markus Kitsinger (SwooshyCueb)" Date: Tue, 12 Mar 2024 16:42:08 -0400 Subject: [PATCH] [irods/irods#7265] Minor reorganization + CMake TLC - Project tree structure reorganized to resemble that of main irods repo. - Added quotes around paths in CMake files. - Removed CMAKE_SHARED_LINKER_FLAGS_INIT and CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT, as no shared libraries are built. - Removed unused postinst script for nonexistent data_world package - Removed rpm package dependency declaration on openssl - Fixed postinst CPack variables --- CMakeLists.txt | 57 ++++++----- common/CMakeLists.txt | 36 +++++++ .../irods/private/indexing/configuration.hpp | 0 .../plugin_specific_configuration.hpp | 0 .../irods/private/indexing/utilities.hpp | 0 .../src/configuration.cpp | 4 +- .../src/plugin_specific_configuration.cpp | 2 +- utilities.cpp => common/src/utilities.cpp | 2 +- elasticsearch.cmake | 84 ----------------- elasticsearch/CMakeLists.txt | 70 ++++++++++++++ .../packaging}/postinst | 0 .../src/main.cpp | 6 +- indexing.cmake | 94 ------------------- indexing/CMakeLists.txt | 83 ++++++++++++++++ .../irods/private/indexing/cpp_json_kw.hpp | 0 .../private/indexing/indexing_utilities.hpp | 2 +- .../packaging}/atomic_metadata_ops.py | 0 .../indexing => indexing/packaging}/postinst | 0 .../packaging}/run_indexing_plugin_test.py | 0 .../packaging}/test_plugin_indexing.py | 0 .../src/indexing_utilities.cpp | 6 +- .../src/main.cpp | 4 +- packaging/elasticsearch/postinst | 9 -- 23 files changed, 229 insertions(+), 230 deletions(-) create mode 100644 common/CMakeLists.txt rename configuration.hpp => common/include/irods/private/indexing/configuration.hpp (100%) rename plugin_specific_configuration.hpp => common/include/irods/private/indexing/plugin_specific_configuration.hpp (100%) rename utilities.hpp => common/include/irods/private/indexing/utilities.hpp (100%) rename configuration.cpp => common/src/configuration.cpp (96%) rename plugin_specific_configuration.cpp => common/src/plugin_specific_configuration.cpp (96%) rename utilities.cpp => common/src/utilities.cpp (96%) delete mode 100644 elasticsearch.cmake create mode 100644 elasticsearch/CMakeLists.txt rename {packaging/document_type => elasticsearch/packaging}/postinst (100%) rename libirods_rule_engine_plugin-elasticsearch.cpp => elasticsearch/src/main.cpp (99%) delete mode 100644 indexing.cmake create mode 100644 indexing/CMakeLists.txt rename cpp_json_kw.hpp => indexing/include/irods/private/indexing/cpp_json_kw.hpp (100%) rename indexing_utilities.hpp => indexing/include/irods/private/indexing/indexing_utilities.hpp (99%) rename {packaging => indexing/packaging}/atomic_metadata_ops.py (100%) rename {packaging/indexing => indexing/packaging}/postinst (100%) rename {packaging => indexing/packaging}/run_indexing_plugin_test.py (100%) rename {packaging => indexing/packaging}/test_plugin_indexing.py (100%) rename indexing_utilities.cpp => indexing/src/indexing_utilities.cpp (99%) rename libirods_rule_engine_plugin-indexing.cpp => indexing/src/main.cpp (99%) delete mode 100644 packaging/elasticsearch/postinst diff --git a/CMakeLists.txt b/CMakeLists.txt index cb4827b..a2a3798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,52 +1,58 @@ -cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR) #CPACK_DEBIAN__PACKAGE_NAME +cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR) -find_package(IRODS 4.3.1 EXACT REQUIRED) +set(IRODS_MINIMUM_VERSION "4.3.1") +find_package(IRODS "${IRODS_MINIMUM_VERSION}" REQUIRED) set(IRODS_PLUGIN_REVISION "0") -set(IRODS_PLUGIN_VERSION "${IRODS_VERSION}.${IRODS_PLUGIN_REVISION}") +set(IRODS_PLUGIN_VERSION "${IRODS_MINIMUM_VERSION}.${IRODS_PLUGIN_REVISION}") set(IRODS_PACKAGE_REVISION "0") include(IrodsCXXCompiler) set(CMAKE_CXX_STANDARD ${IRODS_CXX_STANDARD}) set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs") -set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs") set(CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc") -set(CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc") include(IrodsRunpathDefaults) set(IRODS_TARGET_NAME_PREFIX irods_rule_engine_plugin) project(irods_capability-indexing - VERSION "${IRODS_PLUGIN_VERSION}" - LANGUAGES CXX) + VERSION "${IRODS_PLUGIN_VERSION}" + LANGUAGES CXX) -include(${IRODS_TARGETS_PATH}) +include("${IRODS_TARGETS_PATH}") include(GNUInstallDirs) include(UseLibCXX) if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE) - message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE) + message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'") endif() set(IRODS_BUILD_WITH_WERROR OFF CACHE BOOL "Choose whether to compile with -Werror.") if (IRODS_BUILD_WITH_WERROR) - add_compile_options(-Werror) + add_compile_options(-Werror) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options($<$:-fpermissive>) + add_compile_options($<$:-fpermissive>) endif() +if (NOT DEFINED THREADS_PREFER_PTHREAD_FLAG) + set(THREADS_PREFER_PTHREAD_FLAG TRUE) +endif() find_package(Threads REQUIRED) find_package(nlohmann_json "3.6.1" REQUIRED) find_package(OpenSSL REQUIRED) +add_subdirectory(common) +add_subdirectory(indexing) +add_subdirectory(elasticsearch) + if (NOT CPACK_GENERATOR) - set(CPACK_GENERATOR ${IRODS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE) - message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.") + set(CPACK_GENERATOR ${IRODS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE) + message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.") endif() # CPACK_DEBIAN_PACKAGE_VERSION was previously a cache variable. Evict it. @@ -54,6 +60,13 @@ unset(CPACK_DEBIAN_PACKAGE_VERSION CACHE) include(IrodsCPackCommon) +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}/rule_engines") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods") +list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods/test") + set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF) set(CPACK_COMPONENTS_GROUPING IGNORE) @@ -73,20 +86,4 @@ set(CPACK_RPM_FILE_NAME RPM-DEFAULT) set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) -# CPACK names component package files as "${CPACK_PACKAGE_FILE_NAME}-${COMPONENT_NAME}" -# CPackDeb TO_UPPERs all the component names when checking the ${CPACK_DEBIAN_...} variables - -include(${CMAKE_CURRENT_SOURCE_DIR}/indexing.cmake) -include(${CMAKE_CURRENT_SOURCE_DIR}/elasticsearch.cmake) - -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${CMAKE_INSTALL_LIBDIR}/irods") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_PLUGINS_DIRECTORY}/rule_engines") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${CMAKE_INSTALL_LOCALSTATEDIR}") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${CMAKE_INSTALL_LOCALSTATEDIR}/lib") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods") -list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX}${IRODS_HOME_DIRECTORY}/scripts/irods/test") - include(CPack) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 0000000..ebfd069 --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,36 @@ +add_library( + irods_cap_indexing_common_obj + OBJECT + "${CMAKE_CURRENT_SOURCE_DIR}/src/plugin_specific_configuration.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/configuration.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/utilities.cpp" +) +target_link_libraries( + irods_cap_indexing_common_obj + PUBLIC + irods_common + irods_server + nlohmann_json::nlohmann_json + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so" + "${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so" +) +target_include_directories( + irods_cap_indexing_common_obj + PUBLIC + "$" + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/include" + "${IRODS_EXTERNALS_FULLPATH_FMT}/include" +) +target_compile_definitions( + irods_cap_indexing_common_obj + PUBLIC + BOOST_SYSTEM_NO_DEPRECATED + RODS_SERVER + ENABLE_RE + PRIVATE + ${IRODS_COMPILE_DEFINITIONS} + ${IRODS_COMPILE_DEFINITIONS_PRIVATE} +) diff --git a/configuration.hpp b/common/include/irods/private/indexing/configuration.hpp similarity index 100% rename from configuration.hpp rename to common/include/irods/private/indexing/configuration.hpp diff --git a/plugin_specific_configuration.hpp b/common/include/irods/private/indexing/plugin_specific_configuration.hpp similarity index 100% rename from plugin_specific_configuration.hpp rename to common/include/irods/private/indexing/plugin_specific_configuration.hpp diff --git a/utilities.hpp b/common/include/irods/private/indexing/utilities.hpp similarity index 100% rename from utilities.hpp rename to common/include/irods/private/indexing/utilities.hpp diff --git a/configuration.cpp b/common/src/configuration.cpp similarity index 96% rename from configuration.cpp rename to common/src/configuration.cpp index 14ed126..10a9c99 100644 --- a/configuration.cpp +++ b/common/src/configuration.cpp @@ -1,6 +1,6 @@ -#include "configuration.hpp" +#include "irods/private/indexing/configuration.hpp" -#include "plugin_specific_configuration.hpp" +#include "irods/private/indexing/plugin_specific_configuration.hpp" #include #include diff --git a/plugin_specific_configuration.cpp b/common/src/plugin_specific_configuration.cpp similarity index 96% rename from plugin_specific_configuration.cpp rename to common/src/plugin_specific_configuration.cpp index 4f593e4..44a776c 100644 --- a/plugin_specific_configuration.cpp +++ b/common/src/plugin_specific_configuration.cpp @@ -1,4 +1,4 @@ -#include "plugin_specific_configuration.hpp" +#include "irods/private/indexing/plugin_specific_configuration.hpp" #include #include diff --git a/utilities.cpp b/common/src/utilities.cpp similarity index 96% rename from utilities.cpp rename to common/src/utilities.cpp index 5170aed..d0fa7c5 100644 --- a/utilities.cpp +++ b/common/src/utilities.cpp @@ -1,4 +1,4 @@ -#include "utilities.hpp" +#include "irods/private/indexing/utilities.hpp" #include diff --git a/elasticsearch.cmake b/elasticsearch.cmake deleted file mode 100644 index 34b27e9..0000000 --- a/elasticsearch.cmake +++ /dev/null @@ -1,84 +0,0 @@ -set(POLICY_NAME "elasticsearch") - -string(REPLACE "_" "-" POLICY_NAME_HYPHENS ${POLICY_NAME}) -set(IRODS_PACKAGE_COMPONENT_POLICY_NAME "${POLICY_NAME_HYPHENS}") -string(TOUPPER ${IRODS_PACKAGE_COMPONENT_POLICY_NAME} IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE) - -set(TARGET_NAME "${IRODS_TARGET_NAME_PREFIX}-${POLICY_NAME}") -string(REPLACE "_" "-" TARGET_NAME_HYPHENS ${TARGET_NAME}) - -set( - IRODS_PLUGIN_POLICY_COMPILE_DEFINITIONS - RODS_SERVER - ENABLE_RE -) - -set( - IRODS_PLUGIN_POLICY_LINK_LIBRARIES - irods_server -) - -add_library( - ${TARGET_NAME} - MODULE - ${CMAKE_CURRENT_SOURCE_DIR}/lib${TARGET_NAME}.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utilities.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/configuration.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_specific_configuration.cpp -) - -target_include_directories( - ${TARGET_NAME} - PRIVATE - ${IRODS_INCLUDE_DIRS} - ${IRODS_EXTERNALS_FULLPATH_BOOST}/include - ${IRODS_EXTERNALS_FULLPATH_FMT}/include -) - -target_link_libraries( - ${TARGET_NAME} - PRIVATE - ${IRODS_PLUGIN_POLICY_LINK_LIBRARIES} - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_regex.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_url.so - ${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so - irods_common - nlohmann_json::nlohmann_json -) - -target_compile_definitions( - ${TARGET_NAME} - PRIVATE - ${IRODS_PLUGIN_POLICY_COMPILE_DEFINITIONS} - ${IRODS_COMPILE_DEFINITIONS} - ${IRODS_COMPILE_DEFINITIONS_PRIVATE} - BOOST_SYSTEM_NO_DEPRECATED - IRODS_PLUGIN_VERSION="${IRODS_PLUGIN_VERSION}" -) -target_compile_options(${TARGET_NAME} PRIVATE -Wno-write-strings) -set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD ${IRODS_CXX_STANDARD}) - -install( - TARGETS - ${TARGET_NAME} - LIBRARY - DESTINATION ${IRODS_PLUGINS_DIRECTORY}/rule_engines - COMPONENT ${IRODS_PACKAGE_COMPONENT_POLICY_NAME} -) - -set(CPACK_DEBIAN_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_NAME ${TARGET_NAME_HYPHENS}) - -set(CPACK_DEBIAN_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_DEPENDS "irods-server (= ${IRODS_VERSION}), irods-runtime (= ${IRODS_VERSION}), libc6") - -set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_NAME ${TARGET_NAME_HYPHENS}) - -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/packaging/${POLICY_NAME}/postinst;") -set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/${POLICY_NAME}/postinst") - -if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "centos" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "centos linux" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "almalinux" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "rocky") - set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}, openssl") -elseif (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "opensuse") - set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}, libopenssl1_0_0") -endif() diff --git a/elasticsearch/CMakeLists.txt b/elasticsearch/CMakeLists.txt new file mode 100644 index 0000000..a7beb1b --- /dev/null +++ b/elasticsearch/CMakeLists.txt @@ -0,0 +1,70 @@ +set(IRODS_POLICY_NAME "elasticsearch") +set(IRODS_PLUGIN_TARGET_NAME "${IRODS_TARGET_NAME_PREFIX}-${IRODS_POLICY_NAME}") + +string(REPLACE "_" "-" IRODS_POLICY_NAME_HYPHENS "${IRODS_POLICY_NAME}") +set(IRODS_POLICY_PACKAGE_COMPONENT "${IRODS_POLICY_NAME_HYPHENS}") + +include(ObjectTargetHelpers) + +add_library( + "${IRODS_PLUGIN_TARGET_NAME}" + MODULE + "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp" +) +target_link_objects( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + irods_cap_indexing_common_obj +) +target_link_libraries( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + irods_common + irods_server + nlohmann_json::nlohmann_json + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_url.so" + "${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so" +) +target_include_directories( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + "${IRODS_EXTERNALS_FULLPATH_BOOST}/include" + "${IRODS_EXTERNALS_FULLPATH_FMT}/include" +) +target_compile_definitions( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + BOOST_SYSTEM_NO_DEPRECATED + RODS_SERVER + ENABLE_RE + ${IRODS_COMPILE_DEFINITIONS} + ${IRODS_COMPILE_DEFINITIONS_PRIVATE} + IRODS_PLUGIN_VERSION="${IRODS_PLUGIN_VERSION}" +) +target_compile_options( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + -Wno-write-strings +) + +install( + TARGETS + "${IRODS_PLUGIN_TARGET_NAME}" + LIBRARY + DESTINATION "${IRODS_PLUGINS_DIRECTORY}/rule_engines" + COMPONENT "${IRODS_POLICY_PACKAGE_COMPONENT}" +) + +string(TOUPPER "${IRODS_POLICY_PACKAGE_COMPONENT}" IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE) +string(REPLACE "_" "-" IRODS_PLUGIN_TARGET_NAME_HYPHENS "${IRODS_PLUGIN_TARGET_NAME}") + +# CPack variables need to be set with PARENT_SCOPE, so they will be in scope for CPack. + +set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_NAME "${IRODS_PLUGIN_TARGET_NAME_HYPHENS}" PARENT_SCOPE) +set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_DEPENDS "irods-server (= ${IRODS_VERSION}), irods-runtime (= ${IRODS_VERSION}), libc6" PARENT_SCOPE) +set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst;" PARENT_SCOPE) + +set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_NAME "${IRODS_PLUGIN_TARGET_NAME_HYPHENS}" PARENT_SCOPE) +set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}" PARENT_SCOPE) +set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst" PARENT_SCOPE) diff --git a/packaging/document_type/postinst b/elasticsearch/packaging/postinst similarity index 100% rename from packaging/document_type/postinst rename to elasticsearch/packaging/postinst diff --git a/libirods_rule_engine_plugin-elasticsearch.cpp b/elasticsearch/src/main.cpp similarity index 99% rename from libirods_rule_engine_plugin-elasticsearch.cpp rename to elasticsearch/src/main.cpp index 238017b..f55dd6e 100644 --- a/libirods_rule_engine_plugin-elasticsearch.cpp +++ b/elasticsearch/src/main.cpp @@ -1,6 +1,6 @@ -#include "configuration.hpp" -#include "plugin_specific_configuration.hpp" -#include "utilities.hpp" +#include "irods/private/indexing/configuration.hpp" +#include "irods/private/indexing/plugin_specific_configuration.hpp" +#include "irods/private/indexing/utilities.hpp" #include #include diff --git a/indexing.cmake b/indexing.cmake deleted file mode 100644 index 5a93a26..0000000 --- a/indexing.cmake +++ /dev/null @@ -1,94 +0,0 @@ -set(POLICY_NAME "indexing") - -string(REPLACE "_" "-" POLICY_NAME_HYPHENS ${POLICY_NAME}) -set(IRODS_PACKAGE_COMPONENT_POLICY_NAME "${POLICY_NAME_HYPHENS}") -string(TOUPPER ${IRODS_PACKAGE_COMPONENT_POLICY_NAME} IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE) - -set(TARGET_NAME "${IRODS_TARGET_NAME_PREFIX}-${POLICY_NAME}") -string(REPLACE "_" "-" TARGET_NAME_HYPHENS ${TARGET_NAME}) - -set( - IRODS_PLUGIN_POLICY_COMPILE_DEFINITIONS - RODS_SERVER - ENABLE_RE - ) - -set( - IRODS_PLUGIN_POLICY_LINK_LIBRARIES - irods_server - ) - -add_library( - ${TARGET_NAME} - MODULE - ${CMAKE_CURRENT_SOURCE_DIR}/lib${TARGET_NAME}.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/configuration.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_specific_configuration.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utilities.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/indexing_utilities.cpp - ) - -target_include_directories( - ${TARGET_NAME} - PRIVATE - ${IRODS_INCLUDE_DIRS} - ${IRODS_EXTERNALS_FULLPATH_BOOST}/include - ${IRODS_EXTERNALS_FULLPATH_FMT}/include - ${CMAKE_CURRENT_SOURCE_DIR}/include - ) - -target_link_libraries( - ${TARGET_NAME} - PRIVATE - ${IRODS_PLUGIN_POLICY_LINK_LIBRARIES} - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_regex.so - ${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so - ${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so - irods_common - nlohmann_json::nlohmann_json - ) - -target_compile_definitions(${TARGET_NAME} PRIVATE ${IRODS_PLUGIN_POLICY_COMPILE_DEFINITIONS} ${IRODS_COMPILE_DEFINITIONS} ${IRODS_COMPILE_DEFINITIONS_PRIVATE} BOOST_SYSTEM_NO_DEPRECATED) -target_compile_options(${TARGET_NAME} PRIVATE -Wno-write-strings) -set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD ${IRODS_CXX_STANDARD}) - -install( - TARGETS - ${TARGET_NAME} - LIBRARY - DESTINATION ${IRODS_PLUGINS_DIRECTORY}/rule_engines - COMPONENT ${IRODS_PACKAGE_COMPONENT_POLICY_NAME} - ) - -install( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_plugin_indexing.py - ${CMAKE_CURRENT_SOURCE_DIR}/packaging/atomic_metadata_ops.py - DESTINATION ${IRODS_HOME_DIRECTORY}/scripts/irods/test - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - COMPONENT ${IRODS_PACKAGE_COMPONENT_POLICY_NAME} - ) - -install( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/packaging/run_indexing_plugin_test.py - DESTINATION ${IRODS_HOME_DIRECTORY}/scripts - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - COMPONENT ${IRODS_PACKAGE_COMPONENT_POLICY_NAME} - ) - -set(CPACK_DEBIAN_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/packaging/${POLICY_NAME}/postinst;") -set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME}_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/${POLICY_NAME}/postinst") - -set(CPACK_DEBIAN_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_DEPENDS "irods-server (= ${IRODS_VERSION}), irods-runtime (= ${IRODS_VERSION}), libc6") - -set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_NAME ${TARGET_NAME_HYPHENS}) - -set(CPACK_DEBIAN_${IRODS_PACKAGE_COMPONENT_POLICY_NAME_UPPERCASE}_PACKAGE_NAME ${TARGET_NAME_HYPHENS}) - -if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "centos" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "centos linux" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "almalinux" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "rocky") - set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}, openssl") -elseif (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "opensuse") - set(CPACK_RPM_${IRODS_PACKAGE_COMPONENT_POLICY_NAME}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}, libopenssl1_0_0") -endif() diff --git a/indexing/CMakeLists.txt b/indexing/CMakeLists.txt new file mode 100644 index 0000000..6d094db --- /dev/null +++ b/indexing/CMakeLists.txt @@ -0,0 +1,83 @@ +set(IRODS_POLICY_NAME "indexing") +set(IRODS_PLUGIN_TARGET_NAME "${IRODS_TARGET_NAME_PREFIX}-${IRODS_POLICY_NAME}") + +string(REPLACE "_" "-" IRODS_POLICY_NAME_HYPHENS "${IRODS_POLICY_NAME}") +set(IRODS_POLICY_PACKAGE_COMPONENT "${IRODS_POLICY_NAME_HYPHENS}") + +include(ObjectTargetHelpers) + +add_library( + "${IRODS_PLUGIN_TARGET_NAME}" + MODULE + "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/indexing_utilities.cpp" +) +target_link_objects( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + irods_cap_indexing_common_obj +) +target_link_libraries( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + irods_common + irods_server + nlohmann_json::nlohmann_json + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_regex.so" + "${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so" +) +target_include_directories( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + "$" + "${IRODS_EXTERNALS_FULLPATH_BOOST}/include" + "${IRODS_EXTERNALS_FULLPATH_FMT}/include" +) +target_compile_definitions( + "${IRODS_PLUGIN_TARGET_NAME}" + PRIVATE + BOOST_SYSTEM_NO_DEPRECATED + RODS_SERVER + ENABLE_RE + ${IRODS_COMPILE_DEFINITIONS} + ${IRODS_COMPILE_DEFINITIONS_PRIVATE} +) + +install( + TARGETS + "${IRODS_PLUGIN_TARGET_NAME}" + LIBRARY + DESTINATION "${IRODS_PLUGINS_DIRECTORY}/rule_engines" + COMPONENT "${IRODS_POLICY_PACKAGE_COMPONENT}" +) + +install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/test_plugin_indexing.py" + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/atomic_metadata_ops.py" + DESTINATION "${IRODS_HOME_DIRECTORY}/scripts/irods/test" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + COMPONENT "${IRODS_POLICY_PACKAGE_COMPONENT}" + ) + +install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/packaging/run_indexing_plugin_test.py" + DESTINATION "${IRODS_HOME_DIRECTORY}/scripts" + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + COMPONENT "${IRODS_POLICY_PACKAGE_COMPONENT}" +) + +string(TOUPPER "${IRODS_POLICY_PACKAGE_COMPONENT}" IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE) +string(REPLACE "_" "-" IRODS_PLUGIN_TARGET_NAME_HYPHENS "${IRODS_PLUGIN_TARGET_NAME}") + +# CPack variables need to be set with PARENT_SCOPE, so they will be in scope for CPack. + +set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_NAME "${IRODS_PLUGIN_TARGET_NAME_HYPHENS}" PARENT_SCOPE) +set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_DEPENDS "irods-server (= ${IRODS_VERSION}), irods-runtime (= ${IRODS_VERSION}), libc6" PARENT_SCOPE) +set(CPACK_DEBIAN_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst;" PARENT_SCOPE) + +set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_NAME "${IRODS_PLUGIN_TARGET_NAME_HYPHENS}" PARENT_SCOPE) +set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}" PARENT_SCOPE) +set(CPACK_RPM_${IRODS_POLICY_PACKAGE_COMPONENT_UPPERCASE}_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst" PARENT_SCOPE) diff --git a/cpp_json_kw.hpp b/indexing/include/irods/private/indexing/cpp_json_kw.hpp similarity index 100% rename from cpp_json_kw.hpp rename to indexing/include/irods/private/indexing/cpp_json_kw.hpp diff --git a/indexing_utilities.hpp b/indexing/include/irods/private/indexing/indexing_utilities.hpp similarity index 99% rename from indexing_utilities.hpp rename to indexing/include/irods/private/indexing/indexing_utilities.hpp index 758b915..d39de62 100644 --- a/indexing_utilities.hpp +++ b/indexing/include/irods/private/indexing/indexing_utilities.hpp @@ -1,7 +1,7 @@ #ifndef IRODS_CAPABILITY_INDEXING_INDEXING_UTILITIES_HPP #define IRODS_CAPABILITY_INDEXING_INDEXING_UTILITIES_HPP -#include "configuration.hpp" +#include "irods/private/indexing/configuration.hpp" #include #include diff --git a/packaging/atomic_metadata_ops.py b/indexing/packaging/atomic_metadata_ops.py similarity index 100% rename from packaging/atomic_metadata_ops.py rename to indexing/packaging/atomic_metadata_ops.py diff --git a/packaging/indexing/postinst b/indexing/packaging/postinst similarity index 100% rename from packaging/indexing/postinst rename to indexing/packaging/postinst diff --git a/packaging/run_indexing_plugin_test.py b/indexing/packaging/run_indexing_plugin_test.py similarity index 100% rename from packaging/run_indexing_plugin_test.py rename to indexing/packaging/run_indexing_plugin_test.py diff --git a/packaging/test_plugin_indexing.py b/indexing/packaging/test_plugin_indexing.py similarity index 100% rename from packaging/test_plugin_indexing.py rename to indexing/packaging/test_plugin_indexing.py diff --git a/indexing_utilities.cpp b/indexing/src/indexing_utilities.cpp similarity index 99% rename from indexing_utilities.cpp rename to indexing/src/indexing_utilities.cpp index 0faf366..758812b 100644 --- a/indexing_utilities.cpp +++ b/indexing/src/indexing_utilities.cpp @@ -1,7 +1,7 @@ -#include "indexing_utilities.hpp" +#include "irods/private/indexing/indexing_utilities.hpp" -#include "cpp_json_kw.hpp" -#include "utilities.hpp" +#include "irods/private/indexing/cpp_json_kw.hpp" +#include "irods/private/indexing/utilities.hpp" #include #include diff --git a/libirods_rule_engine_plugin-indexing.cpp b/indexing/src/main.cpp similarity index 99% rename from libirods_rule_engine_plugin-indexing.cpp rename to indexing/src/main.cpp index 7ad2fc9..23608e4 100644 --- a/libirods_rule_engine_plugin-indexing.cpp +++ b/indexing/src/main.cpp @@ -1,5 +1,5 @@ -#include "indexing_utilities.hpp" -#include "utilities.hpp" +#include "irods/private/indexing/indexing_utilities.hpp" +#include "irods/private/indexing/utilities.hpp" #include #include diff --git a/packaging/elasticsearch/postinst b/packaging/elasticsearch/postinst deleted file mode 100644 index 14ca3f3..0000000 --- a/packaging/elasticsearch/postinst +++ /dev/null @@ -1,9 +0,0 @@ -if [ -f /etc/irods/service_account.config ] ; then - . /etc/irods/service_account.config -else - IRODS_SERVICE_ACCOUNT_NAME=`stat --format "%U" /var/lib/irods` - IRODS_SERVICE_GROUP_NAME=`stat --format "%G" /var/lib/irods` -fi - - -#chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods