Bug 261891 - [NEW PORT] graphics/epsonscan2: scanner engine supporting many Seiko/Epson scanners
Summary: [NEW PORT] graphics/epsonscan2: scanner engine supporting many Seiko/Epson sc...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Rainer Hurling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-11 19:09 UTC by J.R. Oldroyd
Modified: 2022-04-03 08:50 UTC (History)
4 users (show)

See Also:


Attachments
shar of graphics/epsonscan2 (158.34 KB, text/plain)
2022-02-11 19:10 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (50.04 KB, text/plain)
2022-02-11 19:11 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (5.99 KB, text/plain)
2022-02-15 14:25 UTC, J.R. Oldroyd
no flags Details
shar of graphics/epsonscan2-non-free-plugin (6.61 KB, text/plain)
2022-02-15 15:19 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (6.67 KB, text/plain)
2022-02-15 18:03 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (7.09 KB, text/plain)
2022-02-15 19:25 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2 (160.57 KB, text/plain)
2022-02-16 21:27 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (7.01 KB, text/plain)
2022-02-16 21:28 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2 (167.15 KB, text/plain)
2022-02-17 20:03 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (6.98 KB, text/plain)
2022-02-17 20:04 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2 (167.80 KB, text/plain)
2022-02-28 15:06 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (10.98 KB, text/plain)
2022-02-28 15:07 UTC, J.R. Oldroyd
no flags Details
shar of graphics/epsonscan2 (167.80 KB, text/plain)
2022-03-02 14:48 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (10.99 KB, text/plain)
2022-03-02 14:48 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2 (167.79 KB, text/plain)
2022-03-02 14:54 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2 (170.21 KB, text/plain)
2022-03-21 13:34 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details
shar of graphics/epsonscan2-non-free-plugin (11.32 KB, text/plain)
2022-03-21 13:34 UTC, J.R. Oldroyd
fbsd: maintainer-approval+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description J.R. Oldroyd 2022-02-11 19:09:36 UTC
This is a port of the Seiko/Epson Epsonscan2 scanner engine and GUI.

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 USB scanners
    - graphics/epsonscan2-non-free-plugin - support for Epson's Linux binary that adds network access to scanners

Please read the file %%PREFIX%%/lib/epsonscan2/Read_me.FreeBSD for notes on how to set this up and use it.
Comment 1 J.R. Oldroyd 2022-02-11 19:10:33 UTC
Created attachment 231759 [details]
shar of graphics/epsonscan2

This is the main scanner engine and GUI.
Comment 2 J.R. Oldroyd 2022-02-11 19:11:33 UTC
Created attachment 231760 [details]
shar of graphics/epsonscan2-non-free-plugin

This is the Linux binary that adds access to scanners over the network.
Comment 3 J.R. Oldroyd 2022-02-11 19:14:49 UTC
Notes to committer:

1. The dependencies may need some additions.  Please add as needed.

2. The graphics/epsonscan2-non-free-plugin uses a proprietary license.  I have listed the LICENSE_PERMS that I think it allows, but feel free to add or remove any as appropriate.

Thanks.
Comment 4 J.R. Oldroyd 2022-02-11 19:43:26 UTC
I have attempted to contact upstream (Epson Japan) to see if they'll incorporate the many patches into their code.  Not holding my breath on this one, but I will be pleasantly surprised if they do.
Comment 5 Rainer Hurling freebsd_committer freebsd_triage 2022-02-12 17:59:49 UTC
I tried your patch with a 'Perfection V600/GT-X820' on USB. 

To use it as a non-root user, I had to add the following lines in /etc/devfs.rules and restart the service (perhaps a hint in 'Read_me.FreeBSD'?):

[system=5]
add path 'ugen2.2' mode 0660 group usb
add path 'usb/2.2.0' mode 0666 group usb



While 'epsonscan2 -l' works as expected, other commands (on command line and in gui) core dump:

#epsonscan2 -c
Assertion failed: (un32BasicResolution > 0), function GetMaxScanSize, file /usr/ports/graphics/epsonscan2/work/epsonscan2-6.6.40.0-1/src/ES2Command/Src/Command/ESCI/ESCIAccessor.cpp, line 1128.



BTW, it seems devel/boost-libs should also be a dependency:

--- Makefile	2022-02-12 17:40:51.185262000 +0100
+++ /usr/ports/graphics/epsonscan2/Makefile	2022-02-12 17:45:35.026525000 +0100
@@ -12,7 +12,8 @@
 LICENSE=	GPLv3
 
 BUILD_DEPENDS=	sane-config:graphics/sane-backends
-LIB_DEPENDS=	libdouble-conversion.so:devel/double-conversion \
+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 \
Comment 6 J.R. Oldroyd 2022-02-14 19:50:28 UTC
Okay on the devfs suggestion and the extra dependency.

As for the core dump, my own scanner uses the ESCI2 interface code while this one is using the ESCI code, which explains why I do not experience this core dump.

The core dump is due to an assertion failure due to Resolution being 0.  The value for Resolution should have been obtained from the device.  Please turn on the execution trace log (do that by creating the empty directory /tmp/epson) and run the command again.  You should see the command going to the device and the values of the data being read back.  If not, you may have to add some additional debug output.

