#
# spec file for package mariadb-connector-odbc
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           mariadb-connector-odbc
Version:        3.1.10
Release:        1.5
Summary:        MariaDB ODBC Connector
License:        LGPL-2.1-or-later
Group:          Productivity/Databases/Tools
URL:            https://downloads.mariadb.org/connector-odbc/
Source:         https://downloads.mariadb.org/interstitial/connector-odbc-%{version}/mariadb-connector-odbc-%{version}-ga-src.tar.gz
# signature is from copy/pasted stuff found on the download page, not actual file
# Source1:        mariadb-connector-odbc-%{version}-ga-src.tar.gz.asc
Source2:        README
Source3:        sample_odbc.ini
Source4:        mariadb-connector-odbc-rpmlintrc
Patch1:         mysql_header_path.patch
Patch6:         DSN_names.patch
Patch8:         nosoname.patch
Patch9:         iconv.patch
BuildRequires:  cmake > 3.5.0
BuildRequires:  gcc-c++
# This is actually MariaDB -devel package(s)
BuildRequires:  libmariadb-devel >= 3.1.11
BuildRequires:  libmariadbprivate >= 3.1.11
BuildRequires:  openssl-devel
BuildRequires:  sed
BuildRequires:  unixODBC-devel
Obsoletes:      MyODBC-unixODBC <= 5.1.9

%description
This package contains the MariaDB ODBC Connector to be used with unixODBC.

%prep
%autosetup -p1 -n mariadb-connector-odbc-%{version}-ga-src

%build
%cmake \
  -DWITH_UNIXODBC=1 \
  -DWITH_OPENSSL=ON \
  -DMARIADB_LINK_DYNAMIC=1 \
  -DINSTALL_DOCDIR=%{_docdir}/%{name} \
  -DINSTALL_LAYOUT=RPM \
  -DINSTALL_LICENSEDIR=%{_licensedir}/%{name}
%cmake_build

%install
%cmake_install
install -Dpm 0644 -t %{buildroot}%{_docdir}/%{name} %{SOURCE2} %{SOURCE3}
sed -i 's#^Driver.*$#Driver = %{_libdir}/mariadb/libmaodbc.so#' %{buildroot}%{_docdir}/%{name}/sample_odbc.ini

%post   -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%dir %{_docdir}/%{name}
%dir %{_libdir}/mariadb
%license COPYING
%{_libdir}/mariadb/libmaodbc.so
%{_docdir}/%{name}/README
%{_docdir}/%{name}/sample_odbc.ini

%changelog
* Thu Nov  5 2020 Adam Majer <adam.majer@suse.de>
- New upstream version 3.1.10
  * ODBC-288 - Connector misses "interactive client" option. Added
    INTERACTIVE connection string option to tell server, that
    the client application is interactive, and interactive_timeout
    has to be used.
  * ODBC-202 - Add charsets recoding function to C/ODBC. Iconv-based
    conversion function has been moved and adapted from MariaDB Connector/C.
  * ODBC-289 - Fixes a crash fetching from statement after closing and re-executing
- remove upstreamed patches: fix_macros.patch,
  implicit_decleration.patch, wrong_types.patch
- iconv.patch: compilation fixes
* Thu Nov  5 2020 Fabian Vogt <fvogt@suse.com>
- Fix Driver in sample_odbc.ini
* Fri Sep 11 2020 Adam Majer <adam.majer@suse.de>
  * * LOCATION CHANGE ** - the ODBC driver location has been changed to
  /usr/lib{,64}/mariadb/libmaodbc.so  Adjust your paths accordingly.
- New upstream version 3.1.9. Fixes since 3.1.7 include,
  * ODBC-214 - Mediumint(INT24) is always empty
  * ODBC-284 - properly handle curly bracket escape in connection string
  * ODBC-283 - Add support for passphrase protected private keys (TlsKeyPwd=)
  * ODBC-280 - fixes multi-threaded issue when multiple connection are
    established simultaneously from different threads.
  * ODBC-279 - SQL_C_TIME binding type not working
- missing_libs.patch: dropped
- added patches forwarded upstream: fix_macros.patch, implicit_decleration.patch, wrong_types.patch
- nosoname.patch: refreshed
- DSN_names.patch: refreshed. Added new option,
  TlsKeyPwd =
* Tue Apr 14 2020 Adam Majer <adam.majer@suse.de>
- New upstream version 3.1.7. Fixes include,
  * ODBC-276 - Update of Binary data containing 0x00 does not work
  * ODBC-277 - Memory Corruption from Incorrect Type for SQL_IDENTIFIER_CASE
  * ODBC-274 - Support INSERT/REPLACE ... RETURNING (requires MariaDB 10.5)
