git: 677e0323efa5 - main - devel/pcsc-cyberjack: New port for Reiner SCT cyberjack PCSC driver

From: Tilman Keskinoz <arved_at_FreeBSD.org>
Date: Mon, 14 Nov 2022 19:46:07 UTC
The branch main has been updated by arved:

URL: https://cgit.FreeBSD.org/ports/commit/?id=677e0323efa55f8b6d88340036b4c0a135f1659d

commit 677e0323efa55f8b6d88340036b4c0a135f1659d
Author:     Tilman Keskinoz <arved@FreeBSD.org>
AuthorDate: 2022-11-14 19:43:58 +0000
Commit:     Tilman Keskinoz <arved@FreeBSD.org>
CommitDate: 2022-11-14 19:43:58 +0000

    devel/pcsc-cyberjack: New port for Reiner SCT cyberjack PCSC driver
    
    PR:             229361
    Submitted by:   Thomas Merkel and info@maisy.de
---
 devel/Makefile                                     |  1 +
 devel/pcsc-cyberjack/Makefile                      | 35 +++++++++
 devel/pcsc-cyberjack/distinfo                      |  3 +
 devel/pcsc-cyberjack/files/patch-cjeca32_Debug.cpp | 11 +++
 .../files/patch-cjeca32_RSCTCriticalSection.cpp    | 11 +++
 devel/pcsc-cyberjack/files/patch-configure.ac      | 10 +++
 devel/pcsc-cyberjack/files/patch-ifd-Makefile.am   | 14 ++++
 .../files/patch-include_driver_Debug.h             | 19 +++++
 .../files/patch-include_driver_Platform__unix.h    | 11 +++
 .../patch-libcyberjack_checksuite_cm__distri.cpp   | 24 ++++++
 .../files/patch-libcyberjack_libdialog_dialog.c    | 87 ++++++++++++++++++++++
 devel/pcsc-cyberjack/pkg-descr                     |  2 +
 devel/pcsc-cyberjack/pkg-plist                     |  6 ++
 13 files changed, 234 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index 4a6687d9b8da..202990547011 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -3794,6 +3794,7 @@
     SUBDIR += pcre
     SUBDIR += pcre++
     SUBDIR += pcre2
+    SUBDIR += pcsc-cyberjack
     SUBDIR += pcsc-lite
     SUBDIR += pdcurses
     SUBDIR += pear