I have sent email with additional details of the call sequence here.
Comment 7 Tatsuki Makino 2022-02-14 22:10:20 UTC
I don't know much about it, so I'm not in a position to point it out to others... :)
However.

I think the EPSON license needs to be limited to about the print/epson-inkjet-printer-escpr2 port.

Then, since the FreeBSD Linuxulator is CentOS, I feel it is better to use rpm rather than deb.
Comment 8 J.R. Oldroyd 2022-02-15 00:58:46 UTC
Thanks for pointing out the EPSON license in the print/epson-inkjet-printer-escpr2 port.  I shall rename the license here to EPSON_END_USER and I'll make the permissions the same as for the EPSON license in the print port.  Can anyone comment on if it is okay to keep the "auto-accept" or does the user have to be prompted to accept it?

Re the format, the non-free-plugin download file is a .tar file that contains the .deb ar archive that contains another .tar.xz.  I do not see any .rpm anywhere.
Comment 9 Tatsuki Makino 2022-02-15 03:39:59 UTC
(In reply to J.R. Oldroyd from comment #8)

LICENSE_NAME_EPSON in print/epson-inkjet-printer-escpr2 is wrong :)
EPSON EULA for epson-inkjet-printer-escpr2 is the same as for epsonscan2.

As a basis for LICENSE_PERMS_EPSON in print/epson-inkjet-printer-escpr2, I believe that 3. and 10. of COPYING.EPSON is applicable.
no-*-sell will be needed to prevent it from getting into the optical discs sold on https://www.freebsdmall.com/ .
And I didn't include "auto-accept" because by the time we get to these distribution files from the download center, we are forced to click a button to accept the license.

rpm version can be found in the download center, which will take you to a page for downloading.
To make it easier, I think you can download it by simply rewriting the 2 deb parts of the URL to rpm :)

There are other ARCH-related conditional branches that will be needed.
Comment 10 J.R. Oldroyd 2022-02-15 14:25:13 UTC
Created attachment 231838 [details]
shar of graphics/epsonscan2-non-free-plugin

Thanks for the pointers for the other download formats for the non-free-plugin.  I have now found the top-level EPSON download page for these files.

I have updated the port to use the rpm, and I have added initial support for the i386 and arm architectures.  However, I am not able to test those.

The install rules and the pkg-plist are updated for the amd64 architecture but they are almost certainly incorrect for the i386 and arm architectures.

It may make sense at this point for someone with knowledge of how to support a multi-architecture port like this and who has a full port testing environment to take this over from me as I have limited time to get myself up to speed on all the details needed here.  But if no one volunteers, I will accept patches needed to fix the install rules and pkg-plist for i386 and arm.
Comment 11 J.R. Oldroyd 2022-02-15 15:19:25 UTC
Created attachment 231839 [details]
shar of graphics/epsonscan2-non-free-plugin

Further update to _2 revision.

Looks like I have figured out the architecture-dependent extract and install rules.

And it appears that the plist is identical for all three architectures, so no changes are needed there.
Comment 12 J.R. Oldroyd 2022-02-15 18:03:31 UTC
Created attachment 231843 [details]
shar of graphics/epsonscan2-non-free-plugin

Further update to the non-free-plugin to revision 3.

This adds an additional run-time dependency on devel/linux_libusb which is needed for the es2intif program to run.

