Bug 269302 - [NEW PORT] print/ghostscript10
Summary: [NEW PORT] print/ghostscript10
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Daniel Engberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-03 09:08 UTC by Michael Osipov
Modified: 2023-06-17 21:27 UTC (History)
3 users (show)

See Also:


Attachments
Git-formatted patch (20.07 KB, application/mbox)
2023-02-03 09:08 UTC, Michael Osipov
no flags Details
Git-formatted patch (20.13 KB, patch)
2023-02-03 09:26 UTC, Michael Osipov
no flags Details | Diff
Patch for ghostscript10 (17.86 KB, patch)
2023-03-19 07:59 UTC, Daniel Engberg
no flags Details | Diff
Git-formatted patch (26.49 KB, patch)
2023-03-22 09:32 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (26.40 KB, patch)
2023-03-23 17:50 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (26.26 KB, patch)
2023-03-23 18:03 UTC, Michael Osipov
michael.osipov: maintainer-approval+
Details | Diff
Patch for ghostscript10 v2 (24.27 KB, patch)
2023-03-29 11:20 UTC, Daniel Engberg
no flags Details | Diff
Patch for ghostscript10 v3 (4.60 KB, patch)
2023-06-17 21:26 UTC, Daniel Engberg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2023-02-03 09:08:00 UTC
Created attachment 239873 [details]
Git-formatted patch

Tested in QA environment with hundreds of LaTeX and PS files, ran through Poudriere and addressed portlint issues as much as possible.

This is based on print/ghostscript9-agpl-base

===================
Implicitly or explicitly fixes:
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251941
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264822
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258424
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247497

Remove all custom patches for Resource/Init/ since their either cause the bugs
above or cover unclear/old marginal/very specific use cases which require
explicit documentation/tests to verify them. Ideally, if those are required
for CJK they either must be a port option or turned to @sample for the user.
See also "git log" of the removed patch files for their previous use cases.
===================
Comment 1 Michael Osipov 2023-02-03 09:24:20 UTC
and this one https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267625
Comment 2 Michael Osipov 2023-02-03 09:26:41 UTC
Created attachment 239874 [details]
Git-formatted patch
Comment 3 Daniel Engberg freebsd_committer freebsd_triage 2023-03-19 07:59:17 UTC
Created attachment 240971 [details]
Patch for ghostscript10

Drop PKGNAMESUFFIX (try to follow other distros more closely)
Use DISTVERSION instead of PORTVERSION
Remove wonky version handling within port
Slightly rearrange port for better readability and clear a few issues reported by Portlint
Comment 4 Daniel Engberg freebsd_committer freebsd_triage 2023-03-19 08:01:27 UTC
Many thanks working on this, here's a few more things that I noticed looking at other repos:

Use CMap from poppler-data?
https://github.com/archlinux/svntogit-packages/blob/packages/ghostscript/trunk/PKGBUILD#L108

Something we should also pick up?
https://github.com/archlinux/svntogit-packages/blob/packages/ghostscript/trunk/0001_Catch_and_act_on_error_code_during_PCL5_init.diff

More dist patches...
https://salsa.debian.org/debian/ghostscript/-/blob/debian/latest/debian/patches/2001_docdir_fix_for_debian.patch
https://salsa.debian.org/debian/ghostscript/-/blob/debian/latest/debian/patches/2004_remove_non-Debian_paths_from_docs.patch
https://salsa.debian.org/debian/ghostscript/-/blob/debian/latest/debian/patches/2010_add_build_timestamp_setting.patch

Many repos includes this as a dependency https://www.freshports.org/x11-fonts/urw-base35-fonts/

Cleanups?
https://src.fedoraproject.org/rpms/ghostscript/blob/rawhide/f/ghostscript.spec#_291

Use flavours and create a port with X support?

Upstream tries to be smart with Tesseract and detect CPU flags, this will for sure fail for packaging...
tesseract --> no auto cpu flags (c++17)

Fix?
WARN: /usr/ports/print/ghostscript10/pkg-plist: [210]: Do not mix %%PORTDOCS%% with %%DATADIR%%. Use '%%PORTDATA%%%%DATADIR%%/doc' instead and update Makefile accordingly.