diff --git a/devel/pcsc-cyberjack/Makefile b/devel/pcsc-cyberjack/Makefile
new file mode 100644
index 000000000000..76b2f67aab58
--- /dev/null
+++ b/devel/pcsc-cyberjack/Makefile
@@ -0,0 +1,35 @@
+PORTNAME=	pcsc-cyberjack
+DISTVERSION=	3.99.5final.SP15
+CATEGORIES=	devel security
+MASTER_SITES=	https://support.reiner-sct.de/downloads/LINUX/V3.99.5_SP15/
+DISTNAME=	${PORTNAME}_${DISTVERSION}
+
+MAINTAINER=	tm@NetBSD.org
+COMMENT=	Reiner SCT cyberJack card reader pcsc driver
+WWW=		https://www.reiner-sct.de
+
+LICENSE=	GPLv2 LGPL20
+LICENSE_COMB=	dual
+LICENSE_FILE_GPLv2=	${WRKSRC}/COPYRIGHT.GPL
+LICENSE_FILE_LGPL20=	${WRKSRC}/COPYRIGHT.LGPL
+
+LIB_DEPENDS=	libpcsclite.so:devel/pcsc-lite \
+		libxml2.so:textproc/libxml2
+
+USES=		dos2unix gmake libtool tar:bzip2 autoreconf compiler:gcc-c++11-lib
+
+USE_LDCONFIG=	yes
+GNU_CONFIGURE=	yes
+
+WRKSRC=		${WRKDIR}/${PORTNAME}-${DISTVERSION}
+
+CONFIGURE_ARGS=	--enable-release --with-usbdropdir=${PREFIX}/lib/pcsc/drivers
+CONFIGURE_ENV=	LIBUSB_CFLAGS="-I${LOCALBASE}/include" \
+		LIBUSB_LIBS="-L${LOCALBASE}/lib -lusb"
+CXXFLAGS+=	-Wno-c++11-narrowing
+CPPFLAGS+=	-I${LOCALBASE}/include ${PTHREAD_CFLAGS}
+LDFLAGS+=	${PTHREAD_LIBS}
+
+PLIST_SUB=	VER=${PORTVERSION}
+
+.include <bsd.port.mk>
diff --git a/devel/pcsc-cyberjack/distinfo b/devel/pcsc-cyberjack/distinfo
new file mode 100644
index 000000000000..8f6e4218e79b
--- /dev/null
+++ b/devel/pcsc-cyberjack/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1667424080
+SHA256 (pcsc-cyberjack_3.99.5final.SP15.tar.bz2) = acb7c2832450718756713767c4b3ef500832d652ed51b35110b910b11ebd467a
+SIZE (pcsc-cyberjack_3.99.5final.SP15.tar.bz2) = 1681827
diff --git a/devel/pcsc-cyberjack/files/patch-cjeca32_Debug.cpp b/devel/pcsc-cyberjack/files/patch-cjeca32_Debug.cpp
new file mode 100644
index 000000000000..c5b6b960ed66
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-cjeca32_Debug.cpp
@@ -0,0 +1,11 @@
+--- cjeca32/Debug.cpp.orig	2021-11-03 13:00:16 UTC
++++ cjeca32/Debug.cpp
+@@ -141,7 +141,7 @@ CDebug Debug(0xffffffff);
+
+
+
+-#elif defined(OS_LINUX) || defined(OS_DARWIN)
++#elif defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_FREEBSD)
+
+ #if defined(OS_DARWIN)
+ # define DEBUG_DEFAULT_LOGFILE "/Library/Logs/cj.log"
diff --git a/devel/pcsc-cyberjack/files/patch-cjeca32_RSCTCriticalSection.cpp b/devel/pcsc-cyberjack/files/patch-cjeca32_RSCTCriticalSection.cpp
new file mode 100644
index 000000000000..f80f57292a1f
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-cjeca32_RSCTCriticalSection.cpp
@@ -0,0 +1,11 @@
+--- cjeca32/RSCTCriticalSection.cpp.orig	2021-11-03 13:00:16 UTC
++++ cjeca32/RSCTCriticalSection.cpp
+@@ -22,7 +22,7 @@ void CRSCTCriticalSection::Leave(void)
+ 	LeaveCriticalSection(&m_hCritSec);
+ }
+ 
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_FREEBSD)
+ 
+ CRSCTCriticalSection::CRSCTCriticalSection(void){
+ }
diff --git a/devel/pcsc-cyberjack/files/patch-configure.ac b/devel/pcsc-cyberjack/files/patch-configure.ac
new file mode 100644
index 000000000000..2599625e547e
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-configure.ac
@@ -0,0 +1,10 @@
+--- configure.ac.orig	2021-11-03 13:00:16 UTC
++++ configure.ac
+@@ -221,6 +221,7 @@ fi
+ AM_CONDITIONAL(IS_WINDOWS, [test "$OS_TYPE" = "windows"])
+ AM_CONDITIONAL(IS_OSX, [test "$OSYSTEM" = "osx"])
+ AM_CONDITIONAL(IS_LINUX, [test "$OSYSTEM" = "linux"])
++AM_CONDITIONAL(IS_FREEBSD, [test "$OSYSTEM" = "freebsd"])
+ 
+ AC_SUBST(cyberjack_sys_is_windows)
+ AC_SUBST(cyberjack_config_file)
diff --git a/devel/pcsc-cyberjack/files/patch-ifd-Makefile.am b/devel/pcsc-cyberjack/files/patch-ifd-Makefile.am
new file mode 100644
index 000000000000..710b72b046b1
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-ifd-Makefile.am
@@ -0,0 +1,14 @@
+--- ifd/Makefile.am.orig	2021-11-03 13:00:16 UTC
++++ ifd/Makefile.am
+@@ -23,6 +23,11 @@ bundleosxdir=$(usbdropdir)/libifd-cyberjack.bundle/Con
+ bundleosx_LTLIBRARIES=libifd-cyberjack.la
+ endif
+ 
++if IS_FREEBSD
++bundlefreebsddir=$(usbdropdir)/libifd-cyberjack.bundle/Contents/FreeBSD
++bundlefreebsd_LTLIBRARIES=libifd-cyberjack.la
++endif
++
+ libifd_cyberjack_la_SOURCES=ifd.cpp
+ libifd_cyberjack_la_LDFLAGS=-version-info @CYBERJACK_SO_CURRENT@:@CYBERJACK_SO_REVISION@:@CYBERJACK_SO_AGE@ -no-undefined
+ #libifd_cyberjack_la_LIBADD=$(top_builddir)/cjeca32/libeca.la $(top_builddir)/cjeca32/ausb/libausb.la
diff --git a/devel/pcsc-cyberjack/files/patch-include_driver_Debug.h b/devel/pcsc-cyberjack/files/patch-include_driver_Debug.h
new file mode 100644
index 000000000000..701743a0990b
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-include_driver_Debug.h
@@ -0,0 +1,19 @@
+--- include/driver/Debug.h.orig	2021-11-03 13:00:16 UTC
++++ include/driver/Debug.h
+@@ -42,14 +42,14 @@ class CJECA32_PRIVATE_CLASS CDebug (public)
+ public:
+ 	~CDebug(void);
+ 
+-#if defined(OS_LINUX) || defined(OS_DARWIN)
++#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_FREEBSD)
+ 	void setLevelMask(unsigned int nLevelMask);
+ 	void setLogFileName(const char *fname);
+ #endif
+ 	
+ private:
+    unsigned int m_nLevelMask;
+-#if defined(OS_LINUX) || defined(OS_DARWIN)
++#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_FREEBSD)
+        char *m_logFileName;
+ #endif
+ };
diff --git a/devel/pcsc-cyberjack/files/patch-include_driver_Platform__unix.h b/devel/pcsc-cyberjack/files/patch-include_driver_Platform__unix.h
new file mode 100644
index 000000000000..a90fd3ec890f
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-include_driver_Platform__unix.h
@@ -0,0 +1,11 @@
+--- include/driver/Platform_unix.h.orig	2021-11-03 13:00:16 UTC
++++ include/driver/Platform_unix.h
+@@ -40,7 +40,7 @@
+ #include <string.h>
+ #include <stdint.h>
+ 
+-#ifndef OS_DARWIN
++#if !defined(OS_DARWIN) && !defined(OS_FREEBSD)
+ # include <malloc.h>
+ #endif
+ 
diff --git a/devel/pcsc-cyberjack/files/patch-libcyberjack_checksuite_cm__distri.cpp b/devel/pcsc-cyberjack/files/patch-libcyberjack_checksuite_cm__distri.cpp
new file mode 100644
index 000000000000..d00a4503b867
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-libcyberjack_checksuite_cm__distri.cpp
@@ -0,0 +1,24 @@
+--- libcyberjack/checksuite/cm_distri.cpp.orig	2021-11-03 13:00:16 UTC
++++ libcyberjack/checksuite/cm_distri.cpp
+@@ -10,8 +10,9 @@
+  ***************************************************************************/
+ 
+ 
++#include "config.h"
++#include "Platform.h"
+ 
+-
+ #include "cm_distri.h"
+ #include "checksuite.h"
+ 
+@@ -21,6 +22,10 @@
+ #include <string.h>
+ #include <unistd.h>
+ 
++#ifdef OS_FREEBSD
++#include <sys/types.h>
++#include <sys/wait.h>
++#endif
+ 
+ 
+ bool CM_Distri::check(std::string &xmlString,
diff --git a/devel/pcsc-cyberjack/files/patch-libcyberjack_libdialog_dialog.c b/devel/pcsc-cyberjack/files/patch-libcyberjack_libdialog_dialog.c
new file mode 100644
index 000000000000..e13ac33475a7
--- /dev/null
+++ b/devel/pcsc-cyberjack/files/patch-libcyberjack_libdialog_dialog.c
@@ -0,0 +1,87 @@
+--- libcyberjack/libdialog/dialog.c.orig	2021-11-03 13:00:16 UTC
++++ libcyberjack/libdialog/dialog.c
+@@ -22,7 +22,7 @@
+  *                                                                         *
+  ***************************************************************************/
+ 
+-
++#include "config.h"
+ #include "Platform.h"
+ #include "dialog_p.h"
+ #include "network.h"
+@@ -30,7 +30,11 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <pwd.h>
++#ifdef OS_FREEBSD
++#include <utmpx.h>
++#else
+ #include <utmp.h>
++#endif
+ 
+ #include <errno.h>
+ #include <string.h>
+@@ -120,11 +124,19 @@ static int rsct_dialog_mk_socket() {
+ 
+ static int rsct_dialog_mk_socket() {
+   char buffer[256];
++#ifdef OS_FREEBSD
++  struct utmpx *u_tmp_p;
++#else
+   struct utmp *u_tmp_p;
++#endif
+   struct passwd *pw;
+   int sk;
+ 
++#ifdef OS_FREEBSD
++  while ((u_tmp_p = getutxent()) != NULL) {
++#else
+   while ((u_tmp_p = getutent()) != NULL) {
++#endif
+     DEBUGPI("RSCT: ut_type=%d, ut_line=[%s]\n",
+ 	    u_tmp_p->ut_type,
+ 	    u_tmp_p->ut_line);
+@@ -136,7 +148,11 @@ static int rsct_dialog_mk_socket() {
+ 
+   if (u_tmp_p==NULL) {
+     DEBUGPE("RSCT: No user logged in at XServer :0 (%s (%d))\n", strerror(errno), errno);
++#ifdef OS_FREEBSD
++    endutxent();
++#else
+     endutent();
++#endif
+     return -1;
+   }
+ 
+@@ -144,18 +160,31 @@ static int rsct_dialog_mk_socket() {
+   if (pw==NULL) {
+     DEBUGPE("RSCT: Could not get home folder for user [%s]: %s (%d)\n",
+ 	    u_tmp_p->ut_user, strerror(errno), errno);
++#ifdef OS_FREEBSD
++    endutxent();
++#else
+     endutent();
++#endif
+     return -1;
+   }
+ 
+   if (pw->pw_dir==NULL || *(pw->pw_dir)==0) {
+     DEBUGPE("RSCT: User [%s] has no home folder\n", u_tmp_p->ut_user);
++#ifdef OS_FREEBSD
++    endutxent();
++#else
+     endutent();
++#endif
+     return -1;
+   }
+   strncpy(buffer, pw->pw_dir, sizeof(buffer)-1);
+   strncat(buffer, "/.cyberJack_gui_sock", sizeof(buffer)-1);
++#ifdef OS_FREEBSD
++  endutxent();
++#else
+   endutent();
++#endif
++
+ 
+   sk=rsct_net_connect_by_path(buffer);
+   if (sk==-1) {
diff --git a/devel/pcsc-cyberjack/pkg-descr b/devel/pcsc-cyberjack/pkg-descr
new file mode 100644
index 000000000000..13d146a3631e
--- /dev/null
+++ b/devel/pcsc-cyberjack/pkg-descr
@@ -0,0 +1,2 @@
+This driver package contains a working PC/SC driver for
+the Reiner SCT cyberJack card readers.
diff --git a/devel/pcsc-cyberjack/pkg-plist b/devel/pcsc-cyberjack/pkg-plist
new file mode 100644
index 000000000000..9437d2c26dc3
--- /dev/null
+++ b/devel/pcsc-cyberjack/pkg-plist
@@ -0,0 +1,6 @@
+lib/pcsc/drivers/libifd-cyberjack.bundle/Contents/FreeBSD/libifd-cyberjack.a
+lib/pcsc/drivers/libifd-cyberjack.bundle/Contents/FreeBSD/libifd-cyberjack.so
+lib/pcsc/drivers/libifd-cyberjack.bundle/Contents/FreeBSD/libifd-cyberjack.so.6
+lib/pcsc/drivers/libifd-cyberjack.bundle/Contents/FreeBSD/libifd-cyberjack.so.6.0.0
+lib/pcsc/drivers/libifd-cyberjack.bundle/Contents/Info.plist
+lib/pcsc/drivers/libifd-cyberjack.bundle/Contents/PkgInfo