git: 27df5bce08f3 - main - graphics/epsonscan2: Add new port for Epson Scanners

From: Rainer Hurling <rhurlin_at_FreeBSD.org>
Date: Sun, 03 Apr 2022 08:46:18 UTC
The branch main has been updated by rhurlin:

URL: https://cgit.FreeBSD.org/ports/commit/?id=27df5bce08f3b1d63d5b4275eaf91bc01d1dfa35

commit 27df5bce08f3b1d63d5b4275eaf91bc01d1dfa35
Author:     Rainer Hurling <rhurlin@FreeBSD.org>
AuthorDate: 2022-04-03 08:05:36 +0000
Commit:     Rainer Hurling <rhurlin@FreeBSD.org>
CommitDate: 2022-04-03 08:44:09 +0000

    graphics/epsonscan2: Add new port for Epson Scanners
    
    This is a port of the Seiko/Epson Epsonscan2 scanner engine and GUI[1].
    
    It provides a complete alternative to sane/xsane with its own scanner engine and GUI.
    It also provides a sane back-end library (libsane-epsonscan2.so) so that it works with the sane package.
    
    There are two parts to this port:
      - graphics/epsonscan2 - the main scanner engine and GUI that
        works with (most) USB scanners
      - graphics/epsonscan2-non-free-plugin - support for Epson's
        Linux binary that adds network access to scanners and
        usb access to some particular scanners
    
    Please read the file %%PREFIX%%/lib/epsonscan2/Read_me.FreeBSD for notes on how to set this up and use it.
    
    [1] https://download.ebz.epson.net/man/linux/epsonscan2_e.html
    
    PR:             261891
    Reviewed by:    (partly) Tatsuki Makino <tatsuki_makino@hotmail.com>, diizzy@
---
 graphics/Makefile                                  |    2 +
 graphics/epsonscan2-non-free-plugin/Makefile       |  102 ++
 graphics/epsonscan2-non-free-plugin/distinfo       |    9 +
 .../epsonscan2-non-free-plugin/files/ddeplugin.in  |   11 +
 .../epsonscan2-non-free-plugin/files/dtrplugin.in  |   11 +
 .../epsonscan2-non-free-plugin/files/es2intif.in   |   11 +
 .../epsonscan2-non-free-plugin/files/es2netif.in   |   11 +
 .../epsonscan2-non-free-plugin/files/fitplugin.in  |   11 +
 .../files/pkg-message.in                           |   16 +
 graphics/epsonscan2-non-free-plugin/pkg-descr      |    7 +
 graphics/epsonscan2-non-free-plugin/pkg-plist      |   52 +
 graphics/epsonscan2/Makefile                       |   53 +
 graphics/epsonscan2/distinfo                       |    3 +
 graphics/epsonscan2/files/Read_me.FreeBSD.in       |  633 ++++++++
 graphics/epsonscan2/files/patch-CMakeLists.txt     |   57 +
 .../files/patch-src_CommonUtility_DbgLog.cpp       |   21 +
 .../patch-src_CommonUtility_utils_ESAnyCastUtils.h |   28 +
 .../files/patch-src_CommonUtility_utils_ESFile.cpp |   12 +
 .../patch-src_CommonUtility_utils_PathUtils.cpp    |   10 +
 .../files/patch-src_Controller_CMakeLists.txt      |   11 +
 .../files/patch-src_Controller_Src_EntryPoints.cpp |   11 +
 ...tch-src_Controller_Src_FileFormat_FFManager.cpp |   12 +
 .../files/patch-src_Controller_Src_Filter_DTR.cpp  |   21 +
 ...h-src_Controller_Src_Filter_ProcOrientation.hpp |   10 +
 .../patch-src_Controller_Src_Filter_Saving.hpp     |   20 +
 .../patch-src_Controller_Src_Finder_UsbFinder.cpp  |   14 +
 ...rc_Controller_Src_KeysValues_All_Resolution.cpp |   11 +
 ...Controller_Src_KeysValues_All_ScanHeightMax.cpp |   11 +
 ..._Controller_Src_KeysValues_All_ScanWidthMax.cpp |   11 +
 .../patch-src_Controller_Src_Scanner_Engine.hpp    |   26 +
 .../patch-src_Controller_Src_Scanner_Scanner.cpp   |   27 +
 .../patch-src_ES2Command_Linux_CMakeLists.txt      |   11 +
 ...rc_ES2Command_Src_Command_ESCI2_ESCI2Accessor.h |   38 +
 ...2Command_Src_Interface_ipc_ipcInterfaceImpl.cpp |   11 +
 ...2Command_Src_Interface_usb_usbInterfaceImpl.cpp |   12 +
 ...ES2Command_Src_Interface_usb_usbInterfaceImpl.h |   15 +
 .../patch-src_ES2Command_Src_Utils_semaphore.hpp   |   71 +
 ...tch-src_ES2FileFormat_Header_IO_FKDestination.h |   32 +
 .../patch-src_ES2FileFormat_Header_IO_FKSource.h   |   11 +
 ...atch-src_ES2FileFormat_Header_Reader_FKReader.h |   34 +
 ...-src_ES2FileFormat_Source_PnmUtil_FKPnmUtil.cpp |   11 +
 graphics/epsonscan2/files/patch-src_Platform.cpp   |   69 +
 .../files/patch-src_SaneWrapper_backend.cpp        |   37 +
 .../files/patch-src_SaneWrapper_defines.h          |   33 +
 .../files/patch-src_SaneWrapper_epsonscan.cpp      |   29 +
 .../files/patch-src_ScanSDK_Src_SDK_supervisor.cpp |   29 +
 .../files/patch-src_Standalone_CMakeLists.txt      |    9 +
 .../patch-src_Standalone_addeditpagedialog.cpp     |    8 +
 .../files/patch-src_Standalone_commandlinemode.cpp |   20 +
 .../patch-src_Standalone_custommessagebox.cpp      |   11 +
 ...rc_Standalone_detectionareamindoublespinbox.cpp |   11 +
 ...patch-src_Standalone_deviceconnectiondialog.cpp |   28 +
 .../files/patch-src_Standalone_documentsize.cpp    |   23 +
 .../files/patch-src_Standalone_foldercomb.cpp      |   20 +
 ...-src_Standalone_imageformatsettingscombobox.cpp |   11 +
 ...tch-src_Standalone_imageformatsettingsdialog.ui |   38 +
 ...tch-src_Standalone_initdeviceselectcombobox.cpp |   11 +
 .../patch-src_Standalone_lengthdoublespinbox.cpp   |   11 +
 .../files/patch-src_Standalone_mainwindow.cpp      |   38 +
 .../files/patch-src_Standalone_mainwindow.ui       |   38 +
 ...ch-src_Standalone_networkdeviceselectdialog.cpp |   11 +
 .../files/patch-src_Standalone_rotateimage.cpp     |   47 +
 .../files/patch-src_Standalone_supervisor.cpp      |   29 +
 .../patch-src_Standalone_widthdoublespinbox.cpp    |   11 +
 .../files/patch-thirdparty_zlib_gzread.c           |   10 +
 .../files/patch-thirdparty_zlib_gzwrite.c          |   10 +
 graphics/epsonscan2/files/pkg-message.in           |   17 +
 graphics/epsonscan2/pkg-descr                      |    5 +
 graphics/epsonscan2/pkg-plist                      | 1650 ++++++++++++++++++++
 69 files changed, 3755 insertions(+)

