diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-09-08 19:42:53 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-09-21 13:31:37 +0200 |
commit | 21d157abaaffe41382ccb0524d8f255f79bec8b1 (patch) | |
tree | d3862876b27c0672eb783543cd59635e90e55683 | |
parent | 5c83305c4c395cf79f19c6fc63e8d566e3815598 (diff) | |
download | mariadb-git-21d157abaaffe41382ccb0524d8f255f79bec8b1.tar.gz |
MDEV-14560 Extra engines enabled through additional config are not loaded on first installation
RPM solution:
Make all server plugins to restart the server when installed.
To avoid multiple server restarts, do it only once in posttrans scriptlet.
Add support for CPACK_RPM_<component>_POST_TRANS_SCRIPT_FILE
-rw-r--r-- | cmake/CPackRPM.cmake | 34 | ||||
-rw-r--r-- | cmake/cpack_rpm.cmake | 2 | ||||
-rw-r--r-- | cmake/plugin.cmake | 2 | ||||
-rw-r--r-- | support-files/rpm/plugin-postin.sh | 2 | ||||
-rw-r--r-- | support-files/rpm/server-posttrans.sh | 11 | ||||
-rw-r--r-- | support-files/rpm/server-postun.sh | 8 |
6 files changed, 52 insertions, 7 deletions
diff --git a/cmake/CPackRPM.cmake b/cmake/CPackRPM.cmake index 3b57decc5bb..326013f06b3 100644 --- a/cmake/CPackRPM.cmake +++ b/cmake/CPackRPM.cmake @@ -2,6 +2,11 @@ # Wrapper for CPackRPM.cmake # +# +# Support for per-component LICENSE and VENDOR +# +# per component values, if present, are copied into global CPACK_RPM_PACKAGE_xxx +# macro(set_from_component WHAT) set(orig_CPACK_RPM_PACKAGE_${WHAT} ${CPACK_RPM_PACKAGE_${WHAT}}) if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${WHAT}) @@ -15,6 +20,33 @@ endmacro() set_from_component(LICENSE) set_from_component(VENDOR) +# +# Support for the %posttrans scriptlet +# +# the scriptlet, if present, is appended (together with the %posttrans tag) +# to the pre-uninstall scriptlet +# +set(base_time "PRE") +set(base_type "UNINSTALL") +set(base_var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}_SCRIPT_FILE) +set(acc) + +macro(read_one_file time_ type_ tag_) + set(var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${time_}_${type_}_SCRIPT_FILE) + if (${var}) + file(READ ${${var}} content) + set(acc "${tag_}\n${content}\n\n${acc}") + endif() +endmacro() + +read_one_file("POST" "TRANS" "%posttrans") +if (acc) + set(orig_${base_var} ${${base_var}}) + read_one_file(${base_time} ${base_type} "") + set(${base_var} ${CPACK_TOPLEVEL_DIRECTORY}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}.scriptlet) + file(WRITE ${${base_var}} "${acc}") +endif() + # load the original CPackRPM.cmake set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) unset(CMAKE_MODULE_PATH) @@ -23,10 +55,10 @@ set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) restore(LICENSE) restore(VENDOR) +set(${base_var} ${orig_${base_var}}) # per-component cleanup foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) unset(TMP_RPM_${_RPM_SPEC_HEADER}) unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) endforeach() - diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 5b8aa36ff0d..21eb2632a50 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -81,6 +81,7 @@ SET(CPACK_RPM_SPEC_MORE_DEFINE " %define _bindir ${INSTALL_BINDIRABS} %define _sbindir ${INSTALL_SBINDIRABS} %define _sysconfdir ${INSTALL_SYSCONFDIR} +%define restart_flag %{_localstatedir}/lib/rpm-state/mariadb-restart ") # this creative hack is described here: http://www.cmake.org/pipermail/cmake/2012-January/048416.html @@ -179,6 +180,7 @@ SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/r SET(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-preun.sh) SET(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postin.sh) SET(CPACK_RPM_server_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postun.sh) +SET(CPACK_RPM_server_POST_TRANS_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-posttrans.sh) SET(CPACK_RPM_shared_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) SET(CPACK_RPM_shared_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) SET(CPACK_RPM_compat_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 26acf442620..9b7af6065e2 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -243,6 +243,8 @@ MACRO(MYSQL_ADD_PLUGIN) ENDIF() INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR}) SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/plugin-postin.sh PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_POST_TRANS_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-posttrans.sh PARENT_SCOPE) ENDIF() ENDIF() ELSE() diff --git a/support-files/rpm/plugin-postin.sh b/support-files/rpm/plugin-postin.sh new file mode 100644 index 00000000000..6be31a35f8e --- /dev/null +++ b/support-files/rpm/plugin-postin.sh @@ -0,0 +1,2 @@ +# request the server restart +echo > %{restart_flag} diff --git a/support-files/rpm/server-posttrans.sh b/support-files/rpm/server-posttrans.sh new file mode 100644 index 00000000000..0d242596185 --- /dev/null +++ b/support-files/rpm/server-posttrans.sh @@ -0,0 +1,11 @@ +if [ -r %{restart_flag} ] ; then + rm %{restart_flag} + if [ -x /usr/bin/systemctl ] ; then + /usr/bin/systemctl daemon-reload > /dev/null 2>&1 + fi + + # only restart the server if it was alredy running + if %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then + %{_sysconfdir}/init.d/mysql restart + fi +fi diff --git a/support-files/rpm/server-postun.sh b/support-files/rpm/server-postun.sh index 412c6f4c67b..b1aa0ea4393 100644 --- a/support-files/rpm/server-postun.sh +++ b/support-files/rpm/server-postun.sh @@ -1,10 +1,6 @@ if [ $1 -ge 1 ]; then - if [ -x %{_sysconfdir}/init.d/mysql ] ; then - # only restart the server if it was alredy running - if %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then - %{_sysconfdir}/init.d/mysql restart - fi - fi + # request the server restart + echo > %{restart_flag} fi if [ $1 = 0 ] ; then |