Skip to content

Commit 17029c0

Browse files
committed
packaging: Add 'Suggests' info in RPM package spec only if it is supported
1 parent d2ad117 commit 17029c0

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

packaging/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,41 @@ include(PackageSpecs.cmake)
5050

5151
add_subdirectory(deb-in)
5252

53+
# RPM stuff
54+
55+
find_program(RPM rpm)
56+
57+
if(RPM)
58+
59+
# Get RPM version
60+
61+
execute_process(COMMAND ${RPM} "--version"
62+
RESULT_VARIABLE res
63+
OUTPUT_VARIABLE RPM_VERSION
64+
OUTPUT_STRIP_TRAILING_WHITESPACE
65+
)
66+
67+
if(res)
68+
message(FATAL_ERROR "Could not determine RPM version (${RPM} --version command failed)")
69+
endif()
70+
71+
# Set RPM_VER_NUM to version number in XYYZZ format
72+
73+
string(REGEX REPLACE "^RPM version *" "" RPM_VERSION ${RPM_VERSION})
74+
string(REPLACE "." ";" ver ${RPM_VERSION})
75+
list(GET ver 0 ver_major)
76+
list(GET ver 1 ver_minor)
77+
list(GET ver 2 ver_patch)
78+
string(REGEX MATCH "..$" ver_minor "0${ver_minor}")
79+
string(REGEX MATCH "..$" ver_patch "0${ver_patch}")
80+
set(RPM_VER_NUM "${ver_major}${ver_minor}${ver_patch}")
81+
82+
message(STATUS "Using RPM tools version: ${RPM_VERSION} (${RPM_VER_NUM})")
83+
84+
endif()
85+
86+
87+
# Gnerate RPM specification
5388

5489
if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
5590
set(rpm_spec "${CMAKE_CURRENT_BINARY_DIR}/SPECS/mysql-connector-c++.spec")

packaging/mysql-connector-c++.spec.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
%global lib_base_name libmysqlcppconnx@ABI_VERSION_MAJOR@
6464
%global lib_base_name_jdbc libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@
6565

66+
# TODO: use %rpmversion if available, note that it is in the format X.Y.Z.Y
67+
# and the current logic requires numeric format XYYZZ.
68+
69+
%global rpm_ver_num @RPM_VER_NUM@
70+
71+
6672
###############################################
6773
# Package specifications
6874
###############################################
@@ -97,7 +103,10 @@ A C++ interface for communicating with MySQL servers.
97103
%package jdbc
98104
Summary: MySQL Driver for C++ which mimics the JDBC 4.0 API
99105
Provides: %{lib_base_name_jdbc} = %{version}-%{release}
106+
# Note: Field `Suggests` is recognized by RPM 4.13 and later
107+
%if %{rpm_ver_num} >= 41300
100108
Suggests: krb5-libs, cyrus-sasl-lib, libfido2
109+
%endif
101110
Obsoletes: %{lib_base_name_jdbc} < %{version}-%{release}
102111
Obsoletes: mysql-connector-c++%{?product_suffix}-jdbc < %{version}-%{release}
103112
Obsoletes: mysql-connector-c++-jdbc < %{version}-%{release}

0 commit comments

Comments
 (0)