The es2intif program is apparently needed for USB access to some scanner models, such as Rainer's GT-X820.  This means that enabling Linux emulation will be needed for some USB scanners too.
Comment 13 Rainer Hurling freebsd_committer freebsd_triage 2022-02-15 18:16:47 UTC
(In reply to J.R. Oldroyd from comment #12)

Does this mean that I also need to install the graphics/epsonscan2-non-free-plugin port in order to use the GT-X820 scanner connected via USB?
Comment 14 J.R. Oldroyd 2022-02-15 18:35:37 UTC
Yes, apparently that is the case.

I replied to your email earlier.  Your scanner is looking for the es2intif program which is part of the non-free-plugin port and which requires the kernel Linux emulation.

Now, my scanner (the ST-3000) is working just fine over USB without this program.  When I run with the debug trace enabled, there is no attempt to run es2intif here.  

Looking at the Resources files, some models have an InterpreterName set to some variation of "esint##.dll" which, I guess, means it needs the es2intif program.  The USB productIDs that have this are:

0x0130
0x0133
0x0136
0x0137
0x013A
0x013B
0x013C
0x013D
0x0142
0x0143
0x0144
0x0147
0x014A
0x0151
0x0153

So it would seem that, for these models, the non-free-plugin is also required for USB access.
Comment 15 Rainer Hurling freebsd_committer freebsd_triage 2022-02-15 19:13:05 UTC
(In reply to J.R. Oldroyd from comment #14)

Thanks for clarification. Yes, I got private mail at the same time, thanks.

When I try to extract the shar file, I get the following message:

sh 261891/231843-epsonscan2-non-free-plugin-1.0.0.5_3.shar
x - graphics/epsonscan2-non-free-plugin/Makefile
261891/231843-epsonscan2-non-free-plugin-1.0.0.5_3.shar: cannot create graphics/epsonscan2-non-free-plugin/Makefile: No such file or directory
x - graphics/epsonscan2-non-free-plugin/distinfo
261891/231843-epsonscan2-non-free-plugin-1.0.0.5_3.shar: cannot create graphics/epsonscan2-non-free-plugin/distinfo: No such file or directory
x - graphics/epsonscan2-non-free-plugin/files/pkg-message.in
261891/231843-epsonscan2-non-free-plugin-1.0.0.5_3.shar: cannot create graphics/epsonscan2-non-free-plugin/files/pkg-message.in: No such file or directory
x - graphics/epsonscan2-non-free-plugin/pkg-descr
261891/231843-epsonscan2-non-free-plugin-1.0.0.5_3.shar: cannot create graphics/epsonscan2-non-free-plugin/pkg-descr: No such file or directory
x - graphics/epsonscan2-non-free-plugin/pkg-plist
261891/231843-epsonscan2-non-free-plugin-1.0.0.5_3.shar: cannot create graphics/epsonscan2-non-free-plugin/pkg-plist: No such file or directory


It seems, the shar file is somewhat broken? BTW, it would be much more easier to create the port from a git diff ;)
Comment 16 J.R. Oldroyd 2022-02-15 19:25:48 UTC
Created attachment 231846 [details]
shar of graphics/epsonscan2-non-free-plugin

Oops, the shar file was indeed missing the directories.  I've uploaded a replacement.

Using shar files for an initial port has for years been the way to do it, and the Porter's Handbook still lists .shar files as an acceptable alternative.
Comment 17 Rainer Hurling freebsd_committer freebsd_triage 2022-02-15 20:11:27 UTC
(In reply to J.R. Oldroyd from comment #16)
> Oops, the shar file was indeed missing the directories. 
> I've uploaded a replacement.

Thanks for the fast correction. I am experimenting with the port now.

> Using shar files for an initial port has for years been
> the way to do it, and the Porter's Handbook still lists
> .shar files as an acceptable alternative.

Yes, of course it is. Handling with git diffs is somewhat more easy and straightforward on boxes like mine ;)
Comment 18 J.R. Oldroyd 2022-02-15 20:37:19 UTC
Looking at the code in src/Controller/Src/Scanner/Scanner.cpp, it seems that the list of scanners that need the es2intif program is shorter than the list I gave above.  Just these:

0x013A
0x013B
0x013C
0x013D
0x0142
0x014A

I will update the Read_me.FreeBSD file to note that the non-free-plugin port is needed for these scanner models, even for USB.
Comment 19 Tatsuki Makino 2022-02-16 01:13:06 UTC
(In reply to J.R. Oldroyd from comment #10)
> LICENSE=	EPSON_EULA

The name of this EPSON_EULA has to be shared somewhere.
I and someport maintainers have already used the license_name EPSON in print/epson-inkjet-printer-escpr2 and print/epson-inkjet-printer-*.
Some users may have added LICENSES_ACCEPTED=EPSON to /etc/make.conf to skip this license check.
Comment 20 J.R. Oldroyd 2022-02-16 02:17:09 UTC
(In reply to Tatsuki Makino from comment #19)

Okay, I have changed the name back to EPSON to be the same as the others.  You will see that in the number 4 revision.
Comment 21 Daniel Engberg freebsd_committer freebsd_triage 2022-02-16 18:45:02 UTC
A few suggestions and questions for graphics/epsonscan2

While there's nothing wrong Porters Handbook recommends you to use DISTVERSION unless the framework can't determine version on its own.

Ref: "3.1. Writing the Makefile" and "Table 2. Package Naming Examples"
https://docs.freebsd.org/en/books/porters-handbook/book/

Please define LICENSE_FILE
Reference: https://docs.freebsd.org/en/books/porters-handbook/makefiles/index.html#licenses-license_file

Is it correct what we need both pcre and pcre2?

Please define gettext-runtime dependency via USES=
https://cgit.freebsd.org/ports/tree/Mk/Uses/gettext-runtime.mk
Ref: https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-gettext-runtime

Please define glib dependency using USES and USE_GNOME
Example: https://cgit.freebsd.org/ports/tree/irc/irssi/Makefile#n14
Reference: https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-gnome

USES= for JPEG --> https://cgit.freebsd.org/ports/tree/Mk/Uses/jpeg.mk
Not sure why it's missing in Porters Handbook

CFLAGS --> USES= localbase
https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-localbase
Ref: https://cgit.freebsd.org/ports/tree/Mk/Uses/localbase.mk

LDFLAGS should probably be added?
"6.3. Shared Libraries" in Porters Handbook

%%DOCSDIR%%-1.0.0.0-1/ looks like a strange path

Great work!

Best regards,
Daniel
Comment 22 J.R. Oldroyd 2022-02-16 21:22:42 UTC
(In reply to Daniel Engberg from comment #21)

Thanks for all the pointers and references to the doc and examples.

I have changed PORTVERSION to DISTVERSION.
I have added LICENSE_FILE.

Re pcre:
$ ldd /usr/local/bin/epsonscan2 | grep pcre
        libpcre2-16.so.0 => /usr/local/lib/libpcre2-16.so.0 (0x802388000)
        libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x80281e000)
So, yes, I think we need both here.

Added to USES: gettext-runtime gnome jpeg localbase

Added USE_GNOME=glib20

Removed the libjpeg-turbo dependency since USES=jpeg handles it.

If LDFLAGS is needed, I'm unclear what to put there as it works for me without.  Please send explicit value.

Re DOCSDIR, the upstream installs docs to that path.  I will remove the "-1.0.0.0-1" before installing.

I have made similar changes to DISTVERSION and DOCSDIR in the non-free-plugin too.  I also fixed the version numbers in the non-free-plugin so that the 6.6.40.0 appears in the port and the EPSON version is 1.0.0.5.  (I had these the other way round in this port before.)

I'll upload new versions of both in a short while.

I am still working with Rainer on the problems accessing his scanner with the Linux binary es2intif.  It it starting to look like linux_libusb may not be talking to the device.  Fortunately, most supported scanners do not require this.  But it would be good to have that working too.
Comment 23 J.R. Oldroyd 2022-02-16 21:27:38 UTC
Created attachment 231876 [details]
shar of graphics/epsonscan2
Comment 24 J.R. Oldroyd 2022-02-16 21:28:08 UTC
Created attachment 231877 [details]
shar of graphics/epsonscan2-non-free-plugin
Comment 25 Daniel Engberg freebsd_committer freebsd_triage 2022-02-16 22:46:00 UTC
J.R. Oldroyd, I'm terribly sorry I meant USE_LDCONFIG not LDFLAGS (6.3. Shared Libraries) sorry for my brainfart. We can just make a note of it right now until the other issues(?) are fixed there's no need to refresh the patch.
Comment 26 Tatsuki Makino 2022-02-16 22:58:35 UTC
(In reply to J.R. Oldroyd from comment #24)

for graphics/epsonscan2-non-free-plugin:

I think it's better to use epsonscan2-bundle instead of epsonscan2-non-free-plugin for the PORTNAME to avoid problems later.

When using linux compatibility, use USES=linux instead of *_DEPENDS=.
When other required libraries that are defined in /usr/ports/Mk/Uses/linux.mk are used, use USE_LINUX=. However, this is not the case for linux_libusb.

${ARCH} and some variables are defined after .include <bsd.port.options.mk> or .include <bsd.port.pre.mk>.
For example:
PORTNAME= epsonscan2...
.include <bsd.port.options.mk>
.if ${ARCH} == amd64
FOR_AMD64_FOOBAR= foo
.endif
.include <bsd.port.mk>

For the post-extract target, in the case of porting epson-inkjet-printer-escpr2, I copied the commands for the do-extract target in /usr/ports/Mk/bsd.port.mk.
I don't think it's necessary to delete files scattered around WRKDIR here, unless there are duplicate names.
For the do-install target, I also copied the one in /usr/ports/Mk/Uses/linux.mk.
I think it's easier to see what will happen that way.

If poudriere, etc. are stopped by a license that is not automatically accepted, put the following in /usr/local/etc/poudriere.d/make.conf and it will go through everything :)

LICENSES_ACCEPTED= ${LICENSE}
Comment 27 J.R. Oldroyd 2022-02-17 15:07:57 UTC
(In reply to Tatsuki Makino from comment #26)

I used "epsonscan2-non-free-plugin" as the second port name to be compatible with the Linux version.  This is how Epson refers to it.  See also Epson's web-manpage which I just discovered here and which refers to this name:
    https://download.ebz.epson.net/man/linux/epsonscan2_e.html

I have added this web-manpage URL to the pkg-descr in epsonscan2 and also to my Read_me.FreeBSD file.

In non-free-plugin, I have replaced the linux dependency with a USES=linux but left the linux_libusb dependency there.

I have added the <bsd.port.pre.mk> and simplified the ARCH handling by removing my own ARCH setting, by adding an extra LINUX_LIB variable and then using the same do-install rules for all architectures.

For now I have left the ${RM} commands in the post-extract as I prefer to keep things cleaned up after use.  But if it is important, we can remove those later.

To Daniel, I have also added USE_LDCONFIG to both ports now.

***

Rainer emailed that he is out for a bit yesterday and today, but he'll resume feedback once he returns.  I have sent him additional debug patches regarding es2intif.
Comment 28 J.R. Oldroyd 2022-02-17 20:03:29 UTC
Created attachment 231905 [details]
shar of graphics/epsonscan2

As well as the changes discussed above, I have also added four additional patches to the code to clear deprecation warnings.  There are still a couple left, but I am not sure what to change to clear those.
Comment 29 J.R. Oldroyd 2022-02-17 20:04:17 UTC
Created attachment 231906 [details]
shar of graphics/epsonscan2-non-free-plugin

Port Makefile clean-ups as discussed above.
Comment 30 Tatsuki Makino 2022-02-18 05:11:21 UTC
(In reply to J.R. Oldroyd from comment #29)

for graphics/epsonscan2-non-free-plugin:
PORTREVISION is not yet required.
For maintainers like us, most of the work related to bumping PORTREVISION can be left to the committer :)

There are separate values for DISTFILES for each architecture.
In this case... ...?

MASTER_SITES= https:// download2.ebz.epson.net/ epsonscan2/common/deb/arm/:aarch64 \
    https:// download2.ebz.epson.net/ epsonscan2/common/rpm/x64/:amd64 \
    https:// download2.ebz.epson.net/ epsonscan2/common/rpm/x86/:i386
DISTNAME= ${PORTNAME:S/-non-free-plugin//}-bundle-${DISTVERSION}
EXTRACT_SUFX= .tar.gz # is default value defined in bsd.port.mk
DISTFILES_aarch64= ${DISTNAME}.armv7l.deb${EXTRACT_SUFX}:aarch64
DISTFILES_amd64= ${DISTNAME}.x86_64.rpm${EXTRACT_SUFX}:amd64
DISTFILES_i386= ${DISTNAME}.i686.rpm${EXTRACT_SUFX}:i386

DISTFILES_* must match ${ARCH}.
The :fooarch suffix in MASTER_SITES and DISTFILES_* is my own named suffix. There is no specific name given for it.
If this is adopted, it may be better to set WRKSRC to some other value.

DOCSDIR in PLIST_SUB is present by default.
I think it is better to use the following post-install to install the document.
Just define the files to be installed in the PORTDOCS value, and adding them to the plist is automatic.
It seems that bsd.options.mk automatically adds PORTDOCS for PLIST_SUB.
post-install:
        ${MKDIR} ${STAGEDIR}${DOCSDIR}
        cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${STAGEDIR}${DOCSDIR}

If you like something, please refer to it :)
Comment 31 J.R. Oldroyd 2022-02-19 13:18:33 UTC
(In reply to Tatsuki Makino from comment #30)

Arigato Tatsuki-san for all these suggestions.  I have incorporated them in the next version, but with some changes.

You missed the "-raspbian" in the arm distfile name.  I also found that, since I need to alter the distfile names for the extract and install rules, I still need to keep things like "x86_64" and "i686" in parameter variables rather than explicitly in the DISTFILE variables.

Understood that PORTREVISION is not needed yet, but I am using it here on three test systems (e.g., with USB, over the net, etc) and also with Rainer who is still testing, and it is helpful for us to see which test version is installed where.  I expect the committer will remove it when we get to that point.

Re the ":archname" names, I've used your "aarch64" for now, but the Linux code uses "armv7", so should we perhaps be using "armv7" here too?  I am not familiar with the distinction between these arm architectures.

I am not sure what you mean about setting WRKSRC to some other value?

I have removed the PLIST_SUB from this Makefile, it isn't needed at all.

I have changed the do-install rule completely because, in testing with Rainer, we discovered that the es2intif program needs additional shared libs which I had previously installed in the FreeBSD dirs, but which need to be in the Linux dirs.  Rainer is testing that again now, so I will delay uploading this latest version until he reports back.
Comment 32 J.R. Oldroyd 2022-02-19 13:29:36 UTC
A separate question...

I have not been able to get scanning with xsane to work.  Scanning with sane's scanimage does work, though.

In debugging, I see that when xsane runs, it does do the scan: the scanner activates and the image data is saved in the /tmp/epsonWork/_pid/ working directory.  But then libsane-epsonscan2.so tries to run an image-enhancer (/usr/local/lib/epsonscan2/ddeplugin) and ddeplugin wants an additional file "EsDDE.prm" which does not exist anywhere in the distribution files I have looked at, so ddeplugin fails.  I also cannot find EsDDE.prm anywhere by searching.

When sane's scanimage runs, also using libsane-epsonscan.so, it apparently does not run the ddeplugin image-enhancer.

Does anyone know how to tell xsane that the enchancer isn't needed?  I have played with the advanced settings in xsane >> Preferences >> Setup >> Enhancement (and other menus too, and also played with the settings in the ~/.sane/xsane/EPSON:networkscanner.drc file), but I have not yet found the knob that turns off the enhancer.

Or, does anyone know where I can find the EsDDE.prm file?
Comment 33 J.R. Oldroyd 2022-02-19 15:46:51 UTC
I also need guidance on where to install the Linux libraries used by the Linux binaries.

They are looking for "/usr/lib64/epsonscan2/foo/libbar.so" etc.  I tried installing them under "/compat/linux/usr/lib64/..." but they are not found.  I have also set USE_LDCONFIG to the paths in /compat/linux/... where the libraries are, but no help.

Am I supposed to just create "/usr/lib64/..." and put them there?

Or is there another mechanism, such as replacing the Linux binaries with wrapper scripts that sets LD_LIBRARY_PATH, then invokes the real binary?  Or something else?
Comment 34 J.R. Oldroyd 2022-02-19 21:59:02 UTC
(In reply to J.R. Oldroyd from comment #32)

The xsane problem appears to be a problem in xsane itself.  It is core dumping when attempting to update its progress bar widget during image processing.  Since the graphics/xsane port is unmaintained, this probably won't get fixed any time soon.

Fortunately, this port works with the epsonscan2 GUI, with the epsonscan2 command-line mode, and the sane/scanimage, so there are enough working alternatives.

As for ddeplugin and the missing EsDDE.prm file that I mentioned earlier, that problem may be moot as it appears that libsane-epsonscan2.so tries various filters and is working anyway.
Comment 35 J.R. Oldroyd 2022-02-19 22:01:02 UTC
(In reply to J.R. Oldroyd from comment #33)

Unless I hear otherwise, I have gone with replacing all the Linux binaries in the FreeBSD hierarchy with wrapper scripts that set LD_LIBRARY_PATH and then invoke the Linux binary from the Linux hierarchy.

The porter's handbook seems to suggest that approach.
Comment 36 Tatsuki Makino 2022-02-20 22:07:55 UTC
for graphics/epsonscan2-non-free-plugin:

(In reply to J.R. Oldroyd from comment #31)

:archname in MASTER_SITES and DISTFILE_* is just a label.
It is to pair the name of the distfile with the URL to download it. (5.4.9 in Porter's Handbook)
There is no specific explanation for DISTFILES_aarch64, but there is a branch on it in Mk/Uses/linux.mk.
${ARCH} contains the result of uname -p. FreeBSD for ARM seems to return the result "aarch64".
So, where ${ARCH} is used, it must be aarch64.

Other automatically defined values and their default values are described in Mk/bsd.port.mk.
We can use a command like "make -V WRKSRC" to see what values are in it.

(In reply to J.R. Oldroyd from comment #33)

Hmm, I don't really understand it :)
epson-inkjet-printer-escpr2 is working for the person who wanted to use it, so I am not involved any further :)

If we want executable-binary to use linux-shared-library, it does not matter where it is in the storage, but the brand of elf must be LINUX.
In other words, the binary compiled and linked for FreeBSD is not supposed to be able to use non-free plugin...maybe :)
It seems better to install non-free plug-ins, including core.

epson-inkjet-printer-escpr2 is just a filter to assemble the raster image, and CUPS will pass the rest to the printer device.
epsonscan2 looks like a binary trying to touch the scanner device directly.
I don't know if a Linux binary can directly touch FreeBSD devices.
Comment 37 J.R. Oldroyd 2022-02-20 22:34:23 UTC
(In reply to Tatsuki Makino from comment #36)

Re the choice of armv7 or aarch64, it seems that this Epson software is 32-bit arm, so I must use the FreeBSD name arm or armv7.  The FreeBSD names arm64 or aarch64 are 64-bit arm.  Epson does not provide a version for 64-bit arm.

Re the libraries, there are three parts to this.  epsonscan2 is a native FreeBSD binary.  It forks and execs a Linux binary, es2intif.  The Linux binary then loads Linux shared libraries.  With my wrapper script that sets LD_LIBRARY_PATH, this part is now all working.

We (Rainer and I) then spent some time this weekend with the Linux program not being able to open the USB devices, despite the /dev/usb/* nodes being mode 0666.  Eventually, we discovered the separate /compat/linux/dev/usb/* nodes which were not the right permission.  This is now solved and also working.

We are now looking into a firmware download problem for his scanner.  Hopefully that will also be resolved soon.

Progress is slow due to timezone differences.

Once we resolve the remaining problem(s) or hit a dead-end, I will upload the latest version of the port.
Comment 38 J.R. Oldroyd 2022-02-28 15:06:54 UTC
Created attachment 232161 [details]
shar of graphics/epsonscan2
Comment 39 J.R. Oldroyd 2022-02-28 15:07:20 UTC
Created attachment 232162 [details]
shar of graphics/epsonscan2-non-free-plugin
Comment 40 J.R. Oldroyd 2022-02-28 15:20:02 UTC
I have uploaded the latest versions of these ports.

What is working:
- Native FreeBSD scanner driver (GUI and command-line) for USB scanners not needing firmware support (which appears to be the majority of scanners).
- Linux back-end for network access to the same set of scanners.
- Also scanning via sane's scanimage program.

What is not working:
- A handful of scanners require a firmware download which is done using a separate Linux back-end program.  The firmware is there but fails to load in testing.
- Scanning using xsane.  For scanners that don't require firmware support, this does initiate the scan and send the image to the host, but then xsane core dumps when updating its Gtk progress bar widget!  Problem in xsane which is currently unmaintained.

There are 302 USB productIDs listed in the driver as supported.  Of these, just 6 appear to require firmware support.
Comment 41 J.R. Oldroyd 2022-03-01 19:50:02 UTC
(In reply to J.R. Oldroyd from comment #40)

Good news.

After applying a small patch to libsub thanks to Hans Petter Selasky, scanning is now also working on Rainer's scanner that uses the es2intif interface program.

So,

What is working:
- Native FreeBSD scanner driver (GUI and command-line) for USB scanners not needing firmware support (which appears to be the majority of scanners).
- Linux back-end for network access to the same set of scanners.
- Linux back-end for USB access to a small subset of the supported scanners.
- Also scanning via sane's scanimage program.

What is not working:
- Scanning using xsane.  This does initiate the scan and send the image to the host, but then xsane core dumps when updating its Gtk progress bar widget!  Problem in xsane which is currently unmaintained.

Of interest is that once the libusb patch was applied and the epsonscan2 driver was able to talk via the interface program to the scanner, it no longer attempts to download the firmware that it was attempting to download before.  Perhaps it talked to the device and determined this was not needed.
Comment 42 commit-hook freebsd_committer freebsd_triage 2022-03-02 11:35:36 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d94d94e2c06b4331f706a3b4eca058041294ea05

commit d94d94e2c06b4331f706a3b4eca058041294ea05
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-03-02 11:31:27 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-03-02 11:33:40 +0000

    libusb(3): Ignore SIGPIPE when initializing the LibUSB v1.0 API.

    The LibUSB v1.0 emulation layer uses pipes internally to signal between
    threads. When USB devices are reset, as part of loading firmware, SIGPIPE
    may happen, and that is expected and should be ignored.

    PR:             261891
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking

 lib/libusb/libusb10.c            | 3 +++
 lib/libusb/libusb_global_linux.h | 1 +
 2 files changed, 4 insertions(+)
Comment 43 commit-hook freebsd_committer freebsd_triage 2022-03-02 12:19:48 UTC
A commit in branch main references this bug:

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

commit a94c7f5fa71af60f923435f5faf98123a4d11a6a
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-03-02 12:18:00 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-03-02 12:18:57 +0000

    devel/linux_libusb: Update to version 13.1.0 .

    - Fixed issue with SIGPIPE
    - Moved sources to GitHUB

    PR:             261891
    Approved by:    pi (implicit)

 devel/linux_libusb/Makefile  | 36 +++++++-----------------------------
 devel/linux_libusb/distinfo  |  6 +++---
 devel/linux_libusb/pkg-descr | 14 ++++----------
 3 files changed, 14 insertions(+), 42 deletions(-)
Comment 44 J.R. Oldroyd 2022-03-02 14:48:25 UTC
Created attachment 232204 [details]
shar of graphics/epsonscan2
Comment 45 J.R. Oldroyd 2022-03-02 14:48:58 UTC
Created attachment 232205 [details]
shar of graphics/epsonscan2-non-free-plugin
Comment 46 J.R. Oldroyd 2022-03-02 14:53:21 UTC
I updated the epsonscan2-non-free-plugin port to refelect the dependency on linux_libusb>=13.1.0 and I also updated the Read_me file in the epsonscan2 port to simplify the notes regarding this.
Comment 47 J.R. Oldroyd 2022-03-02 14:54:50 UTC
Created attachment 232207 [details]
shar of graphics/epsonscan2
Comment 48 commit-hook freebsd_committer freebsd_triage 2022-03-05 14:41:27 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4340df3418ecea57b5e48dec94ac4b1d4f760aca

commit 4340df3418ecea57b5e48dec94ac4b1d4f760aca
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-03-02 11:31:27 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-03-05 14:40:08 +0000

    libusb(3): Ignore SIGPIPE when initializing the LibUSB v1.0 API.

    The LibUSB v1.0 emulation layer uses pipes internally to signal between
    threads. When USB devices are reset, as part of loading firmware, SIGPIPE
    may happen, and that is expected and should be ignored.

    PR:             261891
    Sponsored by:   NVIDIA Networking

    (cherry picked from commit d94d94e2c06b4331f706a3b4eca058041294ea05)

 lib/libusb/libusb10.c            | 3 +++
 lib/libusb/libusb_global_linux.h | 1 +
 2 files changed, 4 insertions(+)
Comment 49 J.R. Oldroyd 2022-03-21 13:34:20 UTC
Created attachment 232601 [details]
shar of graphics/epsonscan2

It has been a while since I uploaded the latest ports.

There has been some extensive testing in both native-USB, Linux-USB and network modes.

This has resulting in some additional patches as well as a number of clean-ups to the port files.
Comment 50 J.R. Oldroyd 2022-03-21 13:34:50 UTC
Created attachment 232602 [details]
shar of graphics/epsonscan2-non-free-plugin
Comment 51 commit-hook freebsd_committer freebsd_triage 2022-04-03 08:46:35 UTC
A commit in branch main references this bug:

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 (new) |  102 ++
 graphics/epsonscan2-non-free-plugin/distinfo (new) |    9 +
 .../files/ddeplugin.in (new)                       |   11 +
 .../files/dtrplugin.in (new)                       |   11 +
 .../files/es2intif.in (new)                        |   11 +
 .../files/es2netif.in (new)                        |   11 +
 .../files/fitplugin.in (new)                       |   11 +
 .../files/pkg-message.in (new)                     |   16 +
 .../epsonscan2-non-free-plugin/pkg-descr (new)     |    7 +
 .../epsonscan2-non-free-plugin/pkg-plist (new)     |   52 +
 graphics/epsonscan2/Makefile (new)                 |   53 +
 graphics/epsonscan2/distinfo (new)                 |    3 +
 graphics/epsonscan2/files/Read_me.FreeBSD.in (new) |  633 ++++++++
 .../epsonscan2/files/patch-CMakeLists.txt (new)    |   57 +
 .../files/patch-src_CommonUtility_DbgLog.cpp (new) |   21 +
 ...-src_CommonUtility_utils_ESAnyCastUtils.h (new) |   28 +
 .../patch-src_CommonUtility_utils_ESFile.cpp (new) |   12 +
 ...tch-src_CommonUtility_utils_PathUtils.cpp (new) |   10 +
 .../patch-src_Controller_CMakeLists.txt (new)      |   11 +
 .../patch-src_Controller_Src_EntryPoints.cpp (new) |   11 +
 ...c_Controller_Src_FileFormat_FFManager.cpp (new) |   12 +
 .../patch-src_Controller_Src_Filter_DTR.cpp (new)  |   21 +
 ...Controller_Src_Filter_ProcOrientation.hpp (new) |   10 +
 ...atch-src_Controller_Src_Filter_Saving.hpp (new) |   20 +
 ...h-src_Controller_Src_Finder_UsbFinder.cpp (new) |   14 +
 ...troller_Src_KeysValues_All_Resolution.cpp (new) |   11 +
 ...ller_Src_KeysValues_All_ScanHeightMax.cpp (new) |   11 +
 ...oller_Src_KeysValues_All_ScanWidthMax.cpp (new) |   11 +
 ...tch-src_Controller_Src_Scanner_Engine.hpp (new) |   26 +
 ...ch-src_Controller_Src_Scanner_Scanner.cpp (new) |   27 +
 ...patch-src_ES2Command_Linux_CMakeLists.txt (new) |   11 +
 ...Command_Src_Command_ESCI2_ESCI2Accessor.h (new) |   38 +
 ...nd_Src_Interface_ipc_ipcInterfaceImpl.cpp (new) |   11 +
 ...nd_Src_Interface_usb_usbInterfaceImpl.cpp (new) |   12 +
 ...mand_Src_Interface_usb_usbInterfaceImpl.h (new) |   15 +
 ...ch-src_ES2Command_Src_Utils_semaphore.hpp (new) |   71 +
 ...c_ES2FileFormat_Header_IO_FKDestination.h (new) |   32 +
 ...ch-src_ES2FileFormat_Header_IO_FKSource.h (new) |   11 +
 ...rc_ES2FileFormat_Header_Reader_FKReader.h (new) |   34 +
 ...S2FileFormat_Source_PnmUtil_FKPnmUtil.cpp (new) |   11 +
 .../epsonscan2/files/patch-src_Platform.cpp (new)  |   69 +
 .../files/patch-src_SaneWrapper_backend.cpp (new)  |   37 +
 .../files/patch-src_SaneWrapper_defines.h (new)    |   33 +
 .../patch-src_SaneWrapper_epsonscan.cpp (new)      |   29 +
 .../patch-src_ScanSDK_Src_SDK_supervisor.cpp (new) |   29 +
 .../patch-src_Standalone_CMakeLists.txt (new)      |    9 +
 ...atch-src_Standalone_addeditpagedialog.cpp (new) |    8 +
 .../patch-src_Standalone_commandlinemode.cpp (new) |   20 +
 ...patch-src_Standalone_custommessagebox.cpp (new) |   11 +
 ...ndalone_detectionareamindoublespinbox.cpp (new) |   11 +
 ...src_Standalone_deviceconnectiondialog.cpp (new) |   28 +
 .../patch-src_Standalone_documentsize.cpp (new)    |   23 +
 .../patch-src_Standalone_foldercomb.cpp (new)      |   20 +
 ...tandalone_imageformatsettingscombobox.cpp (new) |   11 +
 ...c_Standalone_imageformatsettingsdialog.ui (new) |   38 +
 ...c_Standalone_initdeviceselectcombobox.cpp (new) |   11 +
 ...ch-src_Standalone_lengthdoublespinbox.cpp (new) |   11 +
 .../patch-src_Standalone_mainwindow.cpp (new)      |   38 +
 .../files/patch-src_Standalone_mainwindow.ui (new) |   38 +
 ..._Standalone_networkdeviceselectdialog.cpp (new) |   11 +
 .../patch-src_Standalone_rotateimage.cpp (new)     |   47 +
 .../patch-src_Standalone_supervisor.cpp (new)      |   29 +
 ...tch-src_Standalone_widthdoublespinbox.cpp (new) |   11 +
 .../files/patch-thirdparty_zlib_gzread.c (new)     |   10 +
 .../files/patch-thirdparty_zlib_gzwrite.c (new)    |   10 +
 graphics/epsonscan2/files/pkg-message.in (new)     |   17 +
 graphics/epsonscan2/pkg-descr (new)                |    5 +
 graphics/epsonscan2/pkg-plist (new)                | 1650 ++++++++++++++++++++
 69 files changed, 3755 insertions(+)
Comment 52 Rainer Hurling freebsd_committer freebsd_triage 2022-04-03 08:50:48 UTC
Hi J.R.,

Just committed, many thanks for this nice port!

I just noticed that in the commit your authorship was accidentally not included. Sorry for that :(