* Thu Apr  2 2020 Adam Majer <adam.majer@suse.de>
- New upstream version 3.1.6. Fixes include,
  * ODBC-269: BEGIN NOT ATOMIC returning error
  Fixes since version 3.1.1 includes,
  * ODBC-196 - Optimize ODBC-120 issue for the case of array fetch
  * ODBC-267 - Setup library has some redundant dependencies
  * ODBC-87 - When testing a DSN (new or config datasource)
    the database name is missing after the test
  * ODBC-240 - SSLFP and SSLFPLIST parameters appear unused
  * ODBC-241 - Add parameter that corresponds to
    MYSQL_SERVER_PUBLIC_KEY option from MariaDB Connector/C
  * ODBC-226 - Driver doesn't cause an error when it should
  * ODBC-261 - Connector deploys direct execution, even for
    server versions, that do not support it
  * ODBC-262 - MSI and PKG packages do not contain ed25519 plugin
  * ODBC-210 - Fix compilation warnings on OS X
  * ODBC-250 - Operations with Dynamic Lists are not thread-safe,
    and need to be guarded with mutexes
  * ODBC-252 - Build failed when executed the commands present in
    "BUILD.md" file
  * ODBC-253 - MADB_StmtExecDirect() crashes if StatementText is "\0"
  * ODBC-254 - FTBFS: Cmake libdir misconfiguration
  * ODBC-256 - Driver craches on empty statement
  * ODBC-257 - Double-check CPack for a copy-paste error
  * ODBC-258 - RFE: make documentation and license dirs configurable
  * ODBC-260 - Remove all references to internals of MYSQL structure
  * ODBC-255 - When C/ODBC is upgraded on Windows, allow existing
    data sources to be moved
  * ODBC-211 - SQLDescribeCol return precision=0 for field type decimal(1,0)
- install_correct_path.patch: removed, upstreamed
- package_name.patch: removed, no longer necessary
- DSN_names.patch: refreshed. Added new options
  TlsPeerFp =
  TlsPeerFpList =
  ServerKey =
* Tue May 21 2019 Adam Majer <adam.majer@suse.de>
- New upstream version 3.1.1
  * Added FORCETLS connection string option
  * Added connection string option TLSVERSION
  * Added option for reading section in my.cnf
- Changes in version 3.1.0:
  * The fix and the testcase Wrong Input/Output parameter type when
    mapping SQLBindParam to SQLBindParameter
  * The fix and the testcase SQL_DESC_PARAMETER_TYPE is SQLSMALLINT,
    but if application tried to read it into SQLSMALLINT buffer,
    memory would be corrupted.
- sample_odbc.ini - updated listing new connection options
- refreshed patches: DSN_names.patch, missing_libs.patch, nosoname.patch,
  package_name.patch
- install_correct_path.patch: keep odbc library installed in correct
  patch on 64bit systems
- mysql_header_path.patch - mysql headers are now under mysql/ subdir
- missing_includes.patch - dropped, not needed anymore
* Fri Aug 10 2018 adam.majer@suse.de
- Install license as %%license instead of documentation
* Thu Feb 22 2018 adam.majer@suse.de
- New upsream version 3.0.3 (bsc#1104480, fate#324398)
  * fixes core dump when procedure returned more than 1 result set
  * result SQLStatistics were ordered using the wrong columns.
  * fetch would fail if an unbound column contained NULL
- libreoffice_fixes.patch: upstreamed
* Thu Jan  4 2018 adam.majer@suse.de
- libreoffice_fixes.patch: Fix crash with LibreOffice (bnc#938195)
- add mariadb-connector-odbc-rpmlintrc to ignore some
  rpmlint warnings
* Tue Dec 12 2017 mpluskal@suse.com
- Enable openssl support
- Honor optflags when building
* Tue Dec 12 2017 mvetter@suse.com
- Remove 'Provides', it is not a drop in replacement
  for MyODBC-unixODBC. Users will have to change .so file.
  Obsoletes is enough.
* Mon Dec 11 2017 adam.majer@suse.de
- Provide upgrade path for users of MyODBC-unixODBC
* Sun Nov 19 2017 mpluskal@suse.com
- Use more cmake macros
- Run spec-cleaner
* Fri Nov 17 2017 adam.majer@suse.de
- New upstream version 3.0.2
  * first stable version of MariaDB Connector/ODBC 3.0
  * fixed number of memory leaks
- Refreshed patches:
  * missing_includes.patch
  * package_name.patch
- Removed upstreamed patches:
  * fix_bool_return_types.patch
  * no_static_linking.patch
- missing_libs.patch: Add missing -lpthread dependency
- nosoname.patch: libmaodbc.so is an ODBC driver, not a normal
  library. Remove soname generation.
* Thu Jul 13 2017 adam.majer@suse.de
- New upstream version 2.0.15:
  * fix crash in ODBC Driver SQLExecDirect()
  * fix batch query with non-preparable statement crashed
  * fix backslash at the end of string in one of statements in
    multistatement query leads to error
- Changes in version 2.0.14:
  * SQLGetData now correctly handles UTF-16 surrogate pairs
  * Execution of 'ANALYZE TABLE' statement used to invalidate
    statement and connection handles
  * SQLGetData would not return SQL_NO_DATA for BLOB/TEXT columns
    if the buffer size is larger than the column data
  * Min and Max value for time data type were processed incorrectly
  * fixed Error in the SQLGetTypeInfo for WCHAR Types
  * SQLBulkOperations/SQLSetPos SQL_ADD would fail if TIMESTAMP
    column ignored
* Wed Mar 29 2017 adam.majer@suse.de
- Add sample_odbc.ini file to documentation directory.
* Thu Mar 23 2017 adam.majer@suse.de
- Initial package of MariaDB Connector/ODBC 2.0.13
- fix_bool_return_types.patch: use only supported data types
- missing_includes.patch: missing headers added
- no_static_linking.patch: dynamically link with the private
  symbols library.
- package_name.patch: set package name to SUSE package name
  so we don't have to move files around after install or change
  library names.