diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..267417d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/2.7.1.tar.gz diff --git a/.rh-mariadb105-mariadb-java-client.metadata b/.rh-mariadb105-mariadb-java-client.metadata new file mode 100644 index 0000000..19a6f8c --- /dev/null +++ b/.rh-mariadb105-mariadb-java-client.metadata @@ -0,0 +1 @@ +a838d52134182704d3665488278f98104cef4b42 SOURCES/2.7.1.tar.gz diff --git a/SOURCES/artifact-jna.xml b/SOURCES/artifact-jna.xml new file mode 100644 index 0000000..31170d2 --- /dev/null +++ b/SOURCES/artifact-jna.xml @@ -0,0 +1,19 @@ + + + + + net.java.dev.jna + jna + jar + 3.5.2 + /usr/share/java/jna.jar + + + net.java.dev.jna + jna-platform + jar + 3.5.2 + /usr/share/java/jna/platform.jar + + + diff --git a/SOURCES/remove-NamedPipeSocket.patch b/SOURCES/remove-NamedPipeSocket.patch new file mode 100644 index 0000000..c29e44a --- /dev/null +++ b/SOURCES/remove-NamedPipeSocket.patch @@ -0,0 +1,245 @@ +commit 97f2dbbc341c09496c3823604cc73c5d70e42084 +Author: Jakub Janco +Date: Tue Dec 18 17:43:18 2018 +0100 + + remove NamedPipeSocket + +diff --git a/src/main/java/org/mariadb/jdbc/internal/io/socket/NamedPipeSocket.java b/src/main/java/org/mariadb/jdbc/internal/io/socket/NamedPipeSocket.java +deleted file mode 100644 +index 562bceed..00000000 +--- a/src/main/java/org/mariadb/jdbc/internal/io/socket/NamedPipeSocket.java ++++ /dev/null +@@ -1,218 +0,0 @@ +-/* +- * +- * MariaDB Client for Java +- * +- * Copyright (c) 2012-2014 Monty Program Ab. +- * Copyright (c) 2015-2017 MariaDB Ab. +- * +- * This library is free software; you can redistribute it and/or modify it under +- * the terms of the GNU Lesser General Public License as published by the Free +- * Software Foundation; either version 2.1 of the License, or (at your option) +- * any later version. +- * +- * This library is distributed in the hope that it will be useful, but +- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License +- * for more details. +- * +- * You should have received a copy of the GNU Lesser General Public License along +- * with this library; if not, write to Monty Program Ab info@montyprogram.com. +- * +- * This particular MariaDB Client for Java file is work +- * derived from a Drizzle-JDBC. Drizzle-JDBC file which is covered by subject to +- * the following copyright and notice provisions: +- * +- * Copyright (c) 2009-2011, Marcus Eriksson +- * +- * Redistribution and use in source and binary forms, with or without modification, +- * are permitted provided that the following conditions are met: +- * Redistributions of source code must retain the above copyright notice, this list +- * of conditions and the following disclaimer. +- * +- * Redistributions in binary form must reproduce the above copyright notice, this +- * list of conditions and the following disclaimer in the documentation and/or +- * other materials provided with the distribution. +- * +- * Neither the name of the driver nor the names of its contributors may not be +- * used to endorse or promote products derived from this software without specific +- * prior written permission. +- * +- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +- * OF SUCH DAMAGE. +- * +- */ +- +-package org.mariadb.jdbc.internal.io.socket; +- +-import com.sun.jna.platform.win32.Kernel32; +-import java.io.FileNotFoundException; +-import java.io.IOException; +-import java.io.InputStream; +-import java.io.OutputStream; +-import java.io.RandomAccessFile; +-import java.net.Socket; +-import java.net.SocketAddress; +-import java.util.concurrent.TimeUnit; +- +-@SuppressWarnings("UnnecessaryInitCause") +-public class NamedPipeSocket extends Socket { +- +- private final String host; +- private final String name; +- +- private RandomAccessFile file; +- private InputStream is; +- private OutputStream os; +- +- public NamedPipeSocket(String host, String name) { +- this.host = host; +- this.name = name; +- } +- +- @Override +- public void close() throws IOException { +- if (file != null) { +- file.close(); +- file = null; +- } +- } +- +- @Override +- public void connect(SocketAddress endpoint) throws IOException { +- connect(endpoint, 0); +- } +- +- /** +- * Name pipe connection. +- * +- * @param endpoint endPoint +- * @param timeout timeout in milliseconds +- * @throws IOException exception +- */ +- public void connect(SocketAddress endpoint, int timeout) throws IOException { +- String filename; +- if (host == null || host.equals("localhost")) { +- filename = "\\\\.\\pipe\\" + name; +- } else { +- filename = "\\\\" + host + "\\pipe\\" + name; +- } +- +- //use a default timeout of 100ms if no timeout set. +- int usedTimeout = timeout == 0 ? 100 : timeout; +- long initialNano = System.nanoTime(); +- do { +- try { +- file = new RandomAccessFile(filename, "rw"); +- break; +- } catch (FileNotFoundException fileNotFoundException) { +- try { +- //using JNA if available +- Kernel32.INSTANCE.WaitNamedPipe(filename, timeout); +- //then retry connection +- file = new RandomAccessFile(filename, "rw"); +- } catch (Throwable cle) { +- // in case JNA not on classpath, then wait 10ms before next try. +- if (System.nanoTime() - initialNano > TimeUnit.MILLISECONDS.toNanos(usedTimeout)) { +- if (timeout == 0) { +- throw new FileNotFoundException(fileNotFoundException.getMessage() +- + "\nplease consider set connectTimeout option, so connection can retry having access to named pipe. " +- + "\n(Named pipe can throw ERROR_PIPE_BUSY error)"); +- } +- throw fileNotFoundException; +- } +- try { +- TimeUnit.MILLISECONDS.sleep(5); +- } catch (InterruptedException interrupted) { +- IOException ioException = new IOException( +- "Interruption during connection to named pipe"); +- ioException.initCause(interrupted); +- throw ioException; +- } +- } +- } +- } while (true); +- +- is = new InputStream() { +- @Override +- public int read(byte[] bytes, int off, int len) throws IOException { +- return file.read(bytes, off, len); +- } +- +- @Override +- public int read() throws IOException { +- return file.read(); +- } +- +- @Override +- public int read(byte[] bytes) throws IOException { +- return file.read(bytes); +- } +- }; +- +- os = new OutputStream() { +- @Override +- public void write(byte[] bytes, int off, int len) throws IOException { +- file.write(bytes, off, len); +- } +- +- @Override +- public void write(int value) throws IOException { +- file.write(value); +- } +- +- @Override +- public void write(byte[] bytes) throws IOException { +- file.write(bytes); +- } +- }; +- } +- +- public InputStream getInputStream() { +- return is; +- } +- +- public OutputStream getOutputStream() { +- return os; +- } +- +- public void setTcpNoDelay(boolean bool) { +- //do nothing +- } +- +- public void setKeepAlive(boolean bool) { +- //do nothing +- } +- +- public void setReceiveBufferSize(int size) { +- //do nothing +- } +- +- public void setSendBufferSize(int size) { +- //do nothing +- } +- +- public void setSoLinger(boolean bool, int value) { +- //do nothing +- } +- +- @Override +- public void setSoTimeout(int timeout) { +- //do nothing +- } +- +- public void shutdownInput() { +- //do nothing +- } +- +- public void shutdownOutput() { +- //do nothing +- } +-} +diff --git a/src/main/java/org/mariadb/jdbc/internal/io/socket/SocketUtility.java b/src/main/java/org/mariadb/jdbc/internal/io/socket/SocketUtility.java +index 8a024af9..1b8b498d 100644 +--- a/src/main/java/org/mariadb/jdbc/internal/io/socket/SocketUtility.java ++++ b/src/main/java/org/mariadb/jdbc/internal/io/socket/SocketUtility.java +@@ -19,9 +19,7 @@ public class SocketUtility { + Platform.getOSType(); + + return (urlParser, host) -> { +- if (urlParser.getOptions().pipe != null) { +- return new NamedPipeSocket(host, urlParser.getOptions().pipe); +- } else if (urlParser.getOptions().localSocket != null) { ++ if (urlParser.getOptions().localSocket != null) { + try { + return new UnixDomainSocket(urlParser.getOptions().localSocket); + } catch (RuntimeException re) { diff --git a/SOURCES/remove_waffle-jna.patch b/SOURCES/remove_waffle-jna.patch new file mode 100644 index 0000000..625e979 --- /dev/null +++ b/SOURCES/remove_waffle-jna.patch @@ -0,0 +1,31 @@ +diff -up mariadb-connector-j-2.7.1/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java.patch0 mariadb-connector-j-2.7.1/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java +--- mariadb-connector-j-2.7.1/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java.patch0 2020-12-10 21:04:22.902932157 +0100 ++++ mariadb-connector-j-2.7.1/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java 2020-12-10 21:06:46.303703168 +0100 +@@ -57,26 +57,11 @@ import com.sun.jna.Platform; + public class GssUtility { + + /** +- * Get authentication method according to classpath. Windows native authentication is using +- * Waffle-jna. ++ * Get authentication method according to classpath. + * + * @return authentication method + */ + public static GssapiAuth getAuthenticationMethod() { +- try { +- // Waffle-jna has jna as dependency, so if not available on classpath, just use standard +- // authentication +- if (Platform.isWindows()) { +- try { +- Class.forName("waffle.windows.auth.impl.WindowsAuthProviderImpl"); +- return new WindowsNativeSspiAuthentication(); +- } catch (ClassNotFoundException cle) { +- // waffle not in the classpath +- } +- } +- } catch (Throwable cle) { +- // jna jar's are not in classpath +- } + return new StandardGssapiAuthentication(); + } + } diff --git a/SPECS/mariadb-java-client.spec b/SPECS/mariadb-java-client.spec new file mode 100644 index 0000000..d365bd3 --- /dev/null +++ b/SPECS/mariadb-java-client.spec @@ -0,0 +1,231 @@ +%{?scl:%scl_package mariadb-java-client} +%{!?scl:%global pkg_name %{name}} + +Name: %{?scl_prefix}mariadb-java-client +Version: 2.7.1 +Release: 1%{?dist} +Summary: Connects applications developed in Java to MariaDB and MySQL databases +# added BSD license because of https://bugzilla.redhat.com/show_bug.cgi?id=1291558#c13 +License: BSD and LGPLv2+ +URL: https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/ +Source0: https://github.com/MariaDB/mariadb-connector-j/archive/%{version}.tar.gz +Source1: artifact-jna.xml + +# optional dependency not in Fedora +Patch0: remove_waffle-jna.patch +Patch1: remove-NamedPipeSocket.patch + +BuildArch: noarch +BuildRequires: %{?scl_prefix_maven}maven-local +BuildRequires: %{?scl_prefix_maven}mvn(com.google.code.maven-replacer-plugin:replacer) +BuildRequires: %{?scl_prefix_maven}mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: %{?scl_prefix_maven}mvn(org.codehaus.mojo:build-helper-maven-plugin) +BuildRequires: %{?scl_prefix_maven}mvn(junit:junit) +BuildRequires: %{?scl_prefix_maven}mvn(org.slf4j:slf4j-api) +BuildRequires: %{?scl_prefix_maven}mvn(org.osgi:osgi.cmpn) +BuildRequires: %{?scl_prefix_maven}mvn(org.osgi:osgi.core) +BuildRequires: %{?scl_prefix}jna +# jna-platform is not found by mvn macro +#BuildRequires: mvn(net.java.dev.jna:jna-platform) +BuildRequires: %{?scl_prefix}jna-contrib +# since version 1.5.2 missing optional dependency (windows) +#BuildRequires: mvn(com.github.dblock.waffle:waffle-jna) + +#Requires: mariadb + +%description +MariaDB Connector/J is a Type 4 JDBC driver, also known as the Direct to +Database Pure Java Driver. It was developed specifically as a lightweight +JDBC connector for use with MySQL and MariaDB database servers. + +%package javadoc +Summary: Javadoc for %{name} + +%description javadoc +This package contains the API documentation for %{name}. + +%prep +%setup -qn mariadb-connector-j-%{version} + +# convert files from dos to unix line encoding +for file in README.md documentation/*.creole; do + sed -i.orig 's|\r||g' $file + touch -r $file.orig $file + rm $file.orig +done + +# remove missing optional dependency waffle-jna +%pom_remove_dep com.github.waffle:waffle-jna +#%pom_remove_dep com.zaxxer:HikariCP +%pom_remove_dep ch.qos.logback:logback-classic +%pom_remove_dep junit:junit +%pom_remove_dep com.amazonaws:aws-java-sdk-rds + +# use latest OSGi implementation +%pom_change_dep -r :org.osgi.core org.osgi:osgi.core +%pom_change_dep -r :org.osgi.compendium org.osgi:osgi.cmpn + +rm -r src/main/java/org/mariadb/jdbc/credential/aws + +sed -i 's|org.osgi.compendium|osgi.cmpn|' pom.xml +# also remove the file using the removed plugin +rm -f src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/WindowsNativeSspiAuthentication.java +# patch the sources so that the missing file is not making trouble +%patch0 -p1 -b .patch0 +# not required since we have sclized recent jna package +#%%patch1 -p1 + +%mvn_file org.mariadb.jdbc:%{name} %{name} +%mvn_alias org.mariadb.jdbc:%{name} mariadb:mariadb-connector-java + +%pom_remove_plugin org.apache.maven.plugins:maven-source-plugin +%pom_remove_plugin org.apache.maven.plugins:maven-javadoc-plugin +%pom_remove_plugin org.sonatype.plugins:nexus-staging-maven-plugin +%pom_remove_plugin org.apache.maven.plugins:maven-gpg-plugin +%pom_remove_plugin org.jacoco:jacoco-maven-plugin +%pom_remove_plugin com.coveo:fmt-maven-plugin + +# remove preconfigured OSGi manifest file and generate OSGi manifest file +# with maven-bundle-plugin instead of using maven-jar-plugin +rm src/main/resources/META-INF/MANIFEST.MF +%pom_xpath_set "pom:packaging" bundle +%pom_xpath_set "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-jar-plugin']/pom:configuration/pom:archive/pom:manifestFile" '${project.build.outputDirectory}/META-INF/MANIFEST.MF' +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-jar-plugin']/pom:configuration/pom:archive/pom:manifestEntries" + +%pom_add_plugin org.apache.felix:maven-bundle-plugin:2.5.4 . ' +true + + + ${project.groupId} + MariaDB JDBC Client + ${project.version}.0 + org.mariadb.jdbc.* + + !com.sun.jna.*, + javax.net;resolution:=optional, + javax.net.ssl;resolution:=optional, + javax.sql;resolution:=optional, + javax.transaction.xa;resolution:=optional + + + + + + bundle-manifest + process-classes + + manifest + + +' +# not required since we have sclized recent jna package +#%%mvn_config resolverSettings/metadataRepositories/repository %{SOURCE1} + +%build +# tests are skipped, while they require running application server +%mvn_build -f + +%install +%mvn_install + +%files -f .mfiles +%doc documentation/* README.md +%license LICENSE + +%files javadoc -f .mfiles-javadoc +%license LICENSE + +%changelog +* Thu Dec 10 2020 Honza Horak - 2.7.1-1 +- Rebase to 2.7.1 + +* Tue May 21 2019 Jakub Janco - 2.4.1-2 +- Rebuild against java fixed meta pkg + +* Fri Apr 05 2019 Jakub Janco - 2.4.1-1 +- new version + +* Fri Feb 22 2019 Jakub Janco - 2.4.0-1 +- new version + +* Tue Jan 08 2019 Honza Horak - 2.3.0-2 +- Rebuild for buildroot change + +* Tue Dec 18 2018 Jakub Janco - 2.3.0-1 +- new version + +* Tue Dec 18 2018 Jakub Janco - 2.2.6-2 +- add missing build dependencies + +* Fri Aug 10 2018 Jakub Janco - 2.2.6-1 +- new version and SCL-izing spec + +* Thu Jun 14 2018 Jakub Janco - 2.2.5-1 +- update version + +* Mon May 28 2018 Michael Simacek - 2.2.3-2 +- Remove BR on maven-javadoc-plugin + +* Tue Mar 13 2018 Jakub Janco - 2.2.3-1 +- update version + +* Mon Feb 26 2018 Jakub Janco - 2.2.2-1 +- update version + +* Thu Feb 08 2018 Fedora Release Engineering - 2.2.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Jan 03 2018 Jakub Janco - 2.2.1-1 +- Update to 2.2.1 + +* Tue Nov 21 2017 Jakub Janco - 2.2.0-1 +- Update to 2.2.0 + +* Tue Aug 29 2017 Tomas Repik - 2.1.0-1 +- Update to 2.1.0 + +* Wed Jul 26 2017 Fedora Release Engineering - 2.0.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Mon Jun 26 2017 Tomas Repik - 2.0.2-1 +- version update + +* Fri Feb 10 2017 Fedora Release Engineering - 1.5.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Mon Nov 28 2016 Tomas Repik - 1.5.5-1 +- version update + +* Mon Oct 03 2016 Tomas Repik - 1.5.3-1 +- version update + +* Wed Sep 14 2016 Tomas Repik - 1.5.2-1 +- version update + +* Tue Jun 21 2016 Tomas Repik - 1.4.6-1 +- version update + +* Mon Apr 18 2016 Tomas Repik - 1.4.2-1 +- version update + +* Wed Mar 23 2016 Tomas Repik - 1.3.7-1 +- version update +- BSD license added +- cosmetic updates in prep phase + +* Thu Mar 10 2016 Tomas Repik - 1.3.6-1 +- version update + +* Mon Feb 15 2016 Tomas Repik - 1.3.5-1 +- version update + +* Wed Jan 20 2016 Tomáš Repík - 1.3.3-3 +- generating OSGi manifest file with maven-bundle-plugin + +* Wed Dec 16 2015 Tomáš Repík - 1.3.3-2 +- installing LICENSE added +- conversion from dos to unix line encoding revised +- unnecessary tasks removed + +* Wed Dec 9 2015 Tomáš Repík - 1.3.3-1 +- Initial package