Best regards,
Daniel
Comment 5 Michael Osipov 2023-03-20 07:22:51 UTC
I will have a look at all those, but note that my work is based off the previous Ghostscript, I tried to be as close as possible.
Comment 6 Daniel Engberg freebsd_committer freebsd_triage 2023-03-20 08:10:52 UTC
Sounds great, using the older version as a base template is a great idea to move forward.
Comment 7 Michael Osipov 2023-03-20 12:17:18 UTC
(In reply to Daniel Engberg from comment #4)

> Drop PKGNAMESUFFIX (try to follow other distros more closely)

Right, this makes sense since there is no other OSS license anymore. Will do.

> Use DISTVERSION instead of PORTVERSION
> Remove wonky version handling within port

This is a problem which gave me a hard time rooted in: https://bugs.ghostscript.com/show_bug.cgi?id=706389

It all revolves around the inconsistency of a zero-padded vs non-padded single digit minor version. I'd like to keep it for now until upstream has addressed it and hopefully with 10.00.1 I can trim it down.
The big question: Should the port use the zero-padded version or not? Looking at https://github.com/freebsd/freebsd-ports/commit/ed102396a2a65686bf4158350548a5d0c1ed5f7c it was padded as well, which I can accept. WDYT?

> Use CMap from poppler-data?
> https://github.com/archlinux/svntogit-packages/blob/packages/ghostscript/trunk/PKGBUILD#L108

This is already done by the port, post-install links to poppler-data supplied CMap.

> Something we should also pick up?
> https://github.com/archlinux/svntogit-packages/blob/packages/ghostscript/trunk/0001_Catch_and_act_on_error_code_during_PCL5_init.diff

This is a backport of an upstream fix which will we available in 10.00.1. Unless someone complains I don't see a need to cherry pick specific commits.

> More dist patches...
> https://salsa.debian.org/debian/ghostscript/-/blob/debian/latest/debian/patches/2001_docdir_fix_for_debian.patch

Done by post-install, but docs are completely different in 10. They now require an additional build step which isn't included here.

> https://salsa.debian.org/debian/ghostscript/-/blob/debian/latest/debian/patches/2004_remove_non-Debian_paths_from_docs.patch

This is legit. Will take a look at the current manpage.

> https://salsa.debian.org/debian/ghostscript/-/blob/debian/latest/debian/patches/2010_add_build_timestamp_setting.patch

While this is a reasonble patch and I one of the contributors to repro builds in the Maven world, I would pursue to bring this rather upstream independent of this port.

> Many repos includes this as a dependency https://www.freshports.org/x11-fonts/urw-base35-fonts/

I verified this and it makes sense. Will add as a runtime dependency.

> Cleanups?
> https://src.fedoraproject.org/rpms/ghostscript/blob/rawhide/f/ghostscript.spec#_291

The only improvement I can see is to remove the *.sh files; ghostscript(1) we don't have; the rest is subject to %%PORTDOCS%% and will be omitted if chosen to. I am included to remove DOCS altogether because they are useless compared to 9.

> Use flavours and create a port with X support?

This I can only to after this port works. I personally don't use it with X, so it is of low priority to me.

> Upstream tries to be smart with Tesseract and detect CPU flags, this will for sure fail for packaging...
> tesseract --> no auto cpu flags (c++17)

can you be more specific? Are you referring to:
checking supported C++ compiler flags...    -std=c++17
-std=c++17
checking sse4.1 support... yes
checking avx support... yes
checking avx2 support... yes
checking fma support... yes
checking neon support... no
and
--disable-sse2          Do not use sse2 instrinsics


> Fix?
> WARN: /usr/ports/print/ghostscript10/pkg-plist: [210]: Do not mix %%PORTDOCS%% with %%DATADIR%%. Use '%%PORTDATA%%%%DATADIR%%/doc' instead and update Makefile accordingly.

When docs are gone this won't be an issue anymore. I will drop docs.
Comment 8 Michael Osipov 2023-03-20 12:42:11 UTC
Let me try to digest your patch on top. What I dislike that you changed the internal versioning scheme for GS where I have no clue whether this might have consequences internally. GS uses zero-padded, so be it. I wouldn't change it.
Comment 9 Daniel Engberg freebsd_committer freebsd_triage 2023-03-21 06:42:57 UTC
(In reply to Michael Osipov from comment #7)

Hi,

I briefly skimmed through repos and thanks you looking into it more closely.

Regarding version numbering I think using zero padded is fine as "package version" as long as you reference that commit in commit message to clear up the confusion.

As for the cpu feature flags you seem to have found the issue, these is later used in tesseract and  setting --disable-sse2 appears to fix that issue (needs to be default)

Best regards,
Daniel
Comment 10 Michael Osipov 2023-03-21 07:25:56 UTC
(In reply to Daniel Engberg from comment #9)

Right, give me a couple of days. I will get back to you next week with a new patch.
Comment 11 Michael Osipov 2023-03-21 11:45:14 UTC
10.01.0r2 is available, I am using this and Chris fixed (as it seems) the versioning issue, so I can reuse your var magic and even reduce it, it guess. Stay tuned.
Comment 12 Michael Osipov 2023-03-21 18:42:58 UTC
Let me give a status update, I have now a fairly complete port which needs QA testing with out prime LaTeX setup. I was able to address all of the issues you have raised and did even more cleanup and refactorings regarding external libraries.
Notes:
* Unfortunately Tesseract is bundled, I have already requested to optionally externalize it, it is a port OPTION now. The CPU flag checks were already present with 9.x, no one cared. I'd wait for complaints before I add even more logic here.
* SS2 (not related to Tesseract): This has been available since Pentium 4 (2000), for other archs the autodetection will disable it, same here wait for complaints.
* libidn is required for Unicode passwords, I didn't remove it. Whether it should be included at all or a port OPTION, I don't have a strong opinion.
* --with=libiconv=native will not work. The value is misleading (I will raise a bug here) because it does NOT try iconv from libc, 'maybe' does. Don't ask.
* Tesseract C++ requirements are wrong, raised an issue as well.
* No portlint issues anymore

I'll get back to you tomorrow.
Comment 13 Daniel Engberg freebsd_committer freebsd_triage 2023-03-21 22:43:55 UTC
I can't for my life find it now but I read somewhere(tm) that both tesseract and leptonica have modified code that's not upstreamed. Great work on this one! :)
Comment 14 Michael Osipov 2023-03-22 07:38:56 UTC
(In reply to Daniel Engberg from comment #13)

Me neither, therefore I raised an issue: https://bugs.ghostscript.com/show_bug.cgi?id=706490

Suprisingly, lcms2 is forked and there is a README regarding this, BUT they still support external linking which is a contradiction. I will diff lcms2 and figure out whether the fork is still required. I am not a huge fan of using bundled libs unless absolutely necessary.
Comment 15 Michael Osipov 2023-03-22 09:32:38 UTC
Created attachment 241049 [details]
Git-formatted patch

Here is a completely updated patch. I think that all issues are resolved here. Ran TL 2022 with a lot of docs w/o issues. Note: This is 10.01.0rc2 which solves the versioning issue, as soon as GA is available we can drop the DISTVERSIONSUFFIX. Internally this is already 10.01.0.

Currently open issues which might improve the port:
* https://bugs.ghostscript.com/show_bug.cgi?id=706491
* https://bugs.ghostscript.com/show_bug.cgi?id=706490
* https://bugs.ghostscript.com/show_bug.cgi?id=706492

Meanwhile, I will look into the two patches I have adopted from GS9 and will try to move them to upstream.
Comment 16 Michael Osipov 2023-03-22 09:46:55 UTC
patch-tesseract_src_arch_simddetect.cpp is obsolete upstream since it properly detects the necessary function on FreeBSD: https://github.com/tesseract-ocr/tesseract/blob/0daf18c2028e5217cd996522816c3dd2ec1a4198/src/arch/simddetect.cpp#L227-L231
Comment 17 Michael Osipov 2023-03-22 10:01:15 UTC
patch-configure: I consider this more or less obsolete since dynamic driver loading is deprecated and disabled since it is not compatible with hidden symbols. I will leave it as is for now until I have created the X11 flavor.

So, all good.
Comment 18 Michael Osipov 2023-03-23 17:50:35 UTC
Created attachment 241074 [details]
Git-formatted patch

Re: lcms2
Clarified with devs (https://bugs.ghostscript.com/show_bug.cgi?id=706492#c2) that it can use the port version, then it will consume a bit more memory and CPU time compared to the bundled version.

Modified patch accordingly.
Comment 19 Michael Osipov 2023-03-23 18:03:36 UTC
Created attachment 241075 [details]
Git-formatted patch

Update to 10.01.0 final. Released yesterday.

Regarding Tesseract: https://ghostscript.readthedocs.io/en/latest/News.html

"Mainly due to time constraints, we only support including Tesseract from source included in our release packages, and not linking to Tesseract/Leptonica shared libraries. Whether we add this capability will be largely dependent on community demand for the feature."

Let's wait for this...
Comment 20 Michael Osipov 2023-03-28 10:53:05 UTC
Daniel,

is there anything else I can do to get this completed? Ideally, this would in 2023Q2.
Comment 21 Daniel Engberg freebsd_committer freebsd_triage 2023-03-29 11:20:27 UTC
Created attachment 241180 [details]
Patch for ghostscript10 v2

Based on latest patch (Poudriere is fine)

Some minor style changes, looks great!
If you dont have any objects this will be committed later today

- Use DISTVERSION everywhere instead of mixing usage of PORTVERSION and DISTVERSION
- Separate a few sections for better readability
- Use *_USES helper instead of if statement
- Move _DESC into a separate section
- Follow order of global variables in ports Makefile for options
Comment 22 Michael Osipov 2023-03-29 11:30:31 UTC
(In reply to Daniel Engberg from comment #21)

Thanks, let me digest this.
Comment 23 Michael Osipov 2023-03-29 11:44:47 UTC
(In reply to Daniel Engberg from comment #21)

Changes look good and reduce clutter. Please go on and commit. Thank you!
Comment 24 commit-hook freebsd_committer freebsd_triage 2023-03-29 12:00:23 UTC
A commit in branch main references this bug:

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

commit d6b46695f33749aa9c8217f976149c6850c573ca
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-03-29 11:54:23 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2023-03-29 11:55:19 +0000

    print/ghostscript10: New port: Import new major version

    Changelog(s):
    https://ghostscript.readthedocs.io/en/gs10.0.0/News.html
    https://ghostscript.readthedocs.io/en/gs10.01.0/News.html

    PR:             269302

 print/Makefile                                     |   1 +
 print/ghostscript10/Makefile (new)                 | 101 ++++++
 print/ghostscript10/distinfo (new)                 |   3 +
 print/ghostscript10/files/patch-configure (new)    |  16 +
 print/ghostscript10/files/patch-man_gs.1 (new)     | 126 ++++++++
 .../ghostscript10/files/patch-psi_imainarg.c (new) |  44 +++
 .../patch-tesseract_src_arch_simddetect.cpp (new)  |  34 ++
 print/ghostscript10/pkg-descr (new)                |   3 +
 print/ghostscript10/pkg-message (new)              |   8 +
 print/ghostscript10/pkg-plist (new)                | 341 +++++++++++++++++++++
 10 files changed, 677 insertions(+)
Comment 25 Daniel Engberg freebsd_committer freebsd_triage 2023-03-29 12:03:47 UTC
Committed, many thanks for working on this!
Comment 26 Michael Osipov 2023-03-29 12:07:00 UTC
(In reply to Daniel Engberg from comment #25)

Thank you very much for the guidance, your review led to a much better port!
I can now soon replace ghostscript 9 which is unfortunately broken due to custom patches and the port maintainer does not respond. E.g., Bug 267625.
Comment 27 Daniel Engberg freebsd_committer freebsd_triage 2023-06-17 21:26:30 UTC
Created attachment 242847 [details]
Patch for ghostscript10 v3

...and it helps just a bit if you attach the correct patch.
Comment 28 Daniel Engberg freebsd_committer freebsd_triage 2023-06-17 21:27:27 UTC
Comment on attachment 242847 [details]
Patch for ghostscript10 v3

Wrong PR...