Switch from SCONS to CMAKE building tooling

Related: #1982642
This commit is contained in:
Michal Schorm 2021-06-10 04:59:26 +02:00
parent 01108d2e6d
commit 16825667bb
3 changed files with 144 additions and 46 deletions

112
cmake_paths.patch Normal file
View File

@ -0,0 +1,112 @@
1) Documentation files
--- galera-26.4.8/CMakeLists.txt 2021-04-08 08:05:44.000000000 +0200
+++ galera-26.4.8/CMakeLists.txt_patched 2021-06-10 01:40:26.886770832 +0200
@@ -106,14 +106,19 @@ add_subdirectory(galera)
add_subdirectory(scripts/packages)
add_subdirectory(wsrep/tests)
+# Make the intall destination for documentation files configurable
+if(NOT DEFINED INSTALL_DOCDIR)
+ set(INSTALL_DOCDIR "doc" CACHE STRING "path to install documentaion to")
+endif()
+
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD")
install(FILES
${CMAKE_SOURCE_DIR}/AUTHORS
${CMAKE_SOURCE_DIR}/COPYING
${CMAKE_SOURCE_DIR}/README
- DESTINATION doc)
+ DESTINATION ${INSTALL_DOCDIR} )
install(FILES ${CMAKE_SOURCE_DIR}/asio/LICENSE_1_0.txt
- DESTINATION doc
+ DESTINATION ${INSTALL_DOCDIR}
RENAME LICENSE.asio)
endif()
2) Configuration file
3) Executable files
4) Systemd service file
--- galera-26.4.8/garb/CMakeLists.txt 2021-06-10 03:54:55.482520883 +0200
+++ galera-26.4.8/garb/CMakeLists.txt_patched 2021-06-10 03:54:41.070274710 +0200
@@ -31,14 +31,51 @@ target_compile_options(garbd
target_link_libraries(garbd gcs4garb gcomm gcache
${Boost_PROGRAM_OPTIONS_LIBRARIES})
-install(TARGETS garbd DESTINATION bin)
+# Make the install destination for garbd binary configurable
+if(NOT DEFINED INSTALL_GARBD)
+ set(INSTALL_GARBD "bin" CACHE STRING "path to install garbd binary to")
+endif()
+
+install(TARGETS garbd
+ DESTINATION ${INSTALL_GARBD})
+
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD")
+
+ # Make the install destination for garbd-systemd wrapper script configurable
+ if(NOT DEFINED INSTALL_GARBD-SYSTEMD)
+ set(INSTALL_GARBD-SYSTEMD "share" CACHE STRING "path to install garbd-systemd wrapper script to")
+ endif()
+
+ install(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/garb-systemd
+ DESTINATION ${INSTALL_GARBD-SYSTEMD})
+
+ # Make the install destination for garbd configuration file configurable
+ if(NOT DEFINED INSTALL_CONFIGURATION)
+ set(INSTALL_CONFIGURATION "share" CACHE STRING "path to install garbd configuration to")
+ endif()
+
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/files/garb.cnf
+ DESTINATION ${INSTALL_CONFIGURATION}
+ RENAME garb)
+
+ # Make the install destination for garbd systemd service file configurable
+ if(NOT DEFINED INSTALL_SYSTEMD_SERVICE)
+ set(INSTALL_SYSTEMD_SERVICE "share" CACHE STRING "path to install garbd Systemd service to")
+ endif()
+
+ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/files/garb.service
- ${CMAKE_CURRENT_SOURCE_DIR}/files/garb-systemd
- DESTINATION share)
+ DESTINATION ${INSTALL_SYSTEMD_SERVICE})
+
+ # Make the install destination for manpage configurable
+ if(NOT DEFINED INSTALL_MANPAGE)
+ set(INSTALL_MANPAGE "man/man8" CACHE STRING "path to install manpage to")
+ endif()
+
install(FILES
${CMAKE_SOURCE_DIR}/man/garbd.8
- DESTINATION man/man8)
+ DESTINATION ${INSTALL_MANPAGE})
+
endif()
5) Shared library path
--- galera-26.4.8/galera/src/CMakeLists.txt 2021-06-10 03:13:05.465005845 +0200
+++ galera-26.4.8/galera/src/CMakeLists.txt_patched 2021-06-10 03:16:53.388699046 +0200
@@ -112,7 +112,12 @@ endif()
target_link_libraries(galera_smm galera ${GALERA_LINK_OPTIONS})
-install(TARGETS galera_smm DESTINATION lib)
+# Make the install destination for garbd binary configurable
+if(NOT DEFINED INSTALL_LIBDIR)
+ set(INSTALL_LIBDIR "lib" CACHE STRING "path to install shared libraries to")
+endif()
+
+install(TARGETS galera_smm DESTINATION ${INSTALL_LIBDIR})
# The following checks are guaranteed to work only
# Linux platform, we skip them on others.

View File

