pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/java-netty: import java-netty-4.1.53



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Nov 18 22:29:00 2020 +0100
Changeset:	216b86d9ff25fb21af74d56ca1f45afe87031aab

Added Files:
	java-netty/DESCR
	java-netty/Makefile
	java-netty/PLIST
	java-netty/distinfo
	java-netty/files/patch-netty_kqueue_bsdsocket.c

Log Message:
wip/java-netty: import java-netty-4.1.53

Netty is a NIO client server framework which enables quick and easy
development of network applications such as protocol servers and
clients. It greatly simplifies and streamlines network programming
such as TCP and UDP socket server.

'Quick and easy' doesn't mean that a resulting application will suffer
from a maintainability or a performance issue. Netty has been designed
carefully with the experiences earned from the implementation of a lot
of protocols such as FTP, SMTP, HTTP, and various binary and
text-based legacy protocols. As a result, Netty has succeeded to find
a way to achieve ease of development, performance, stability, and
flexibility without a compromise.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=216b86d9ff25fb21af74d56ca1f45afe87031aab

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 java-netty/DESCR                                |  12 +++
 java-netty/Makefile                             |  77 +++++++++++++++++
 java-netty/PLIST                                |   3 +
 java-netty/distinfo                             |   6 ++
 java-netty/files/patch-netty_kqueue_bsdsocket.c | 107 ++++++++++++++++++++++++
 5 files changed, 205 insertions(+)

