Skip to content

Commit 47cae63

Browse files
committed
WL#16458: JDBC: Bundle authentication plugins in connector packages
1 parent a644094 commit 47cae63

File tree

10 files changed

+73
-25
lines changed

10 files changed

+73
-25
lines changed

jdbc/cmake/DepFindMySQL.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,18 @@ function(use_mysql_config)
492492

493493
_mysql_conf(MYSQL_INCLUDE_DIR --variable=pkgincludedir)
494494
_mysql_conf(MYSQL_LIB_DIR --variable=pkglibdir)
495-
_mysql_conf(MYSQL_PLUGIN_DIR --variable=plugindir)
496495

497496
file(TO_CMAKE_PATH "${MYSQL_INCLUDE_DIR}" MYSQL_INCLUDE_DIR)
498497
file(TO_CMAKE_PATH "${MYSQL_LIB_DIR}" MYSQL_LIB_DIR)
499-
file(TO_CMAKE_PATH "${MYSQL_PLUGIN_DIR}" MYSQL_PLUGIN_DIR)
500498

501499
set(MYSQL_INCLUDE_DIR "${MYSQL_INCLUDE_DIR}" PARENT_SCOPE)
502500
set(MYSQL_LIB_DIR "${MYSQL_LIB_DIR}" PARENT_SCOPE)
503-
set(MYSQL_PLUGIN_DIR "${MYSQL_PLUGIN_DIR}" PARENT_SCOPE)
501+
502+
if(NOT MYSQL_PLUGIN_DIR)
503+
_mysql_conf(MYSQL_PLUGIN_DIR --variable=plugindir)
504+
file(TO_CMAKE_PATH "${MYSQL_PLUGIN_DIR}" MYSQL_PLUGIN_DIR)
505+
set(MYSQL_PLUGIN_DIR "${MYSQL_PLUGIN_DIR}" PARENT_SCOPE)
506+
endif()
504507

505508
# client library version (note: it will be cleaned up in get_version())
506509

jdbc/driver/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ IF(WIN32)
193193
ENDIF(WIN32)
194194

195195

196+
if(DEFINED DEFAULT_PLUGIN_DIR)
197+
add_compile_definitions(DEFAULT_PLUGIN_DIR="${DEFAULT_PLUGIN_DIR}")
198+
endif()
199+
200+
196201
#-----------------
197202

198203
add_library(jdbc STATIC ${MYSQLCPPCONN_SOURCES})

jdbc/driver/mysql_connection.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999
bool oci_plugin_is_loaded = false;
100100

101101

