diff --git a/CMakeLists.txt b/CMakeLists.txt index cb34586..81d8315 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,9 +51,6 @@ if(ENABLE_SANITIZE_ADDRESS AND ENABLE_SANITIZE_THREAD) message(WARNING "Both ENABLE_SANITIZE_ADDRESS and ENABLE_SANITIZE_THREAD set, only ENABLE_SANITIZE_ADDRESS effected.") endif() -add_custom_target("install-program" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Program -P cmake_install.cmake) -add_custom_target("install-profile" COMMAND ${CMAKE_COMMAND} ARGS -DCOMPONENT=Profile -P cmake_install.cmake) - enable_testing() add_subdirectory(conf) add_subdirectory(vendor) @@ -63,4 +60,5 @@ add_subdirectory(script) add_subdirectory(include) add_subdirectory(test) -install(DIRECTORY DESTINATION log) \ No newline at end of file +install(DIRECTORY DESTINATION log COMPONENT PROGRAM) +install(DIRECTORY DESTINATION plugin COMPONENT PROGRAM) \ No newline at end of file diff --git a/cmake/Package.cmake b/cmake/Package.cmake index 33dba1a..15c789f 100644 --- a/cmake/Package.cmake +++ b/cmake/Package.cmake @@ -1,12 +1,4 @@ -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CPACK_PACKAGE_NAME "stellar-debug") -else() - set(CPACK_PACKAGE_NAME "stellar") -endif() - -message(STATUS "Package: ${CPACK_PACKAGE_NAME}") - -set(CPACK_PACKAGE_VENDOR "TSG") +set(CPACK_PACKAGE_VENDOR "TSG") set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${DESCRIBE}") @@ -19,17 +11,23 @@ set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") set(CPACK_RPM_PACKAGE_AUTOREQPROV "no") set(CPACK_RPM_PACKAGE_RELEASE_DIST on) set(CPACK_RPM_DEBUGINFO_PACKAGE on) -set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in) -set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostUninstall.in) -set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PreUninstall.in) - -# Must uninstall the debug package before install release package +set(CPACK_RPM_COMPONENT_INSTALL ON) if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CPACK_RPM_PACKAGE_CONFLICTS "stellar") + set(CPACK_RPM_PROGRAM_PACKAGE_NAME "stellar-debug") + set(CPACK_RPM_LIBRARIES_PACKAGE_NAME "stellar-devel-debug") else() - set(CPACK_RPM_PACKAGE_CONFLICTS "stellar-debug") + set(CPACK_RPM_PROGRAM_PACKAGE_NAME "stellar") + set(CPACK_RPM_LIBRARIES_PACKAGE_NAME "stellar-devel") endif() +set(CPACK_COMPONENT_PROGRAM_REQUIRED TRUE) +set(CPACK_RPM_PROGRAM_PACKAGE_CONFLICTS ${CPACK_RPM_PROGRAM_PACKAGE_NAME}) + +set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE) +set(CPACK_RPM_LIBRARIES_PACKAGE_CONFLICTS ${CPACK_RPM_LIBRARIES_PACKAGE_NAME}) + +set(CPACK_COMPONENTS_ALL LIBRARIES PROGRAM) + # setup %config(noreplace) set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/conf/stellar.toml") diff --git a/cmake/PostInstall.in b/cmake/PostInstall.in deleted file mode 100644 index ab0272d..0000000 --- a/cmake/PostInstall.in +++ /dev/null @@ -1,2 +0,0 @@ -%systemd_post stellar.service -/sbin/ldconfig \ No newline at end of file diff --git a/cmake/PostUninstall.in b/cmake/PostUninstall.in deleted file mode 100644 index fda72ad..0000000 --- a/cmake/PostUninstall.in +++ /dev/null @@ -1,2 +0,0 @@ -%systemd_postun_with_restart stellar.service -/sbin/ldconfig \ No newline at end of file diff --git a/cmake/PreUninstall.in b/cmake/PreUninstall.in deleted file mode 100644 index e24c506..0000000 --- a/cmake/PreUninstall.in +++ /dev/null @@ -1 +0,0 @@ -%systemd_preun stellar.service \ No newline at end of file diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt index 326ef77..5040b1e 100644 --- a/conf/CMakeLists.txt +++ b/conf/CMakeLists.txt @@ -1,2 +1,2 @@ -install(FILES stellar.toml DESTINATION conf COMPONENT Profile) -install(FILES log.toml DESTINATION conf COMPONENT Profile) \ No newline at end of file +install(FILES stellar.toml DESTINATION conf COMPONENT PROGRAM) +install(FILES log.toml DESTINATION conf COMPONENT PROGRAM) \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 881c5ea..ac87277 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,7 +1,7 @@ -install(FILES stellar/utils.h DESTINATION include/stellar/ COMPONENT HEADER) -install(FILES stellar/tuple.h DESTINATION include/stellar/ COMPONENT HEADER) -install(FILES stellar/packet.h DESTINATION include/stellar/ COMPONENT HEADER) -install(FILES stellar/session.h DESTINATION include/stellar/ COMPONENT HEADER) -install(FILES stellar/stellar.h DESTINATION include/stellar/ COMPONENT HEADER) -install(FILES stellar/session_mq.h DESTINATION include/stellar/ COMPONENT HEADER) -install(FILES stellar/session_exdata.h DESTINATION include/stellar/ COMPONENT HEADER) \ No newline at end of file +install(FILES stellar/utils.h DESTINATION include/stellar/ COMPONENT LIBRARIES) +install(FILES stellar/tuple.h DESTINATION include/stellar/ COMPONENT LIBRARIES) +install(FILES stellar/packet.h DESTINATION include/stellar/ COMPONENT LIBRARIES) +install(FILES stellar/session.h DESTINATION include/stellar/ COMPONENT LIBRARIES) +install(FILES stellar/stellar.h DESTINATION include/stellar/ COMPONENT LIBRARIES) +install(FILES stellar/session_mq.h DESTINATION include/stellar/ COMPONENT LIBRARIES) +install(FILES stellar/session_exdata.h DESTINATION include/stellar/ COMPONENT LIBRARIES) \ No newline at end of file diff --git a/script/CMakeLists.txt b/script/CMakeLists.txt index 35cd5b8..7243c1d 100644 --- a/script/CMakeLists.txt +++ b/script/CMakeLists.txt @@ -1,2 +1,2 @@ -install(FILES python_stat.sh DESTINATION ./ COMPONENT Program) -install(FILES shell_stat.sh DESTINATION ./ COMPONENT Program) \ No newline at end of file +install(FILES python_stat.sh DESTINATION ./ COMPONENT PROGRAM) +install(FILES shell_stat.sh DESTINATION ./ COMPONENT PROGRAM) \ No newline at end of file diff --git a/src/plugin/plugin_manager.cpp b/src/plugin/plugin_manager.cpp index ed2c319..2dfa3cc 100644 --- a/src/plugin/plugin_manager.cpp +++ b/src/plugin/plugin_manager.cpp @@ -256,6 +256,10 @@ struct plugin_manager_schema *plugin_manager_init(struct stellar *st, const char void plugin_manager_exit(struct plugin_manager_schema *plug_mgr) { + if (plug_mgr == NULL) + { + return; + } struct plugin_specific *p=NULL; if (plug_mgr->plugin_load_specs_array) { diff --git a/src/stellar/CMakeLists.txt b/src/stellar/CMakeLists.txt index 9eb856c..2cb23ad 100644 --- a/src/stellar/CMakeLists.txt +++ b/src/stellar/CMakeLists.txt @@ -13,5 +13,5 @@ target_link_libraries(stellar stellar_core) target_link_libraries(stellar "-rdynamic") set_target_properties(stellar PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/version.map") -install(TARGETS stellar RUNTIME DESTINATION bin COMPONENT Program) +install(TARGETS stellar RUNTIME DESTINATION bin COMPONENT PROGRAM) install(TARGETS stellar_devel LIBRARY DESTINATION lib COMPONENT LIBRARIES) \ No newline at end of file diff --git a/src/stellar/stellar.cpp b/src/stellar/stellar.cpp index 957c7a9..21e9959 100644 --- a/src/stellar/stellar.cpp +++ b/src/stellar/stellar.cpp @@ -44,7 +44,7 @@ static uint64_t need_exit = 0; static thread_local uint16_t __thread_id = 0; static const char *log_config_file = "./conf/log.toml"; static const char *main_config_file = "./conf/stellar.toml"; -static const char *plugin_config_file = "./stellar_plugin/spec.toml"; +static const char *plugin_config_file = "./plugin/spec.toml"; /****************************************************************************** * Stellar Thread Main Loop diff --git a/test/packet_inject/CMakeLists.txt b/test/packet_inject/CMakeLists.txt index de423bf..63af63e 100644 --- a/test/packet_inject/CMakeLists.txt +++ b/test/packet_inject/CMakeLists.txt @@ -27,4 +27,4 @@ packet_inject_add_case(gtest_inject_tcp_payload_fin_rst_after_recv_c2s_first_pay file(COPY ./conf/ DESTINATION ./conf/) file(COPY ./pcap/ DESTINATION ./pcap/) -file(COPY ./stellar_plugin/ DESTINATION ./stellar_plugin/) \ No newline at end of file +file(COPY ./plugin/ DESTINATION ./plugin/) \ No newline at end of file diff --git a/test/packet_inject/packet_inject_test.cpp b/test/packet_inject/packet_inject_test.cpp index ca3e2fb..dfe5801 100644 --- a/test/packet_inject/packet_inject_test.cpp +++ b/test/packet_inject/packet_inject_test.cpp @@ -150,7 +150,7 @@ void packet_inject_test(struct packet_inject_case *test) } system_cmd("cp %s/%s %s", test->input_prefix, test->input_pcap, dumpfile_dir); system_cmd("cp -r conf %s/", test->work_dir); - system_cmd("cp -r stellar_plugin %s/", test->work_dir); + system_cmd("cp -r plugin %s/", test->work_dir); system_cmd("cp -r libpacket_inject_plugin.so %s/", test->work_dir); // run packet injector diff --git a/test/packet_inject/stellar_plugin/spec.toml b/test/packet_inject/plugin/spec.toml similarity index 100% rename from test/packet_inject/stellar_plugin/spec.toml rename to test/packet_inject/plugin/spec.toml