diff --git a/graphics/Makefile b/graphics/Makefile
index 8d0ce3dcf3d8..a9df4c0a0080 100644
--- a/graphics/Makefile
+++ b/graphics/Makefile
@@ -168,6 +168,8 @@
     SUBDIR += ephoto
     SUBDIR += epix
     SUBDIR += eps2png
+    SUBDIR += epsonscan2
+    SUBDIR += epsonscan2-non-free-plugin
     SUBDIR += epstool
     SUBDIR += eterm-bg
     SUBDIR += evince
diff --git a/graphics/epsonscan2-non-free-plugin/Makefile b/graphics/epsonscan2-non-free-plugin/Makefile
new file mode 100644
index 000000000000..a7f0c8a2956e
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/Makefile
@@ -0,0 +1,102 @@
+PORTNAME=	epsonscan2-non-free-plugin
+DISTVERSION=	6.6.40.0
+CATEGORIES=	graphics
+MASTER_SITES=	https://download2.ebz.epson.net/${EPSONSCAN2}/common/rpm/x64/:amd64 \
+		https://download2.ebz.epson.net/${EPSONSCAN2}/common/deb/arm/:armv7 \
+		https://download2.ebz.epson.net/${EPSONSCAN2}/common/deb/arm/:armv7rasb \
+		https://download2.ebz.epson.net/${EPSONSCAN2}/common/rpm/x86/:i386
+DISTNAME=	${EPSONSCAN2}-bundle-${DISTVERSION}
+DISTFILES_amd64=	${DISTNAME}.${DIST_SUFX}${EXTRACT_SUFX}:amd64
+DISTFILES_armv7=	${DISTNAME}.${DIST_SUFX}${EXTRACT_SUFX}:armv7
+DISTFILES_armv7rasb=	${DISTNAME:S,bundle,bundle-raspbian,}.${DIST_SUFX}${EXTRACT_SUFX}:armv7rasb
+DISTFILES_i386=		${DISTNAME}.${DIST_SUFX}${EXTRACT_SUFX}:i386
+
+MAINTAINER=	fbsd@opal.com
+COMMENT=	Epson Scan 2 network interface non-free-plugin
+
+LICENSE=	EPSON
+LICENSE_NAME=	EPSON END USER SOFTWARE LICENSE AGREEMENT
+LICENSE_FILE=	${WRKDIR}/usr/share/doc/${PORTNAME}-${EPSON_VERSION}-1/COPYING.EPSON
+LICENSE_PERMS=	no-dist-mirror no-dist-sell no-pkg-mirror no-pkg-sell
+
+LEGAL_TEXT=	License does not permit public sharing or revenue earning, and restricts exports
+
+ONLY_FOR_ARCHS=	amd64 armv7 armv7rasb i386
+
+RUN_DEPENDS=	epsonscan2:graphics/epsonscan2 \
+		linux_libusb>=13.1.0:devel/linux_libusb
+
+USES=		linux
+USE_LDCONFIG=	${LINUXBASE}/usr/${LINUX_LIB}/epsonscan2/libexec \
+		${LINUXBASE}/usr/${LINUX_LIB}/epsonscan2/non-free-exec
+
+EPSON_VERSION=	1.0.0.5
+EPSONSCAN2=	${PORTNAME:S,-non-free-plugin,,}
+
+LINUX_WRAPPERS=	ddeplugin \
+		dtrplugin \
+		es2intif \
+		es2netif \
+		fitplugin
+
+NO_BUILD=	true
+
+SUB_FILES=	pkg-message \
+		${LINUX_WRAPPERS}
+
+SUB_LIST+=	LINUXBASE=${LINUXBASE} \
+		LINUX_LIB=${LINUX_LIB}
+
+PLIST_SUB+=	LINUX_LIB=${LINUX_LIB} \
+		LINUX_LIB_EXTRA=${LINUX_LIB_EXTRA}
+
+.include <bsd.port.pre.mk>
+
+.if ((${OSVERSION} >= 1400000 && ${OSVERSION} <= 1400053) || \
+     (${OSVERSION} >= 1300000 && ${OSVERSION} <= 1300526) || \
+      ${OSVERSION} < 1300000)
+.warning epsonscan2-non-free-plugin's es2intif requires FreeBSD 13.x or 14.x
+.warning kernel later than 2022/03/05 for operation with scanners shown with
+.warning [*] in ${PREFIX}/lib/epsonscan2/Read_me.FreeBSD.
+.endif
+
+.if ${ARCH} == amd64
+DIST_FMT=	rpm
+DIST_SUFX=	x86_64.${DIST_FMT}
+LINUX_ARCH=	x86_64
+LINUX_FMT=	rpm
+LINUX_LIB=	lib64
+LINUX_LIB_EXTRA=	"@comment "
+.elif ${ARCH} == armv7 || ${ARCH} == armv7rasb
+DIST_FMT=	deb
+DIST_SUFX=	armv7l.${DIST_FMT}
+LINUX_ARCH=	armhf
+LINUX_FMT=	deb
+LINUX_LIB=	lib/arm-linux-gnueabihf
+LINUX_LIB_EXTRA=	""
+.elif ${ARCH} == i386
+DIST_FMT=	rpm
+DIST_SUFX=	i686.${DIST_FMT}
+LINUX_ARCH=	i686
+LINUX_FMT=	rpm
+LINUX_LIB=	lib
+LINUX_LIB_EXTRA=	"@comment "
+.endif
+
+post-extract:
+.	if ${ARCH} == amd64 || ${ARCH} == i386
+		cd ${WRKDIR}; ${TAR} xf ${DISTNAME}.${DIST_SUFX}/plugins/${PORTNAME}-${EPSON_VERSION}-1.${LINUX_ARCH}.${DIST_FMT} && ${RM} -r ${DISTNAME}.${DIST_SUFX}
+.	elif ${ARCH} == armv7 || ${ARCH} == armv7rasb
+		cd ${WRKDIR}; ${TAR} xf ${DISTNAME}.${DIST_SUFX}/plugins/${PORTNAME}_${EPSON_VERSION}-1_${LINUX_ARCH}.${DIST_FMT} data.tar.xz && ${RM} -r ${DISTNAME}.${DIST_SUFX}
+		cd ${WRKDIR}; ${TAR} xf data.tar.xz && ${RM} data.tar.xz
+.	endif
+
+do-install:
+		${MKDIR} ${STAGEDIR}${LINUXBASE}
+		cd ${WRKDIR}/usr; ${COPYTREE_SHARE} . ${STAGEDIR}${LINUXBASE}/usr "! -path *-ocr* -a ! -path *.build-id*"
+		cd ${WRKDIR}/usr/${LINUX_LIB}/${EPSONSCAN2}/non-free-exec; ${INSTALL_KLD} ${LINUX_WRAPPERS} ${STAGEDIR}${LINUXBASE}/usr/${LINUX_LIB}/${EPSONSCAN2}/non-free-exec
+		${MKDIR} ${STAGEDIR}${PREFIX}/lib/${EPSONSCAN2}/non-free-exec
+		cd ${WRKDIR}; ${INSTALL_SCRIPT} ${LINUX_WRAPPERS} ${STAGEDIR}${PREFIX}/lib/${EPSONSCAN2}/non-free-exec
+		cd ${WRKDIR}/usr/share/doc/${PORTNAME}-${EPSON_VERSION}-1; ${CP} -pr . ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.post.mk>
diff --git a/graphics/epsonscan2-non-free-plugin/distinfo b/graphics/epsonscan2-non-free-plugin/distinfo
new file mode 100644
index 000000000000..e1cdd7062920
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/distinfo
@@ -0,0 +1,9 @@
+TIMESTAMP = 1644933572
+SHA256 (epsonscan2-bundle-6.6.40.0.armv7l.deb.tar.gz) = efe070472e662feea572899cdad0300b759edcf84b2f57c51c997df8d2c07171
+SIZE (epsonscan2-bundle-6.6.40.0.armv7l.deb.tar.gz) 18239327
+SHA256 (epsonscan2-bundle-6.6.40.0.i686.rpm.tar.gz) = c7b68d8cd0c0d7ae187d3c44b5edcca1ca625bbcab50db31e754e3d2261787f0
+SIZE (epsonscan2-bundle-6.6.40.0.i686.rpm.tar.gz) = 14582599
+SHA256 (epsonscan2-bundle-6.6.40.0.x86_64.rpm.tar.gz) = 2b9453dba611c6fbadb8105817020334b9ce1db205e6a68f3d1de198ca3d9451
+SIZE (epsonscan2-bundle-6.6.40.0.x86_64.rpm.tar.gz) = 14016602
+SHA256 (epsonscan2-bundle-raspbian-6.6.40.0.armv7l.deb.tar.gz) = 3b373288884ae38febb5eb9343e820d083d8690414c273f6cdf9abc77b3a171e
+SIZE (epsonscan2-bundle-raspbian-6.6.40.0.armv7l.deb.tar.gz) = 20669297
diff --git a/graphics/epsonscan2-non-free-plugin/files/ddeplugin.in b/graphics/epsonscan2-non-free-plugin/files/ddeplugin.in
new file mode 100644
index 000000000000..02b2ae040bf0
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/files/ddeplugin.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+# This wrapper script sets environment variable LD_LIBRARY_PATH to the list
+# of needed Linux library directories, then invokes the Linux binary in the
+# Linux directories.
+
+LINUX_EPSONSCAN2=%%LINUXBASE%%/usr/%%LINUX_LIB%%/epsonscan2
+
+PROG=${LINUX_EPSONSCAN2}/non-free-exec/`basename $0`
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LINUX_EPSONSCAN2}/non-free-exec:${LINUX_EPSONSCAN2}/libexec
+
+exec $PROG ${@+"$@"}
diff --git a/graphics/epsonscan2-non-free-plugin/files/dtrplugin.in b/graphics/epsonscan2-non-free-plugin/files/dtrplugin.in
new file mode 100644
index 000000000000..02b2ae040bf0
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/files/dtrplugin.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+# This wrapper script sets environment variable LD_LIBRARY_PATH to the list
+# of needed Linux library directories, then invokes the Linux binary in the
+# Linux directories.
+
+LINUX_EPSONSCAN2=%%LINUXBASE%%/usr/%%LINUX_LIB%%/epsonscan2
+
+PROG=${LINUX_EPSONSCAN2}/non-free-exec/`basename $0`
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LINUX_EPSONSCAN2}/non-free-exec:${LINUX_EPSONSCAN2}/libexec
+
+exec $PROG ${@+"$@"}
diff --git a/graphics/epsonscan2-non-free-plugin/files/es2intif.in b/graphics/epsonscan2-non-free-plugin/files/es2intif.in
new file mode 100644
index 000000000000..02b2ae040bf0
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/files/es2intif.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+# This wrapper script sets environment variable LD_LIBRARY_PATH to the list
+# of needed Linux library directories, then invokes the Linux binary in the
+# Linux directories.
+
+LINUX_EPSONSCAN2=%%LINUXBASE%%/usr/%%LINUX_LIB%%/epsonscan2
+
+PROG=${LINUX_EPSONSCAN2}/non-free-exec/`basename $0`
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LINUX_EPSONSCAN2}/non-free-exec:${LINUX_EPSONSCAN2}/libexec
+
+exec $PROG ${@+"$@"}
diff --git a/graphics/epsonscan2-non-free-plugin/files/es2netif.in b/graphics/epsonscan2-non-free-plugin/files/es2netif.in
new file mode 100644
index 000000000000..02b2ae040bf0
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/files/es2netif.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+# This wrapper script sets environment variable LD_LIBRARY_PATH to the list
+# of needed Linux library directories, then invokes the Linux binary in the
+# Linux directories.
+
+LINUX_EPSONSCAN2=%%LINUXBASE%%/usr/%%LINUX_LIB%%/epsonscan2
+
+PROG=${LINUX_EPSONSCAN2}/non-free-exec/`basename $0`
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LINUX_EPSONSCAN2}/non-free-exec:${LINUX_EPSONSCAN2}/libexec
+
+exec $PROG ${@+"$@"}
diff --git a/graphics/epsonscan2-non-free-plugin/files/fitplugin.in b/graphics/epsonscan2-non-free-plugin/files/fitplugin.in
new file mode 100644
index 000000000000..02b2ae040bf0
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/files/fitplugin.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+# This wrapper script sets environment variable LD_LIBRARY_PATH to the list
+# of needed Linux library directories, then invokes the Linux binary in the
+# Linux directories.
+
+LINUX_EPSONSCAN2=%%LINUXBASE%%/usr/%%LINUX_LIB%%/epsonscan2
+
+PROG=${LINUX_EPSONSCAN2}/non-free-exec/`basename $0`
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LINUX_EPSONSCAN2}/non-free-exec:${LINUX_EPSONSCAN2}/libexec
+
+exec $PROG ${@+"$@"}
diff --git a/graphics/epsonscan2-non-free-plugin/files/pkg-message.in b/graphics/epsonscan2-non-free-plugin/files/pkg-message.in
new file mode 100644
index 000000000000..a2f77a596d3a
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/files/pkg-message.in
@@ -0,0 +1,16 @@
+[
+{ type: install
+  message: <<EOM
+The graphics/epsonscan2 scanner driver is the main Epson scanner port.
+
+This port provides the Linux binaries needed to access the scanner over
+the network and for some older USB models.  This port requires the kernel
+Linux emulation and emulators/linux_base-c7 ports.  Depending on your scanner
+model, if you do not need network access, you may not need this port or the
+Linux emulator.
+
+Please read %%PREFIX%%/lib/epsonscan2/Read_me.FreeBSD for further details
+of how to configure and use this software.
+EOM
+}
+]
diff --git a/graphics/epsonscan2-non-free-plugin/pkg-descr b/graphics/epsonscan2-non-free-plugin/pkg-descr
new file mode 100644
index 000000000000..bfb8bbd15bd9
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/pkg-descr
@@ -0,0 +1,7 @@
+This port installs the Linux binaries of the Seiko/Epson non-free-plugin
+that is required for the graphics/epsonscan2 scanner driver.  The kernel
+Linux emulation is required to run these binaries.  This is only required
+to access a scanner over the network or for certain older USB scanner
+models.
+
+WWW: https://support.epson.net/linux/en/epsonscan2.php
diff --git a/graphics/epsonscan2-non-free-plugin/pkg-plist b/graphics/epsonscan2-non-free-plugin/pkg-plist
new file mode 100644
index 000000000000..76523887d8db
--- /dev/null
+++ b/graphics/epsonscan2-non-free-plugin/pkg-plist
@@ -0,0 +1,52 @@
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libcnx-esci-gt-s650.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libcnx-esci-gt-s650.so.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libcnx-esci-gt-s650.so.0.0.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libesci-interpreter-perfection-v330.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libesci-interpreter-perfection-v330.so.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libesci-interpreter-perfection-v330.so.0.0.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libesintA1.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libesintA1.so.2
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libesintA1.so.2.0.1
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libiscan-plugin-perfection-v370.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libiscan-plugin-perfection-v370.so.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libiscan-plugin-perfection-v370.so.0.0.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libiscan-plugin-perfection-v550.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libiscan-plugin-perfection-v550.so.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec/libiscan-plugin-perfection-v550.so.0.0.0
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/ddeplugin
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/dtrplugin
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/es2intif
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/es2netif
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/fitplugin
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/libdde6.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/libesdtr.so
+/compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec/libimf6.so
+/compat/linux/usr/%%DOCSDIR%%-1.0.0.5-1/COPYING.EPSON
+/compat/linux/usr/%%DOCSDIR%%-1.0.0.5-1/NEWS
+/compat/linux/usr/%%DOCSDIR%%-1.0.0.5-1/copyright
+/compat/linux/usr/share/epsonscan2/esfw010c.bin
+/compat/linux/usr/share/epsonscan2/esfwA1.bin
+/compat/linux/usr/share/epsonscan2/esfwad.bin
+/compat/linux/usr/share/epsonscan2/esfwdd.bin
+/compat/linux/usr/share/epsonscan2/esfweb.bin
+lib/epsonscan2/non-free-exec/ddeplugin
+lib/epsonscan2/non-free-exec/dtrplugin
+lib/epsonscan2/non-free-exec/es2intif
+lib/epsonscan2/non-free-exec/es2netif
+lib/epsonscan2/non-free-exec/fitplugin
+%%DOCSDIR%%/COPYING.EPSON
+%%DOCSDIR%%/NEWS
+%%DOCSDIR%%/copyright
+@dir /compat/linux/usr/%%LINUX_LIB%%/epsonscan2/libexec
+@dir /compat/linux/usr/%%LINUX_LIB%%/epsonscan2/non-free-exec
+@dir /compat/linux/usr/%%LINUX_LIB%%/epsonscan2
+@dir /compat/linux/usr/%%LINUX_LIB%%
+%%LINUX_LIB_EXTRA%%@dir /compat/linux/usr/lib
+@dir /compat/linux/usr/libexec
+@dir /compat/linux/usr/%%DOCSDIR%%-1.0.0.5-1
+@dir /compat/linux/usr/share/doc
+@dir /compat/linux/usr/share/epsonscan2
+@dir /compat/linux/usr/share
+@dir /compat/linux/usr
+@dir /compat/linux
+@dir /compat
diff --git a/graphics/epsonscan2/Makefile b/graphics/epsonscan2/Makefile
new file mode 100644
index 000000000000..0ecc95a66348
--- /dev/null
+++ b/graphics/epsonscan2/Makefile
@@ -0,0 +1,53 @@
+PORTNAME=	epsonscan2
+DISTVERSION=	6.6.40.0
+CATEGORIES=	graphics
+MASTER_SITES=	https://support.epson.net/linux/src/scanner/epsonscan2/
+DISTNAME=	${PORTNAME}-${PORTVERSION}-1.src
+
+MAINTAINER=	fbsd@opal.com
+COMMENT=	Epson Scan 2 scanner driver
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+BUILD_DEPENDS=	sane-config:graphics/sane-backends
+LIB_DEPENDS=	libboost_serialization.so:devel/boost-libs \
+		libdouble-conversion.so:devel/double-conversion \
+		libfreetype.so:print/freetype2 \
+		libglib-2.0.so:devel/glib20 \
+		libGL.so:graphics/libglvnd \
+		libgraphite2.so:graphics/graphite2 \
+		libicuuc.so:devel/icu \
+		libiconv.so:converters/libiconv \
+		libintl.so:devel/gettext-runtime \
+		libharfbuzz.so:print/harfbuzz \
+		libpcre.so:devel/pcre \
+		libpcre2-16.so:devel/pcre2 \
+		libpng.so:graphics/png \
+		libtiff.so:graphics/tiff \
+		libzstd.so:archivers/zstd
+RUN_DEPENDS=	avahi-browse:net/avahi-app
+
+USES=		cmake gettext-runtime gnome jpeg localbase qt:5 xorg
+USE_GNOME=	glib20
+USE_LDCONFIG=	${PREFIX}/lib/epsonscan2
+USE_QT=		buildtools_build core gui qmake_build widgets
+USE_XORG=	x11 xau xcb xdmcp
+
+EPSON_VERSION=	1.0.0.0
+
+CONFIGURE_ENV+=	STAGEDIR=${STAGEDIR}
+
+CFLAGS+=	-I${PREFIX}/include
+
+SUB_FILES=	pkg-message \
+		Read_me.FreeBSD
+
+WRKSRC=		${WRKDIR}/${PORTNAME}-${PORTVERSION}-1
+
+post-install:
+		${RM} -rf ${STAGEDIR}${DOCSDIR}
+		${MV} ${STAGEDIR}${DOCSDIR}-${EPSON_VERSION}-1 ${STAGEDIR}${DOCSDIR}
+		${INSTALL_DATA} ${WRKDIR}/Read_me.FreeBSD ${STAGEDIR}${PREFIX}/lib/epsonscan2
+
+.include <bsd.port.mk>
diff --git a/graphics/epsonscan2/distinfo b/graphics/epsonscan2/distinfo
new file mode 100644
index 000000000000..29a2e52cc255
--- /dev/null
+++ b/graphics/epsonscan2/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1642131410
+SHA256 (epsonscan2-6.6.40.0-1.src.tar.gz) = 07aa21eab09e945cadddcbef102caa1e42390ab52cc49a2c00e911e3a3340923
+SIZE (epsonscan2-6.6.40.0-1.src.tar.gz) = 2289979
diff --git a/graphics/epsonscan2/files/Read_me.FreeBSD.in b/graphics/epsonscan2/files/Read_me.FreeBSD.in
new file mode 100644
index 000000000000..a12d2ba98a87
--- /dev/null
+++ b/graphics/epsonscan2/files/Read_me.FreeBSD.in
@@ -0,0 +1,633 @@
+The FreeBSD port of the Seiko/Epson epsonscan2 driver is mostly working.
+Some bugs present in the Linux version have been found and fixed here in
+this version.
+
+There are two ports:
+	graphics/epsonscan2	Native FreeBSD port of the Epson
+				scanner engine and the GUI front-end.
+				This supports scanners connected via
+				USB cable.
+
+	graphics/epsonscan2-non-free-plugin
+				Port of the Linux binary that supports
+				scanner access over networks as well as
+				USB access to some older scanner models.
+				This port requires the kernel Linux
+				emulator modules as well as the userland
+				Linux libraries.
+
+The epsonscan2 package provides support for a variety of Seiko/Epson
+scanners.  The specific model names are stored as hashed strings in the
+driver and there does not appear to be a text file listing the supported
+models, so it is not possible to know what they all are!  However, the
+driver does include the USB product ID codes that it supports.  A full
+list of these USB product ID codes is included at the end of this file.
+
+The epsonscan2 package provides a complete alternative to the usual
+sane/xsane way of doing things.  The epsonscan2 command provides both a
+full GUI interface as well as a command line interface to the scanner.
+
+There is also a libsane-epsonscan2.so back-end for sane, and it does
+work, but requires some manual configuration first.
+
+The epsonscan2 package only works with scanners connected via USB cable,
+but not even all USB scanners.  Some older models also require the
+non-free-plugin port for USB access.  See the list of USB product IDs
+at the end of this file for which models also require the non-free-plugin
+for USB access.
+
+To access a network-connected scanner, the es2netif binary in the
+epsonscan2-non-free-plugin port is also required.  As mentioned, some
+older models require the es2intif binary from this port for USB access.
+es2netif and es2intif are Linux binaries that interface between the
+epsonscan2 driver and the scanner.  es2netif is a program that talks
+to a scanner over network sockets and works well.  es2intif appears
+to provide support for firmware downloads to the scanner device over
+USB and may not be fully working at this time.  These binaries require
+the kernel Linux emulator modules and the Linux userland support in
+emulators/linux_base-c7.  The kernel Linux modules include:
+	linux.ko
+	linux64.ko
+	linux_common.ko
+	linprocfs.ko
+	linsysfs.ko
+	fdescfs.ko
+	pty.ko
+
+Epson provides additional web documentation for epsonscan2 at this URL:
+	https://download.ebz.epson.net/man/linux/epsonscan2_e.html
+
+
+SYSTEM CONFIGURATION
+
+To access a USB scanner as a non-root user, you will need to ensure
+that the USB devices are readable.  Configure as follows:
+In /etc/rc.conf:
+	devfs_system_ruleset="system"
+	devfs_set_rulesets="%%LINUXBASE%%/dev=system"
+In /etc/devfs.rules:
+	[system=5]
+	add path 'usb' mode 0755
+	add path 'usb/*' mode 0666
+	add path 'ugen*' mode 0666
+	add path 'usbctl' mode 0666
+
+
+DETECTING SCANNERS
+
+You can run:
+	epsonscan2 -l
+to list discovered scanners.
+
+If your USB scanner is not found, make sure that it is displayed when
+you run:
+	usbconfig dump_device_desc
+and that its vendorID and productID are on the list at the bottom of
+this file.
+
+If your network scanner is not found, make sure that it is configured
+with an IPv4 address (the epsonscan2 driver ignores IPv6 scanners).
+Also make sure that the scanner has mDNS/Bonjour enabled and that when
+you run:
+	avahi-browse -at
+you can see the scanner with IPv4 in the domain _scanner._tcp.  If your
+scanner does not support the mDNS/Bonjour protocol, you can manually
+configure the scanner's IP address like this:
+	epsonscan2 -i ipv4.address
+
+
+SCANNING WITH THE EPSON GUI
+
+To use with the GUI front-end, just run:
+	 epsonscan2
+It will look for USB and network scanners and list them.  Choose the
+scanner you want and click Next.  The scanning menu will show, allowing
+you to set scanning parameters and acquire a preview or scan the image.
+
+NOTE again, that it might well detect network scanners without the
+non-free-module installed, but it will not talk to a network scanner
+without that module.
+
+
+SCANNING FROM THE COMMAND-LINE
+
+The command-line syntax is:
+	epsonscan2 -s ConfigFile.SF2
+
+This will initiate a scan based on the parameters in the configuration
+file and save the output where the config directs it.  A config file is
+created when you use the GUI; look for the file:
+	~/.epsonscan2/Settings/MODEL/UserSettings.SF2
+
+Alternatively, you can create a config file using:
+	epsonscan2 -c
+
+You must then edit the file and set at least the following parameters:
+	The JpegQuality values are in the range [0..100].  If set to 0,
+	no image will be produced:
+		JpegQuality:		30
+		JpegQualityForJpeg:	85
+		JpegQualityForPdf:	50
+	The Resolution is likely to include 75, 150, 200, 300, 600, 1200,
+	2400, 9600 but the values are device dependent:
+		Resolution:		200
+	The ScanArea defines where is scanned.  It is the page size in
+	inches multiplied by the Resolution value:
+		ScanAreaHeight:		2200
+		ScanAreaWidth:		1700
+	Threshold must also be set:
+		Threshold:		110
+
+NOTE: If Resolution is left at 0, epsonscan2 -s will likely core dump
+      with a floating point exception!
+
+
+SCANNING WITH SANE
+
+The epsonscan2 package includes a libsane-epsonscan2.so backend.
+
+The port creates a sane config file in:
+	%%PREFIX/etc/sane.d/dll.d/epsonscan2
+but this does not seem to do anything on FreeBSD.  You must also edit
+the file:
+	%%PREFIX/etc/sane.d/dll.conf
+and add:
+	epsonscan2
+to that file.  To speed device searches up, you can also comment out all
+the ones you are not using.
+
+For a USB scanner, you do not need this next part.  For a network scanner,
+you do.  The libsane-epsonscan2.so module does not use the main epsonscan2
+code that finds network scanners using the mDNS/Bonjour protocol.  Instead,
+it uses a static hint file telling it where to find network scanners.  It
+will not find network scanners without this file.  Create the hint file
+using:
+	epsonscan2 -i ipv4.address
+or edit:
+	~/.epsonscan2/Network/epsonscan2.conf
+and put in it:
+	[Network]
+	ipv4.address
+There can be multiple scanner ipv4.address entries, one per line.
+E.g.:
+	[Network]
+	192.168.3.30
+	192.168.4.17
+
+The libsane-epsonscan2.so backend uses a scanner configuration file in:
+	~/.epsonscan2/DefaultSettings.SF2
+
+If you have already scanned using epsonscan2, there will be a config
+file in:
+	~/.epsonscan2/Settings/MODEL/UserSettings.SF2
+Copy or link this file to the DefaultSettings.SF2 path above.  Or,
+create a new file using "epsonscan2 -c", adjust its parameter values as
+described above, and put the file in the DefaultSettings.SF2 path.
+
+Then, scanimage should work:
+	Try:
+		scanimage -o foo.pnm
+		scanimage --mode Color -o foo.pnm
+	For A4 paper size:
+		scanimage --mode Color --scan-area A4 -o foo.pnm
+		scanimage --mode Color -x 210 -y 297 -o foo.pnm
+	For US Letter paper size:
+		scanimage --mode Color --scan-area Letter -o foo.pnm
+		scanimage --mode Color -x 215.9 -y 279.4 -o foo.pnm
+
+
+SCANNING WITH XSANE
+
+This doesn't work.  See KNOWN PROBLEMS, below.
+
+
+COMMON PROBLEMS
+
+Read the sections above for fuller details on each of these.
+
+0. The scanner is not found.
+	If the scanner is connected bu USB cable, run:
+		usbconfig dump_device_desc
+	The following values are supported by this driver:
+		idVendor = 0x04b8 
+		idProduct = (see list at end of this file)
+
+	If the scanner is connected by Ethernet or WiFi, and for some
+	older USB models, the graphics/epsonscan2-non-free-plugin
+	port must also be installed and the kernel Linux support must
+	be enabled (see above).
+
+1. epsonscan2 -s scans but the "img.pdf" file contains a blank image.
+	Make sure that the config file contains valid settings e.g.:
+		JpegQuality:		30
+		JpegQualityForJpeg:	85
+		JpegQualityForPdf:	50
+		Resolution:		200
+		ScanAreaHeight:		2200
+		ScanAreaWidth:		1700
+		Threshold:		110
+
+2. epsonscan2 -s scans but does not save the file.
+	Make sure that the config file contains valid settings for:
+		FileNameOverwrite:	"0" to use sequential file
+					names, "1" to use the same
+					filename each time
+		FileNamePrefix:		any file name; a number will
+					be appended if FileNameOverwrite
+					is set to "0"
+		UserDefinePath:		"./" for the current directory
+
+3. epsonscan2 -s scans then says "Not enough memory".
+	Various things can cause this.  Usually the problem is an
+	excessively large scan area or too large values for the image
+	enhancer.  Check the following in your config file:
+		Resolution:		200
+		ScanAreaHeight:		2200
+		ScanAreaWidth:		1700
+		Threshold:		110
+		textEnhance		0
+		textEnhanceNoiseReductionLevel	0
+		textEnhancePaperCreaseReduction	0
+		textEnhanceSensitivity	0
+		thresholdAdjustment	0
+
+4. epsonscan2 works with USB scanners but not with network scanners.
+	Make sure that:
+	a.  You have the non-free-plugin port installed and the kernel
+	    Linux emulator enabled.
+
+5. epsonscan2 scans but then prints:
+	ERROR : Unable to save scanned files.
+	/tmp/epsonWork/_12345/: No such file or directory
+	Make sure that:
+	a.  The working dir, /tmp/epsonWork is writable by the user
+	    running the scan.
+
+6. scanimage works with USB scanners but not with network scanners.
+	Make sure that:
+	a.  You have the non-free-plugin port installed and the kernel
+	    Linux emulator enabled.
+	b.  You added the network scanner's IPv4 address to the file:
+		~/.epsonscan2/Networks/epsonscan2.conf
+
+7. scanimage scans but the image is in reverse video.
+	Specifiy the scan mode using any of:
+		scanimage --mode Monochrome ...
+		scanimage --mode Grayscale ...
+		scanimage --mode Color ...
+
+KNOWN PROBLEMS
+
+There are two known problems on FreeBSD at the moment:
+
+0.  es2intif core dumps.
+	The older scanners that require the es2intif program require a
+	small patch to the linux_libusb code.  Make sure that you have
+	port devel/linux_libusb-13.1.0 or later and a 13.x or 14.x kernel
+	newer than 2022/03/05.
+
+1.  xsane scans but then core dumps.
+	This isn't working.  This appears to be a bug in xsane.  After
+	receiving the image data, xsane processes the image in
+	xsane_read_image_data() which calls xsane_progress_update() to
+	update a progress bar widget.  It core dumps when calling
+	gtk_main_iteration() from that!  Since the xsane port on FreeBSD
+	is unmaintained, this won't get fixed until someone decides to
+	take a look at it.
+
+Good luck!
+
+
+DEBUGGING
+
+The epsonscan2 driver provides a debugging trace if the directory:
+	/tmp/epson
+exists.  It also saves various files in that directory too.
+
+The sane backend component provides a debugging trace by setting the
+following environment variable:
+	export SANE_DEBUG_EPSONSCAN=IMG
+	scanimage -L
+
+The xsane program can be debugged by setting the environment variable:
+	export XSANE_DEBUG=99
+	xsane
+
+
+LIST OF SUPPORTED USB PRODUCT IDs
+
+The following USB product IDs are supported by the epsonscan2 driver.
+Descriptons have been added where they can be determined.
+
+[*] Models with the [*] require the non-free-plugin port even for USB
+    access.
+
+USB
+Vendor ID	Description
+0x04B8		Seiko/Epson Corporation
+
+Product ID	Description
+0x0023
+0x0024
+0x0129		ES-10000G [Expression 10000XL]
+0x012B		ES-H300 [GT-2500]
+0x012C		GT-X900 [Perfection V700/V750 Photo]
+0x0130		GT-X770 [Perfection V500]
+0x0133		GT-1500 [GT-D1000]
+0x0135		GT-X970
+0x0136		ES-D400 [GT-S80]
+0x0137		ES-D200 [GT-S50]
+0x0138		ES-H7200 [GT-20000]
+0x013A	[*]	GT-X820 [Perfection V600 Photo]
+0x013B	[*]
+0x013C	[*]
+0x013D	[*]
+0x0142	[*]	GT-F730 [GT-S630/Perfection V33/V330 Photo]
+0x0143		GT-S55
+0x0144		GT-S85
+0x0145
+0x0146
+0x0147
+0x014A	[*]
+0x014B
+0x014C
+0x014D
+0x0150
+0x0151		Perfection V800 Photo
+0x0152
+0x0153
+0x0154
+0x0155
+0x0156
+0x0157
+0x0159
+0x015A
+0x015B
+0x015C
+0x015D
+0x015E
+0x015F
+0x0160
+0x0162
+0x0163
+0x0164
+0x0165
+0x0166
+0x0167
+0x0168
+0x0169
+0x016B
+0x016C
+0x016D
+0x016E
+0x016F
+0x0170
+0x0171
+0x0172
+0x0173
+0x0176
+0x0177
+0x0178
+0x0179
+0x017A
+0x017B
+0x017C
+0x017D
+0x017E
+0x017F
+0x0180
+0x0181
+0x0182
+0x0183
+0x0184
+0x0185
+0x0186
+0x0187
+0x0188
+0x0189
+0x018A
+0x018B
+0x018C
+0x018D
+0x018E
+0x018F
+0x0190
+0x0191
+0x0192
+0x0869		PX-1600F
+0x0879		EP-904A/EP-904F [Artisan 837/Stylus Photo PX830FWD Series]
+0x087B		EP-804A/EP-804AR/EP-804AW [Stylus Photo PX730WD/Artisan 730 Series]
+0x087C		PX-1700F
+0x087D		PX-B750F/WP-4525 Series
+0x0899
+0x08A5
+0x08A9
+0x08AA
+0x08AC
+0x08AD
+0x08AE
+0x08AF
+0x08B0
+0x08B3
+0x08B4
+0x08B5
+0x08B6
+0x08B7
+0x08B8
+0x08B9
+0x08BC
+0x08BD
+0x08BE
+0x08BF
+0x08C0
+0x08C1
+0x08C2
+0x08C3
+0x08C4
+0x08C5
+0x08C6
+0x08C7
+0x08C8
+0x08C9
+0x08CA
+0x08CC
+0x08CD
+0x08CE
+0x08CF
+0x08D0
+0x08D1
+0x08D2
+0x08D3
+0x1101
+0x1102
+0x1103
+0x1104
+0x1105
+0x1106
+0x1107
+0x1108
+0x1109
+0x110A
+0x110B
+0x110C
+0x110D
+0x110F
+0x1111
+0x1112
+0x1113
+0x1114		XP-440 [Expression Home Small-in-One Printer]
+0x1115
+0x1116
+0x1117
+0x1118
+0x1119
+0x111A
+0x111B
+0x111C
+0x111D
+0x111E
+0x111F
+0x1120
+0x1121
+0x1122
+0x1123
+0x1125
+0x1126
+0x1127
+0x1128
*** 3289 LINES SKIPPED ***