dev-java/rxtx: Fix various build errors for Java 11+ and others, EAPI 8

- Fix compiler errors due to -Werror=format-security
- Fix Javadoc generation errors
- Replace 'javah' with 'javac -h' for JDK 10+
- Attempt to fix some random, nondeterministic build-time errors that
  were speculated to be caused by parallel 'make'.  Those errors are not
  always reproducible and may go away during a retry, which might have
  stopped some users (including the commit author himself) from
  reporting them.  Another random error popped up when the new ebuild
  revision was being tested, hence a fix that forces sequential build is
  attempted in the hope to prevent probable random errors.

Bug: https://bugs.gentoo.org/550534
Bug: https://bugs.gentoo.org/642030
Bug: https://bugs.gentoo.org/831394
Bug: https://bugs.gentoo.org/833396
Signed-off-by: Yuan Liao <liaoyuan@gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/24289
Signed-off-by: Miroslav Šulc <fordfrog@gentoo.org>
This commit is contained in:
Yuan Liao
2022-02-21 10:19:44 +01:00
committed by Miroslav Šulc
parent 19101965af
commit f8f2919fe3
4 changed files with 506 additions and 0 deletions
@@ -0,0 +1,50 @@
Debian patch for fixing build issues on JDK 10 and above.
In particular, 'javah' needs to replaced by 'javac -h' since 'javah'
has been removed due to JEP 313 (https://openjdk.java.net/jeps/313).
To support Javadoc generation with JDK 17 and above, the '-source 1.8'
option must be included in the arguments to 'javadoc'. Otherwise, the
following error would be raised:
src/gnu/io/LPRPort.java:373: error: invalid use of a restricted identifier 'yield'
yield();
^
(to invoke a method called yield, qualify the yield with a receiver or type name)
The original patch can be found at:
https://salsa.debian.org/java-team/rxtx/-/blob/6500bd55f265de7d2dfef68dc1df5d8b990f66c3/debian/patches/java10-compatibility.patch
Bug: https://bugs.gentoo.org/831394
---
Description: Fixes the build failure with Java 10
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/Makefile.am
+++ b/Makefile.am
@@ -111,11 +111,6 @@
$(CLASSES): $(javafiles) $(TOP)/Makefile
$(JAVAH_FIX)
$(JAVAC) $(javafiles)
- $(JAVAH) `(for i in $(javahfiles);do \
- if grep > /dev/null native.*\( $(SPATH)/gnu/io/$$i.java; then \
- echo $(CLASSDIR).$$i; \
- fi; \
- done)`
$(JAR) cf $(JARTARGET) $(CLASSTOP)/*
# install librxtxSerial.so into the proper directory and copy $(JARTARGET) to its
--- a/configure.in
+++ b/configure.in
@@ -485,9 +485,9 @@
*)
find_java_native_include jni_md.h
JAVAH="\$(JPATH)/bin/javah -classpath \$(CLASSPATH) -d \$(DEST) -jni"
- JAVAC="\$(JPATH)/bin/javac -classpath \$(CLASSPATH) -d \$(TOP)/ -O -source 1.8 -target 1.8"
+ JAVAC="\$(JPATH)/bin/javac -classpath \$(CLASSPATH) -d \$(TOP)/ -O -source 1.8 -target 1.8 -h \$(DEST)"
JAR="\$(JPATH)/bin/jar"
- JAVADOC="\$(JPATH)/bin/javadoc"
+ JAVADOC="\$(JPATH)/bin/javadoc -source 1.8"
CFLAGS=$CFLAGS" -D_BSD_SOURCE"
;;
esac
@@ -0,0 +1,229 @@
From 4c47d6d133f727a9615987d582fa143e4a17cd01 Mon Sep 17 00:00:00 2001
From: Yuan Liao <liaoyuan@gmail.com>
Date: Sun, 20 Feb 2022 08:17:59 -0800
Subject: [PATCH] Fix invalid Javadoc syntax that leads to errors
Bug: https://bugs.gentoo.org/642030
Signed-off-by: Yuan Liao <liaoyuan@gmail.com>
---
src/gnu/io/RXTXPort.java | 50 ++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/src/gnu/io/RXTXPort.java b/src/gnu/io/RXTXPort.java
index 622a6a8..77a23ea 100644
--- a/src/gnu/io/RXTXPort.java
+++ b/src/gnu/io/RXTXPort.java
@@ -1732,7 +1732,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port the name of the port thats been preopened
* @return BaudRate on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
* This will not behave as expected with custom speeds
*
*/
@@ -1751,7 +1751,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port the name of the port thats been preopened
* @return DataBits on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
public static int staticGetDataBits( String port )
@@ -1770,7 +1770,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port the name of the port thats been preopened
* @return Parity on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
public static int staticGetParity( String port )
@@ -1789,7 +1789,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port the name of the port thats been preopened
* @return StopBits on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
public static int staticGetStopBits( String port )
@@ -1839,7 +1839,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* the port a second time later on.
*
* @return true on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1862,7 +1862,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* the port a second time later on.
*
* @return true on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1885,7 +1885,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* the port a second time later on.
*
* @return none
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1907,7 +1907,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port
* @return true if asserted
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1927,7 +1927,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port
* @return true if asserted
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1947,7 +1947,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port
* @return true if asserted
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1967,7 +1967,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port
* @return true if asserted
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -1987,7 +1987,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port
* @return true if asserted
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -2007,7 +2007,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
*
* @param port
* @return true if asserted
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
*/
@@ -2025,7 +2025,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* This is an extension to CommAPI. It may not be supported on
* all operating systems.
* @return int the Parity Error Character
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
* Anyone know how to do this in Unix?
*/
@@ -2049,7 +2049,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* all operating systems.
* @param b Parity Error Character
* @return boolean true on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
* Anyone know how to do this in Unix?
*/
@@ -2067,7 +2067,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* This is an extension to CommAPI. It may not be supported on
* all operating systems.
* @return int the End of Input Character
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*
* Anyone know how to do this in Unix?
*/
@@ -2091,7 +2091,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* all operating systems.
* @param b End Of Input Character
* @return boolean true on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*/
public boolean setEndOfInputChar( byte b )
@@ -2111,7 +2111,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* or "16750".
* @param test boolean flag to determin if the UART should be tested.
* @return boolean true on success
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*/
public boolean setUARTType(String type, boolean test)
throws UnsupportedCommOperationException
@@ -2127,7 +2127,7 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* @return type String representation of the UART type which mayb
* be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2"
* or "16750".
- * @throws UnsupportedCommOperationException;
+ * @throws UnsupportedCommOperationException
*/
public String getUARTType() throws UnsupportedCommOperationException
{
@@ -2140,7 +2140,8 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* @param BaudBase The clock frequency divided by 16. Default
* BaudBase is 115200.
* @return true on success
- * @throws UnsupportedCommOperationException, IOException
+ * @throws UnsupportedCommOperationException
+ * @throws IOException
*/
public boolean setBaudBase(int BaudBase)
@@ -2155,7 +2156,8 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
/**
* Extension to CommAPI
* @return BaudBase
- * @throws UnsupportedCommOperationException, IOException
+ * @throws UnsupportedCommOperationException
+ * @throws IOException
*/
public int getBaudBase() throws UnsupportedCommOperationException,
@@ -2170,7 +2172,8 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
* Extension to CommAPI. Set Baud Base to 38600 on Linux and W32
* before using.
* @param Divisor
- * @throws UnsupportedCommOperationException, IOException
+ * @throws UnsupportedCommOperationException
+ * @throws IOException
*/
public boolean setDivisor(int Divisor)
@@ -2184,7 +2187,8 @@ Documentation is at http://java.sun.com/products/jdk/1.2/docs/api/java/io/InputS
/**
* Extension to CommAPI
* @return Divisor;
- * @throws UnsupportedCommOperationException, IOException
+ * @throws UnsupportedCommOperationException
+ * @throws IOException
*/
public int getDivisor() throws UnsupportedCommOperationException,
--
2.34.1
@@ -0,0 +1,118 @@
Debian patch for fixing errors emitted due to -Werror=format-security.
The patch can be found at:
https://salsa.debian.org/java-team/rxtx/-/blob/6500bd55f265de7d2dfef68dc1df5d8b990f66c3/debian/patches/format_security.patch
Bug: https://bugs.gentoo.org/550534
---
From: tony mancill <tmancill@debian.org>
Forwarded: no
Description: use format specifiers in fprintf statements for hardening flags
--- a/src/SerialImp.c
+++ b/src/SerialImp.c
@@ -5108,7 +5108,7 @@
void report_warning(const char *msg)
{
#ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#else
mexWarnMsgTxt( (const char *) msg );
#endif /* DEBUG_MW */
@@ -5129,7 +5129,7 @@
#ifdef DEBUG_MW
mexErrMsgTxt( msg );
#else
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#endif /* DEBUG_MW */
#endif /* DEBUG_VERBOSE */
}
@@ -5145,7 +5145,7 @@
void report_error(const char *msg)
{
#ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#else
mexWarnMsgTxt( msg );
#endif /* DEBUG_MW */
@@ -5164,7 +5164,7 @@
{
#ifdef DEBUG
# ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
# else
mexPrintf( msg );
# endif /* DEBUG_MW */
--- a/src/ParallelImp.c
+++ b/src/ParallelImp.c
@@ -920,7 +920,7 @@
void report_error(char *msg)
{
#ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#else
mexWarnMsgTxt( msg );
#endif /* DEBUG_MW */
@@ -938,7 +938,7 @@
void report(char *msg)
{
#ifdef DEBUG
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#endif /* DEBUG */
}
--- a/src/SerialImp.cpp
+++ b/src/SerialImp.cpp
@@ -1844,7 +1844,7 @@
#ifdef DEBUG
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#endif
}
--- a/CNI/SerialImp.c
+++ b/CNI/SerialImp.c
@@ -4549,7 +4549,7 @@
void report_warning(char *msg)
{
#ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#else
mexWarnMsgTxt( (const char *) msg );
#endif /* DEBUG_MW */
@@ -4570,7 +4570,7 @@
#ifdef DEBUG_MW
mexErrMsgTxt( msg );
#else
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#endif /* DEBUG_MW */
#endif /* DEBUG_VERBOSE */
}
@@ -4586,7 +4586,7 @@
void report_error(char *msg)
{
#ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
#else
mexWarnMsgTxt( msg );
#endif /* DEBUG_MW */
@@ -4605,7 +4605,7 @@
{
#ifdef DEBUG
# ifndef DEBUG_MW
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
# else
mexPrintf( msg );
# endif /* DEBUG_MW */
+109
View File
@@ -0,0 +1,109 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
JAVA_PKG_IUSE="doc source"
inherit toolchain-funcs autotools java-pkg-2
MY_PV="$(ver_rs 2 '')"
MY_P="${PN}-${MY_PV}"
DESCRIPTION="Native library providing serial and parallel communication for Java"
# SSL protocol versions supported by the HTTPS website are too old for
# the latest web browsers, so please keep the HTTP URL for HOMEPAGE
HOMEPAGE="http://rxtx.qbang.org/"
SRC_URI="ftp://ftp.qbang.org/pub/rxtx/${MY_P}.zip"
LICENSE="LGPL-2.1+"
SLOT="2"
KEYWORDS="~amd64 ~x86"
IUSE="lfd"
RDEPEND=">=virtual/jre-1.8:*
lfd? ( sys-apps/xinetd )"
DEPEND=">=virtual/jdk-1.8:*"
BDEPEND="app-arch/unzip"
S="${WORKDIR}/${MY_P}"
src_prepare() {
sed -i -e "s:\(\$(JAVADOC)\):\1 -d api:g" Makefile.am || die
sed -i \
-e "s:UTS_RELEASE::g" \
-e "s:AM_CONFIG_HEADER:AC_CONFIG_HEADERS:g" \
-e "s:-source ... -target ...:$(java-pkg_javac-args):g" \
configure.in || die
eapply -p0 "${FILESDIR}/${PN}-2.1-7r2-lfd.diff"
eapply -p0 "${FILESDIR}/${PN}-2.1-7r2-nouts.diff"
eapply -p0 "${FILESDIR}/${P}-limits.patch"
eapply "${FILESDIR}/${P}-add-ttyACM.patch"
eapply "${FILESDIR}/${P}-format-security.patch"
eapply "${FILESDIR}/${P}-fix-invalid-javadoc.patch"
eapply "${FILESDIR}/${P}-fix-for-java-10+.patch"
eapply_user
rm acinclude.m4 || die
eautoreconf
}
src_configure() {
econf \
$(use_enable lfd lockfile_server)
}
src_compile() {
# Parallel build on this package may cause random
# build-time errors sometimes due to race conditions
emake -j1
if use lfd ; then
# see INSTALL in src/ldf
$(tc-getCC) ${LDFLAGS} ${CFLAGS} src/lfd/lockdaemon.c -o src/lfd/in.lfd || die
fi
if use doc ; then
emake -j1 docs
fi
# Fix for src zip creation
if use source ; then
mkdir -p src_with_pkg/gnu || die
ln -s ../../src src_with_pkg/gnu/io || die
fi
}
src_install() {
java-pkg_dojar RXTXcomm.jar
java-pkg_doso ${CHOST}/.libs/*.so
dodoc AUTHORS ChangeLog INSTALL PORTING TODO SerialPortInstructions.txt
docinto html
dodoc RMISecurityManager.html
if use lfd ; then
insinto /etc/xinetd.d
newins "${FILESDIR}/lockfiled.xinetd" lfd
dosbin src/lfd/in.lfd
dodoc src/lfd/LockFileServer.rfc
fi
use doc && java-pkg_dojavadoc api
use source && java-pkg_dosrc src_with_pkg/gnu
}
pkg_postinst() {
if use lfd ; then
elog "Don't forget to enable the LockFileServer"
elog "daemon (lfd) in /etc/xinetd.d/lfd"
else
elog "RXTX uses UUCP style device-locks. You should"
elog "add every user who needs to access serial ports"
elog "to the 'uucp' group:"
elog
elog " usermod -aG uucp <user>"
fi
}