@ -1,17 +0,0 @@
Upstream PR:
https://github.com/codership/galera/pull/512
diff -up galera-25.3.23/SConstruct.bak galera-25.3.23/SConstruct
--- galera-25.3.23/SConstruct.bak 2018-07-13 15:14:49.059835554 +0200
+++ galera-25.3.23/SConstruct 2018-07-13 15:19:07.717967794 +0200
@@ -194,8 +194,8 @@ if link != 'default':
env.Replace(LINK = link)
# Get compiler name/version, CXX may be set to "c++" which may be clang or gcc
-cc_version = str(read_first_line(env['CC'].split() + ['--version']))
-cxx_version = str(read_first_line(env['CXX'].split() + ['--version']))
+cc_version = str(read_first_line(env['CC'].split() + ['--version']).decode())
+cxx_version = str(read_first_line(env['CXX'].split() + ['--version']).decode())
print('Using C compiler executable: ' + env['CC'])
print('C compiler version is: ' + cc_version)

View File

@ -15,9 +15,9 @@ Source0: http://releases.galeracluster.com/source/%{name}-%{version}.tar.
Source1: garbd.service
Source2: garbd-wrapper
Patch0: galera-python3.patch
Patch0: cmake_paths.patch
BuildRequires: boost-devel check-devel openssl-devel python3-scons systemd gcc-c++ asio-devel
BuildRequires: boost-devel check-devel openssl-devel cmake systemd gcc-c++ asio-devel
Requires: nmap-ncat
%{?systemd_requires}
@ -45,36 +45,29 @@ sed -i '/^GALERA_VER/s/API + //' wsrep/tests/SConscript
%build
%{set_build_flags}
# Print help:
# scons-3 --help
# scons-3 -H
# Possibly usefull arguments:
# --debug=findlibs
# --debug=stacktrace
# --warn=all
# debug=0
%cmake . \
-DCMAKE_BUILD_TYPE="%{?with_debug:Debug}%{!?with_debug:RelWithDebInfo}" \
-DINSTALL_LAYOUT=RPM \
-DCMAKE_RULE_MESSAGES:BOOL=OFF \
\
-DBUILD_SHARED_LIBS:BOOL=OFF \
\
-DINSTALL_DOCDIR="share/doc/%{name}/" \
-DINSTALL_GARBD="sbin" \
-DINSTALL_GARBD-SYSTEMD="sbin" \
-DINSTALL_CONFIGURATION="/etc/sysconfig/" \
-DINSTALL_SYSTEMD_SERVICE="lib/systemd/system" \
-DINSTALL_LIBDIR="%{_lib}/galera" \
-DINSTALL_MANPAGE="share/man/man8"
# Workaround for version 26.4.7
export CXXFLAGS="$CXXFLAGS -Wno-error=format-extra-args"
# ... and for 32 bit arches
export CXXFLAGS="$CXXFLAGS -Wno-error=format"
export CFLAGS="$CFLAGS -Wno-error=format-extra-args -Wno-error=format"
# end of workaroound
cmake -B %_vpath_builddir -LAH
scons-3 %{?_smp_mflags} strict_build_flags=1
%cmake_build
%install
install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/garbd.service
install -D -m 755 %{SOURCE2} %{buildroot}%{_sbindir}/garbd-wrapper
install -D -m 755 garb/garbd %{buildroot}%{_sbindir}/garbd
install -D -m 755 libgalera_smm.so %{buildroot}%{_libdir}/galera/libgalera_smm.so
install -D -m 644 garb/files/garb.cnf %{buildroot}%{_sysconfdir}/sysconfig/garb
install -D -m 644 COPYING %{buildroot}%{_docdir}/galera/COPYING
install -D -m 644 asio/LICENSE_1_0.txt %{buildroot}%{_docdir}/galera/LICENSE.asio
install -D -m 644 scripts/packages/README %{buildroot}%{_docdir}/galera/README
install -D -m 644 scripts/packages/README-MySQL %{buildroot}%{_docdir}/galera/README-MySQL
%cmake_install
%post
@ -91,16 +84,26 @@ install -D -m 644 scripts/packages/README-MySQL %{buildroot}%{_docdir}/galera/RE
%files
%config(noreplace,missingok) %{_sysconfdir}/sysconfig/garb
%dir %{_docdir}/galera
%dir %{_libdir}/galera
%{_sbindir}/garbd
%{_sbindir}/garbd-wrapper
%{_unitdir}/garbd.service
#%{_sbindir}/garbd-wrapper
%{_sbindir}/garb-systemd
%{_mandir}/man8/garbd.8*
#%{_unitdir}/garbd.service
%{_unitdir}/garb.service
%{_libdir}/galera/libgalera_smm.so
%doc %{_docdir}/galera/AUTHORS
%doc %{_docdir}/galera/COPYING
%doc %{_docdir}/galera/LICENSE.asio
%doc %{_docdir}/galera/README
%doc %{_docdir}/galera/README-MySQL
#%doc %{_docdir}/galera/README-MySQL
%changelog