102+
#ifdef DEFAULT_PLUGIN_DIR
103+
std::string default_plugin_dir(DEFAULT_PLUGIN_DIR);
104+
#else
105+
std::string default_plugin_dir;
106+
#endif
107+
108+
102109
namespace sql
103110
{
104111
namespace mysql
@@ -783,21 +790,10 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
783790
throw sql::InvalidArgumentException("Wrong type passed for pluginDir expected sql::SQLString");
784791
}
785792
}
786-
#if(_WIN32 && CONCPP_BUILD_SHARED)
787-
else {
788-
/*
789-
Note: For DLL in Windows we will try to set the plugin directory
790-
based on driver_dll_path.
791-
*/
792-
plugin_dir = driver_dll_path;
793-
#ifdef _DEBUG
794-
// Debug dll is placed inside debug subdirectory
795-
plugin_dir.append("..\\");
796-
#endif
797-
plugin_dir.append("plugin");
793+
else if(!default_plugin_dir.empty()) {
794+
plugin_dir = default_plugin_dir;
798795
p_s = &plugin_dir;
799796
}
800-
#endif
801797

802798
if (p_s) {
803799
proxy->options(sql::mysql::MYSQL_PLUGIN_DIR, *p_s);

jdbc/driver/mysql_connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#if(_WIN32 && CONCPP_BUILD_SHARED)
4040
extern std::string driver_dll_path;
4141
#endif
42+
extern std::string default_plugin_dir;
4243

4344
namespace sql
4445
{

jdbc/driver/mysql_driver.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,19 @@ BOOL WINAPI DllMain(
271271
GetModuleFileNameA(hmodule, _driver_dll_path, sizeof(_driver_dll_path));
272272
driver_dll_path = _driver_dll_path;
273273
driver_dll_path = driver_dll_path.substr(0, driver_dll_path.find_last_of('\\') + 1);
274+
275+
/*
276+
Note: For DLL in Windows we will try to set the plugin directory
277+
based on driver_dll_path.
278+
*/
279+
280+
default_plugin_dir = driver_dll_path;
281+
#ifdef _DEBUG
282+
// Debug dll is placed inside debug subdirectory
283+
default_plugin_dir.append("..\\");
284+
#endif
285+
default_plugin_dir.append("plugin");
286+
274287
return true;
275288
}
276289
#endif

packaging/deb-in/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,12 @@ IF (DEB_PRODUCT STREQUAL "commercial")
100100
SET (DEB_LICENSENAME "Commercial")
101101
SET (DEB_VERSION "+commercial-1")
102102
SET (DEB_SERVERPRODUCT "commercial")
103-
SET (JDBC_RECOMMENDS_AND_SUGGESTS "Recommends: mysql-commercial-client-plugins")
104103
ELSE()
105104
SET (DEB_COPYRIGHT_UPSTREAMNAME "MySQL ${MYSQL_BASE_VERSION}")
106105
SET (DEB_PRODUCTNAME "")
107106
SET (DEB_LICENSENAME "GPL")
108107
SET (DEB_VERSION "-1")
109108
SET (DEB_SERVERPRODUCT "community")
110-
SET (JDBC_RECOMMENDS_AND_SUGGESTS "Suggests: mysql-community-client-plugins")
111109
ENDIF()
112110

113111
# All files are configured and copied to the debian/ directory, which is used
@@ -148,4 +146,3 @@ endforeach()
148146
EXECUTE_PROCESS(
149147
COMMAND chmod +x ${CMAKE_BINARY_DIR}/debian/rules
150148
)
151-

packaging/deb-in/control.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Section: database
44
Priority: optional
55
Standards-Version: 3.9.8
66
Homepage: https://dev.mysql.com/doc/connector-cpp/en/
7-
Build-Depends: cmake, debhelper (>= 10), libboost-dev, libmysqlclient-dev, libssl-dev
7+
Build-Depends: cmake, debhelper (>= 10), libboost-dev, libmysqlclient-dev, libssl-dev, chrpath
88

99
Package: libmysqlcppconnx@ABI_VERSION_MAJOR@
1010
Architecture: any
@@ -22,7 +22,7 @@ Section: libs
2222
Pre-Depends: ${misc:Pre-Depends}
2323
Multi-Arch: same
2424
Depends: ${shlibs:Depends}, ${misc:Depends}
25-
@JDBC_RECOMMENDS_AND_SUGGESTS@
25+
Suggests: libkrb5-3, libsasl2-2, libgssapi-krb5-2, libfido2-1, libssl3
2626
Description: MySQL Driver for C++ which mimics the JDBC 4.0 API
2727
This MySQL Driver for C++ mimics the JDBC 4.0 API.
2828

packaging/deb-in/jdbc.install.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
usr/lib/*/libmysqlcppconn.so.@JDBC_ABI_VERSION_MAJOR@*
2525

26+
# Plugins
27+
usr/lib/*/mysql/libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@/plugin/
28+
2629
# Build info
2730
/usr/INFO_SRC /usr/share/doc/@PACKAGE_BASE_NAME@
2831
/usr/INFO_BIN /usr/share/doc/@PACKAGE_BASE_NAME@

packaging/deb-in/rules.in

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export CFLAGS=
3131
export CXXFLAGS=
3232

3333
export LIB_DIR = /usr/lib/$(DEB_HOST_MULTIARCH)
34+
export PLUGIN_DIR = $(LIB_DIR)/mysql/libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@/plugin
3435

3536
export CMAKE_OPTS= \
3637
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
@@ -39,7 +40,9 @@ export CMAKE_OPTS= \
3940
-DINSTALL_DOC_DIR=./usr \
4041
-DWITH_JDBC=ON \
4142
-DMYSQLCLIENT_STATIC_LINKING=ON \
43+
-DDEFAULT_PLUGIN_DIR=$(PLUGIN_DIR) \
4244
-DWITH_SSL=system \
45+
-DBUNDLE_DEPENDENCIES=ON \
4346
@DEB_CMAKE_EXTRAS@
4447

4548
override_dh_auto_configure:
@@ -84,11 +87,23 @@ override_dh_auto_install:
8487
rm debian/tmp/mysql-concpp-config.cmake
8588
rm debian/tmp/mysql-concpp-config-version.cmake
8689

87-
touch $@
90+
install -d -m 0755 debian/tmp/.$(PLUGIN_DIR)
91+
mv -v debian/tmp/.$(LIB_DIR)/plugin/* debian/tmp/.$(PLUGIN_DIR)/
92+
# Note: Remove custom RPATH in plugins -- we want them to use OS-wide dependencies
93+
chrpath --delete debian/tmp/.$(PLUGIN_DIR)/*
94+
rm -rf debian/tmp/.$(LIB_DIR)/plugin
95+
rm -rf debian/tmp/.$(LIB_DIR)/private
96+
# touch $@
8897

8998
override_dh_installinit:
9099
@echo "RULES.$@"
91100
touch $@
92101

93102
override_dh_install:
94103
dh_install --fail-missing
104+
105+
106+
# Note: Exclude plugins from calculating package dependencies
107+
108+
override_dh_shlibdeps:
109+
dh_shlibdeps -Xmysql_native_password -Xauthentication_

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757

5858
%global source_date_epoch_from_changelog 0
5959

60+
%global lib_base_name libmysqlcppconnx@ABI_VERSION_MAJOR@
61+
%global lib_base_name_jdbc libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@
62+
6063
###############################################
6164
# Package specifications
6265
###############################################
@@ -90,8 +93,9 @@ A C++ interface for communicating with MySQL servers.
9093

9194
%package jdbc
9295
Summary: MySQL Driver for C++ which mimics the JDBC 4.0 API
93-
Provides: libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@ = %{version}-%{release}
94-
Obsoletes: libmysqlcppconn@JDBC_ABI_VERSION_MAJOR@ < %{version}-%{release}
96+
Provides: %{lib_base_name_jdbc} = %{version}-%{release}
97+
Suggests: krb5-libs, cyrus-sasl-lib, libfido2
98+
Obsoletes: %{lib_base_name_jdbc} < %{version}-%{release}
9599
Obsoletes: mysql-connector-c++%{?product_suffix}-jdbc < %{version}-%{release}
96100
Obsoletes: mysql-connector-c++-jdbc < %{version}-%{release}
97101
%description jdbc
@@ -121,6 +125,8 @@ to develop MySQL client applications in C++.
121125
SRC=`pwd`
122126
cd ${RPM_BUILD_DIR}
123127

128+
%global plugin_dir %{_libdir}/mysql/%{lib_base_name_jdbc}/plugin
129+
124130
%{?gcc_toolset:source /opt/rh/%{gcc_toolset}/enable}
125131

126132
%if 0%{?with_tests:1} && 0%{?with_gtest:1}
@@ -133,7 +139,7 @@ cd ${RPM_BUILD_DIR}
133139
# Note: use relative paths for CMAKE_INSTALL_XXX options
134140

135141
%global __cmake_cmd cmake%{?el6:3}%{?el7:3}
136-
%global __cmake_common_opts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=.%{_libdir} -DCMAKE_INSTALL_INCLUDEDIR=.%{_includedir}/mysql-cppconn -DWITH_SSL=system -DWITH_JDBC=1 -DMYSQLCLIENT_STATIC_LINKING=1 %{?mysql_opt} %{__cmake_test_opts} -DDEBUG_PREFIX_MAP=OFF
142+
%global __cmake_common_opts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=.%{_libdir} -DCMAKE_INSTALL_INCLUDEDIR=.%{_includedir}/mysql-cppconn -DWITH_SSL=system -DDEFAULT_PLUGIN_DIR=%{plugin_dir} -DWITH_JDBC=1 -DMYSQLCLIENT_STATIC_LINKING=1 -DBUNDLE_DEPENDENCIES=1 %{?mysql_opt} %{__cmake_test_opts} -DDEBUG_PREFIX_MAP=OFF
137143
%global __cmake_config %{__cmake_cmd} %{__cmake_common_opts} %{__cmake_explicit_opts}
138144

139145
rm -rf build-static && mkdir build-static
@@ -165,6 +171,11 @@ mkdir -p %{buildroot}%{_libdir}/cmake/mysql-concpp/
165171
install -D -m 0644 %{buildroot}/*.cmake %{buildroot}%{_libdir}/cmake/mysql-concpp/
166172
rm %{buildroot}/*.cmake
167173

174+
# Bundled plugins
175+
mkdir -p %{buildroot}%{plugin_dir}
176+
mv -v %{buildroot}%{_libdir}/plugin/* %{buildroot}%{plugin_dir}
177+
rm -rf %{buildroot}%{_libdir}/{plugin,private}
178+
168179

169180
%post -p /sbin/ldconfig
170181

@@ -193,6 +204,7 @@ rm %{buildroot}/*.cmake
193204
%doc LICENSE.txt
194205
%doc README.txt ../build-dynamic/INFO_SRC ../build-dynamic/INFO_BIN
195206
%{_libdir}/libmysqlcppconn.so.@JDBC_ABI_VERSION_MAJOR@*
207+
%{plugin_dir}
196208

197209
%files devel
198210
%doc LICENSE.txt
@@ -213,6 +225,9 @@ rm %{buildroot}/*.cmake
213225

214226
%changelog
215227

228+
* Fri Aug 09 2024 Rafal Somla <[email protected]> - 9.1.0-1
229+
- Bundle authentication plugins in the -jdbc package (WL#16458)
230+
216231
* Thu Jul 11 2024 Rafal Somla <[email protected]> - 9.1.0-1
217232
- Fixed provides/obsoletes information
218233
- Updates to configure/build/install logic

0 commit comments

Comments
 (0)