diffs:
diff --git a/java-netty/DESCR b/java-netty/DESCR
new file mode 100644
index 0000000000..2c6db23b7f
--- /dev/null
+++ b/java-netty/DESCR
@@ -0,0 +1,12 @@
+Netty is a NIO client server framework which enables quick and easy
+development of network applications such as protocol servers and
+clients. It greatly simplifies and streamlines network programming
+such as TCP and UDP socket server.
+
+'Quick and easy' doesn't mean that a resulting application will suffer
+from a maintainability or a performance issue. Netty has been designed
+carefully with the experiences earned from the implementation of a lot
+of protocols such as FTP, SMTP, HTTP, and various binary and
+text-based legacy protocols. As a result, Netty has succeeded to find
+a way to achieve ease of development, performance, stability, and
+flexibility without a compromise.
diff --git a/java-netty/Makefile b/java-netty/Makefile
new file mode 100644
index 0000000000..f3d6feb8da
--- /dev/null
+++ b/java-netty/Makefile
@@ -0,0 +1,77 @@
+# $NetBSD$
+
+DISTNAME=	netty-4.1.53.Final
+PKGNAME=	java-${DISTNAME:S/.Final//}
+CATEGORIES=	java devel
+MASTER_SITES=	http://dl.bintray.com/netty/downloads/
+EXTRACT_SUFX=	.tar.bz2
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	https://netty.io/
+COMMENT=	Asynchronous event-driven network application framework and tools
+LICENSE=	apache-2.0
+
+JAR=		${PKG_JAVA_HOME}/bin/jar
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${MACHINE_ARCH} == "aarch64"
+NETTY_ARCH=	aarch_64
+.elif ${MACHINE_ARCH} == "amd64"
+NETTY_ARCH=	x86_64
+.elif ${MACHINE_ARCH} == "i386"
+NETTY_ARCH=	x86_32
+.else
+NETTY_ARCH=	${MACHINE_ARCH}
+.endif
+
+post-extract:
+	${RUN} cd ${WRKSRC} && \
+		${JAR} xf jar/netty-transport-native-kqueue-${PKGVERSION_NOREV}.Final-sources.jar
+	${RUN} cd ${WRKSRC} && \
+		${JAR} xf jar/netty-transport-native-unix-common-${PKGVERSION_NOREV}.Final-sources.jar
+	${RUN} cd ${WRKSRC} && cat ${FILESDIR}/patch-netty_kqueue_bsdsocket.c | patch -p0
+
+CFLAGS+=	-D_POSIX_C_SOURCE=200112L -D_NETBSD_SOURCE
+CFLAGS+=	-I${PKG_JAVA_HOME}/include
+CFLAGS+=	-I${PKG_JAVA_HOME}/include/${LOWER_OPSYS}
+
+NETTY_UNIX_COMMON_SRCS=	netty_unix_buffer.c netty_unix_errors.c \
+			netty_unix_filedescriptor.c netty_unix_limits.c \
+			netty_unix_socket.c netty_unix_util.c
+NETTY_KQUEUE_SRCS=	netty_kqueue_bsdsocket.c netty_kqueue_eventarray.c \
+			netty_kqueue_native.c
+NETTY_SRCS=		${NETTY_UNIX_COMMON_SRCS} ${NETTY_KQUEUE_SRCS}
+NETTY_LOS=		${NETTY_SRCS:S/.c$/.lo/}
+
+do-build:
+.for f in ${NETTY_SRCS}
+	${RUN} cd ${WRKSRC} && \
+		 ${LIBTOOL} --mode=compile --tag=CC ${CC} ${CFLAGS} -c ${f}
+.endfor
+	${RUN} cd ${WRKSRC} && \
+		${LIBTOOL} --mode=link --tag=CC ${CC} \
+			-avoid-version ${LDFLAGS} \
+                        -o libnetty_transport_native_kqueue_${NETTY_ARCH}.la \
+			${NETTY_LOS} -rpath ${PREFIX}/lib
+
+INSTALLATION_DIRS=	lib/java
+
+do-install:
+	${RUN} cd ${WRKSRC} && \
+		${LIBTOOL} --mode=install ${INSTALL_LIB} \
+			-c libnetty_transport_native_kqueue_${NETTY_ARCH}.la \
+			${DESTDIR}${PREFIX}/lib/libnetty_transport_native_kqueue_${NETTY_ARCH}.la
+	${MKDIR} ${WRKSRC}/jar/all-in-one/META-INF/native
+	${MV} ${DESTDIR}${PREFIX}/lib/libnetty_transport_native_kqueue_${NETTY_ARCH}.so \
+		${WRKSRC}/jar/all-in-one/META-INF/native
+	${RUN} cd ${WRKSRC}/jar/all-in-one && \
+		${JAR} uvf netty-all-${PKGVERSION_NOREV}.Final.jar \
+		META-INF/native/libnetty_transport_native_kqueue*.so
+	${INSTALL_DATA} ${WRKSRC}/jar/all-in-one/netty-all-${PKGVERSION_NOREV}.Final.jar \
+		${DESTDIR}${PREFIX}/lib/java/netty-${PKGVERSION_NOREV}.jar
+	${LN} -nfs netty-${PKGVERSION_NOREV}.jar ${DESTDIR}${PREFIX}/lib/java/netty.jar
+	${RM} -f ${DESTDIR}${PREFIX}/lib/libnetty_transport_native_kqueue_x86_64.*
+
+.include "../../mk/java-vm.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/java-netty/PLIST b/java-netty/PLIST
new file mode 100644
index 0000000000..16aef74b76
--- /dev/null
+++ b/java-netty/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD$
+lib/java/netty-${PKGVERSION}.jar
+lib/java/netty.jar
diff --git a/java-netty/distinfo b/java-netty/distinfo
new file mode 100644
index 0000000000..a15a4d8beb
--- /dev/null
+++ b/java-netty/distinfo
@@ -0,0 +1,6 @@
+$NetBSD$
+
+SHA1 (netty-4.1.53.Final.tar.bz2) = 35a0f3f1503e2de1dbce73dcac727aea83f622c6
+RMD160 (netty-4.1.53.Final.tar.bz2) = a1de9e971cbd95384d09920c623bf69b9b27ad1e
+SHA512 (netty-4.1.53.Final.tar.bz2) = f45ff56e09177b0e54a4bd9c16bc885ee6c307d946d1b4881eec5508515ccca17abbdfd560a1b7ee6217d040c045f88a5a2f0547ef2bc780984058c8a88df9ae
+Size (netty-4.1.53.Final.tar.bz2) = 23826138 bytes
diff --git a/java-netty/files/patch-netty_kqueue_bsdsocket.c b/java-netty/files/patch-netty_kqueue_bsdsocket.c
new file mode 100644
index 0000000000..130c5bf49a
--- /dev/null
+++ b/java-netty/files/patch-netty_kqueue_bsdsocket.c
@@ -0,0 +1,107 @@
+Fix NetBSD build.
+
+--- netty_kqueue_bsdsocket.c	2020-10-13 06:30:08.000000000 +0200
++++ netty_kqueue_bsdsocket.c	2020-11-18 21:42:31.794460137 +0100
+@@ -41,6 +41,7 @@
+ static jfieldID fileDescriptorFieldId = NULL;
+ static jmethodID peerCredentialsMethodId = NULL;
+ 
++#if !defined(__NetBSD__)
+ // JNI Registered Methods Begin
+ static jlong netty_kqueue_bsdsocket_sendFile(JNIEnv* env, jclass clazz, jint socketFd, jobject fileRegion, jlong base_off, jlong off, jlong len) {
+     jobject fileChannel = (*env)->GetObjectField(env, fileRegion, fileChannelFieldId);
+@@ -80,6 +81,7 @@
+     }
+     return res < 0 ? -err : 0;
+ }
++#endif
+ 
+ static void netty_kqueue_bsdsocket_setAcceptFilter(JNIEnv* env, jclass clazz, jint fd, jstring afName, jstring afArg) {
+ #ifdef SO_ACCEPTFILTER
+@@ -129,14 +131,17 @@
+ #endif
+ }
+ 
++#ifdef TCP_NOPUSH
+ static void netty_kqueue_bsdsocket_setTcpNoPush(JNIEnv* env, jclass clazz, jint fd, jint optval) {
+     netty_unix_socket_setOption(env, fd, IPPROTO_TCP, TCP_NOPUSH, &optval, sizeof(optval));
+ }
++#endif
+ 
+ static void netty_kqueue_bsdsocket_setSndLowAt(JNIEnv* env, jclass clazz, jint fd, jint optval) {
+     netty_unix_socket_setOption(env, fd, SOL_SOCKET, SO_SNDLOWAT, &optval, sizeof(optval));
+ }
+ 
++#ifdef TCP_NOPUSH
+ static jint netty_kqueue_bsdsocket_getTcpNoPush(JNIEnv* env, jclass clazz, jint fd) {
+   int optval;
+   if (netty_unix_socket_getOption(env, fd, IPPROTO_TCP, TCP_NOPUSH, &optval, sizeof(optval)) == -1) {
+@@ -144,6 +149,7 @@
+   }
+   return optval;
+ }
++#endif
+ 
+ static jint netty_kqueue_bsdsocket_getSndLowAt(JNIEnv* env, jclass clazz, jint fd) {
+   int optval;
+@@ -154,6 +160,22 @@
+ }
+ 
+ static jobject netty_kqueue_bsdsocket_getPeerCredentials(JNIEnv *env, jclass clazz, jint fd) {
++#ifdef __NetBSD__
++    struct unpcbid cred;
++    socklen_t credlen = sizeof(cred);
++
++    if (netty_unix_socket_getOption(env, fd, SOL_SOCKET, LOCAL_PEEREID, &cred, credlen) == -1)
++        return NULL;
++
++    pid_t pid = cred.unp_pid;
++    uid_t euid = cred.unp_euid;
++    gid_t egid = cred.unp_egid;
++
++    jintArray gids = NULL;
++    (*env)->SetIntArrayRegion(env, gids, 0, 1, (jint*) &egid);
++
++    return (*env)->NewObject(env, peerCredentialsClass, peerCredentialsMethodId, pid, euid, gids);
++#else
+     struct xucred credentials;
+     // It has been observed on MacOS that this method can complete successfully but not set all fields of xucred.
+     credentials.cr_ngroups = 0;
+@@ -184,16 +206,21 @@
+ #endif
+ 
+     return (*env)->NewObject(env, peerCredentialsClass, peerCredentialsMethodId, pid, credentials.cr_uid, gids);
++#endif
+ }
+ // JNI Registered Methods End
+ 
+ // JNI Method Registration Table Begin
+ static const JNINativeMethod fixed_method_table[] = {
+   { "setAcceptFilter", "(ILjava/lang/String;Ljava/lang/String;)V", (void *) netty_kqueue_bsdsocket_setAcceptFilter },
++#ifdef TCP_NOPUSH
+   { "setTcpNoPush", "(II)V", (void *) netty_kqueue_bsdsocket_setTcpNoPush },
++#endif
+   { "setSndLowAt", "(II)V", (void *) netty_kqueue_bsdsocket_setSndLowAt },
+   { "getAcceptFilter", "(I)[Ljava/lang/String;", (void *) netty_kqueue_bsdsocket_getAcceptFilter },
++#ifdef TCP_NOPUSH
+   { "getTcpNoPush", "(I)I", (void *) netty_kqueue_bsdsocket_getTcpNoPush },
++#endif
+   { "getSndLowAt", "(I)I", (void *) netty_kqueue_bsdsocket_getSndLowAt }
+ };
+ 
+@@ -214,6 +241,7 @@
+     memcpy(dynamicMethods, fixed_method_table, sizeof(fixed_method_table));
+ 
+     JNINativeMethod* dynamicMethod = &dynamicMethods[fixed_method_table_size];
++#if !defined(__NetBSD__)
+     NETTY_PREPEND(packagePrefix, "io/netty/channel/DefaultFileRegion;JJJ)J", dynamicTypeName, error);
+     NETTY_PREPEND("(IL", dynamicTypeName,  dynamicMethod->signature, error);
+     dynamicMethod->name = "sendFile";
+@@ -221,6 +249,7 @@
+     netty_unix_util_free_dynamic_name(&dynamicTypeName);
+ 
+     ++dynamicMethod;
++#endif
+     NETTY_PREPEND(packagePrefix, "io/netty/channel/unix/PeerCredentials;", dynamicTypeName, error);
+     NETTY_PREPEND("(I)L", dynamicTypeName,  dynamicMethod->signature, error);
+     dynamicMethod->name = "getPeerCredentials";


Home | Main Index | Thread Index | Old Index