Bug 270989

Summary: print/ghostscript10: adds libgs.so; connects to USES and DEFAULT_VERSIONS facilities; flavorized
Product: Ports & Packages Reporter: Chad Jacob Milios <milios>
Component: Individual Port(s)Assignee: Daniel Engberg <diizzy>
Status: Closed FIXED    
Severity: Affects Some People CC: diizzy, hrs, mandree, mfburdett, michael.osipov, pmc, rene
Priority: --- Flags: bugzilla: maintainer-feedback? (michael.osipov)
milios: maintainer-feedback? (michael.osipov)
milios: merge-quarterly?
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258424
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270800
Attachments:
Description Flags
bring ghostscript10 onto USES
milios: maintainer-approval? (michael.osipov)
Patch for point 1
none
Patch for point 1
none
Patch for point 2
none
Patch for point 1
none
Patch for point 2
none
Patch for point 3 + 5
none
Patch for point 1
none
Patch for point 2 (port OPTION)
none
Patch for point 3 + 5 (port OPTION)
none
Patch for point 1
none
Patch for point 2
none
Patch for point 3 + 5
none
Patch for ghostscript10 (1+2 combined)
none
Patch for ghostscript10 (1+2 combined) v2
none
Patch for ghostscript10 (1+2 combined) v3
none
Patch for ghostscript10 (1+2 combined) v3.1
none
Patch for point 3 + 5
none
Add lib arg support to ghostscript.mk
none
Fix graphics/xfig
none
Fix graphics/inkscape
none
Fix graphics/graphviz none

Description Chad Jacob Milios 2023-04-21 21:51:22 UTC
Created attachment 241643 [details]
bring ghostscript10 onto USES

print/ghostscript10 was added recently. it addresses CVE-2021-3781 but it lacked parity with earlier ports in the tree so long as it didnt provide libgs.so and X11.so. (it provided the executables only) or connect to Uses/ghostscript.mk

i hooked it in and opted to go with FLAVOR support rather than SLAVE or a disparate -x11 port. i've successfully rebuilt all the packages i am using here (graphviz, inkscape, texlive, ImageMagick7, R to name a few) while setting my DEFAULT_VERSIONS=...ghostscript=10…

so far i've only really had a chance to put ImageMagic through its paces. i have not tested my changes to Mk with the current default: [9-]agpl

fyi, i've never made or heavily modified a FLAVORed port; i hope i'm on the right track

thank you
Comment 1 Michael Osipov 2023-04-22 08:27:10 UTC
I will go through this next week.
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2023-04-22 12:01:53 UTC
Thanks for the patch, looks good overall but I have a few inputs having a quick look at it.

Changes to Mk/Uses/ghostscript.mk should go into a separate patch
PORTVERSION --> DISTVERSION

For overall consistency in tree I'd suggest that we make a nox11 variant rather than x11 and remove base from naming

Use ".if ${FLAVOR} == nox11" instead of .if !empty(FLAVOR:Mx11)

L104 and L105 is a way to do it but I think for the sake of readability its better to wrap it around .if statements
Comment 3 Michael Osipov 2023-04-24 07:23:33 UTC
I am currently going through ghostcript.mk and the shared library thing to get a better understand. Give a me a few days.

I have intentionally disabled dynamic driver loading since it is deprected by Artifex and didn't want also to expose any hidden symbols since I know how this can break applications (looking at you Oracle).
Comment 4 Michael Osipov 2023-04-24 15:34:27 UTC
Went through most of the patch, although it mostly looks fine, the patch does way too much from my S/W dev PoV, seperate concerns need to be addressed separately:

1. Add dynamic linking
2. Flavorize port
3. Clean up ghostscript.mk, everything before 9 should be removed
4. Clean up ports not to use a specific version directly:
> ./graphics/graphviz/Makefile:GHOSTSCRIPT_LIB_DEPENDS=   libgs.so:print/${_GS_PORT}
Uses an implementation detail which is not acceptable, should be "USES=ghostscript"
> ./graphics/inkscape/Makefile:           ps2pdf:print/ghostscript9-agpl-base \
"USES=ghostscript:run"
> ./graphics/xfig/Makefile:LIB_DEPENDS=   libgs.so:print/ghostscript9-agpl-base \
"USES=ghostscript"
5. Adapt patch on top of cleaned up ghostscript.mk to integrate flavors of 10 AND request an exp-run for 10 to see whether there are fallouts just to make sure.

So this makes five patches here which gives us much more control of this important change.

@dizzy Do you want me or Chad provide patch for 4 or do you want me to do this yourself?

I will go on with these based on Chad's patch.
Comment 5 Michael Osipov 2023-04-24 15:36:41 UTC
Created attachment 241701 [details]
Patch for point 1

Here is the first patch. Chad's authorship has been retained, of course. @dizzy please have a look and commit it to HEAD, I will continue with the flavors tomorrow.
Comment 6 Michael Osipov 2023-04-24 15:41:36 UTC
Ports affected by exp-run:
root@deblndw011x:/var/poudriere/ports/default-head (main-custom *)
# grep -r --include='**/Makefile*' ghostscript .
./biology/vsearch/Makefile:USES=                autoreconf ghostscript:build gmake localbase
./cad/xcircuit/Makefile:USES=           ghostscript:x11,run gmake gnome pkgconfig tar:tgz tk:tea xorg
./chinese/enscript/Makefile:USES+=              ghostscript:run
./comms/opencbm/Makefile:DOCS_USES=             ghostscript:build
./devel/aegis/Makefile:USES=            cpe gettext ghostscript gnome groff perl5 tk bison
./devel/doxygen/Makefile:DOCS_USES=             ghostscript:build tex
./devel/libexplain/Makefile:USES=               bison gettext ghostscript:build gmake groff iconv libtool:build
./devel/xsd/Makefile:USES=              compiler:c++11-lang ghostscript:build gmake localbase:ldflags tar:bzip2
./devel/srecord/Makefile:USES=          ghostscript groff libtool:build
./editors/ted/Makefile:USES=            ghostscript:x11,run iconv pkgconfig xorg
./editors/texmacs/Makefile:GHOSTSCRIPT_USES=    ghostscript:x11
./editors/texmaker/Makefile:USES=               compiler:c++11-lang desktop-file-utils ghostscript:x11,run \
./editors/texstudio/Makefile:           ghostscript:run gl pkgconfig qmake qt:5 tex xorg
./graphics/ImageMagick6/Makefile:USES+=         ghostscript:x11
./graphics/ImageMagick6/Makefile:USES+=         ghostscript
./graphics/ImageMagick6/Makefile:USES+=         ghostscript:x11
./graphics/ImageMagick6/Makefile:USES+=         ghostscript
./graphics/ImageMagick6/Makefile:USES+=         ghostscript:x11,build
./graphics/ImageMagick6/Makefile:USES+=         ghostscript:build
./graphics/ImageMagick7/Makefile:USES+=         ghostscript:x11
./graphics/ImageMagick7/Makefile:USES+=         ghostscript
./graphics/ImageMagick7/Makefile:USES+=         ghostscript:x11
./graphics/ImageMagick7/Makefile:USES+=         ghostscript
./graphics/ImageMagick7/Makefile:USES+=         ghostscript:x11,build
./graphics/ImageMagick7/Makefile:USES+=         ghostscript:build
./graphics/eps2png/Makefile:USES=               ghostscript perl5
./graphics/epstool/Makefile:USES=               ghostscript:run gmake
./graphics/gimp-app/Makefile:GHOSTSCRIPT_USES=          ghostscript
./graphics/gmt/Makefile:USES=           blaslapack cmake ghostscript:run shebangfix tar:xz
./graphics/graphviz/Makefile:GHOSTSCRIPT_USES=ghostscript
./graphics/graphviz/Makefile:DOCS_USES= ghostscript:build groff
./graphics/impressive/Makefile:GHOSTSCRIPT_USES=        ghostscript:run
./graphics/inkscape/Makefile:           ps2pdf:print/ghostscript9-agpl-base \
./graphics/klatexformula/Makefile:USES=         cmake compiler:c++11-lang desktop-file-utils ghostscript:run \
./graphics/netpbm/Makefile:USES=                cpe ghostscript:test gmake perl5 shebangfix tar:xz
./graphics/ocaml-images/Makefile:GHOSTSCRIPT_USES=      ghostscript
./graphics/peps/Makefile:USES=          ghostscript:run
./graphics/pstoedit/Makefile:USES=              ghostscript libtool localbase pathfix pkgconfig
./graphics/sam2p/Makefile:USES=         cpe ghostscript:run gmake jpeg:run perl5
./graphics/xfig/Makefile:LIB_DEPENDS=   libgs.so:print/ghostscript9-agpl-base \
./graphics/xournal/Makefile:GHOSTSCRIPT_DESC=   Install ghostscript (PS/PDF as bitmap bg)
./graphics/xournal/Makefile:GHOSTSCRIPT_USES=   ghostscript:run
./graphics/xpaint/Makefile:USES=                ghostscript:run jpeg libtool:build localbase:ldflags \
./graphics/xpeps/Makefile:USES=         ghostscript:x11,run
./lang/clisp/Makefile:USES=             compiler gettext ghostscript gnome iconv localbase:ldflags
./mail/claws-mail-pdf_viewer/Makefile:USES+=            ghostscript
./mail/courier/Makefile:USES+=          ghostscript
./math/R/Makefile:GHOSTSCRIPT_USES=             ghostscript
./math/asymptote/Makefile:USES=         compiler:c++14-lang gettext-runtime ghostscript gl gmake gnome ncurses perl5 python:3.6+ \
./math/linbox/Makefile:FULL_USES=               ghostscript
./math/plplot/Makefile:USES=            compiler:c11 cmake gettext-runtime ghostscript gnome \
./misc/pspresent/Makefile:USES=         ghostscript:x11,run xorg
./multimedia/lives/Makefile:GHOSTSCRIPT_USES=           ghostscript:run
./print/auctex/Makefile:USES=           emacs ghostscript gmake tex
./print/cups-filters/Makefile:GHOSTSCRIPT_USES=         ghostscript
./print/cups-fxlinuxprint/Makefile:USES=                dos2unix ghostscript:run localbase:ldflags
./print/cups-pdf/Makefile:USES=         ghostscript:run localbase
./print/dvisvg/Makefile:USES=           ghostscript:run tex
./print/epsonepl/Makefile:USES=         ghostscript:run uidfix tar:tgz
./print/fig2dev/Makefile:USES=          alias cpe ghostscript:run iconv tar:xz xorg
./print/flpsed/Makefile:USES=           desktop-file-utils ghostscript:x11 gmake xorg
./print/foo2zjs/Makefile:USES=          cpe ghostscript gmake shebangfix
./print/font2svg/Makefile:USES=         ghostscript:run
./print/foomatic-filters/Makefile:USES=         autoreconf cpe ghostscript perl5 pkgconfig
./print/gspdf/Makefile:USES=            ghostscript gnustep
./print/gv/Makefile:USES=               cpe ghostscript:x11 iconv gmake perl5 shebangfix xorg
./print/html2ps/Makefile:USES=          ghostscript:run magick:6,run perl5
./print/libspectre/Makefile:USES=               ghostscript gmake gnome libtool localbase pathfix pkgconfig
./print/lilypond-devel/Makefile:USES=           bison:build compiler:c++11-lib cpe ghostscript gmake gnome \
./print/lilypond/Makefile:USES=         bison:build compiler:c++11-lib cpe ghostscript gmake gnome \
./print/lout/Makefile:USES=             cpe ghostscript:run gmake magick:run
./print/magicfilter/Makefile:USES=              ghostscript
./print/pnm2ppa/Makefile:USES=  gmake ghostscript:run
./print/ps2eps/Makefile:USES=           ghostscript:run perl5
./print/psdim/Makefile:USES=            ghostscript
./print/pstotext/Makefile:USES=         cpe ghostscript:run
./print/shrinkpdf/Makefile:USES=                        ghostscript:run
./print/texlive-base/Makefile:USES=             compiler:c++11-lib cpe ghostscript gnome localbase pkgconfig perl5 \
./print/texvc/Makefile:RASTER_USES=     ghostscript:run magick:6,run tex
./print/transfig/Makefile:USES=         alias ghostscript:run imake xorg
./sysutils/LPRngTool/Makefile:USES=             ghostscript:build tar:tgz tk
./textproc/docproj-legacy/Makefile:USES=                ghostscript:run metaport perl5
./textproc/latex2html/Makefile:USES=            ghostscript perl5 tex
./textproc/pdfsandwich/Makefile:USES=           gmake ghostscript:run magick:6,run tar:bz2
./textproc/pdftohtml/Makefile:USES=             cpe ghostscript gmake
./textproc/py-ocrmypdf/Makefile:USES=           ghostscript:run python:3.8+ shebangfix
./textproc/sowing/Makefile:USES=                ghostscript gmake perl5 tex
./textproc/tth/Makefile:USES=           ghostscript:run shebangfix tar:tgz

root@deblndw011x:/var/poudriere/ports/default-head (main-custom *)
# grep -r --include='**/Makefile*' libgs.so: .
./graphics/graphviz/Makefile:GHOSTSCRIPT_LIB_DEPENDS=   libgs.so:print/${_GS_PORT}
Comment 7 Michael Osipov 2023-04-24 15:44:27 UTC
Regarding point 2, flavor names:
Looking at
# grep -ri --include='*/Makefile*' -E -e 'FLAVORS=' .
./archivers/quazip/Makefile:FLAVORS=    qt5 qt6
./audio/asterisk-espeak/Makefile:FLAVORS=       asterisk18 asterisk16
./audio/asterisk-flite/Makefile:FLAVORS=                        asterisk18 asterisk16
./audio/jamulus/Makefile:FLAVORS=       desktop server
./audio/kid3/Makefile:FLAVORS=  qt5 qt6 kf5
./audio/strawberry/Makefile:FLAVORS=            qt5 qt6
./benchmarks/glmark2/Makefile:CONFIGURE_ARGS=   -Dflavors=${PLATFORMS:ts,}
./benchmarks/wrk/Makefile:FLAVORS=      luajit luajitor
./cad/ngspice_rework/Makefile:FLAVORS=  x11 shlib
./cad/qcad/Makefile:#FLAVORS=   qt5 qt6
./databases/ldb15/Makefile:#FLAVORS=            default nopython
./databases/sqlite3/Makefile:FLAVORS=   default icu tcl
./deskutils/copyq/Makefile:FLAVORS=     qt5 qt6
./deskutils/fet/Makefile:FLAVORS=       qt5 qt6
./devel/RStudio/Makefile:FLAVORS=       desktop server
./devel/binutils/Makefile:FLAVORS=      native aarch64 aarch64_none_elf amd64 arm_gnueabi arm_none_eabi \
./devel/bullet/Makefile:FLAVORS=        single double
./devel/cmake-gui/Makefile:FLAVORS=     qt5 qt6
./devel/llvm16/Makefile:FLAVORS=        default lite
./devel/freebsd-gcc12/Makefile:FLAVORS= aarch64 amd64 armv6 armv7 i386 powerpc powerpc64 riscv64
./devel/freebsd-gcc9/Makefile:FLAVORS=  aarch64 amd64 armv6 armv7 i386 mips mips64 powerpc powerpc64 riscv64 sparc64
./devel/freebsd-sysroot/Makefile:FLAVORS=       aarch64 amd64 armv7 i386 powerpc powerpc64 powerpc64le \
./devel/git/Makefile:FLAVORS=   default lite tiny
./devel/hs-haskell-language-server/Makefile:FLAVORS=    default ghc810
./devel/intel-graphics-compiler/Makefile:FLAVORS=       ${14 13 12 11:L:S/^/llvm/}
./devel/libdbusmenu-qt/Makefile:FLAVORS=        qt5 qt6
./devel/llvm-devel/Makefile:FLAVORS=    default lite
./devel/llvm15/Makefile:FLAVORS=        default lite
./devel/opencl-clang/Makefile:FLAVORS=  ${15 14 13 12 11:L:S/^/llvm/}
./devel/qca/Makefile:FLAVORS=   qt5 qt6
./devel/qcoro/Makefile:FLAVORS= qt5 qt6
./devel/spirv-llvm-translator/Makefile:FLAVORS= ${16 15 14 13 12 11:L:S/^/llvm/}
./devel/vc-intrinsics/Makefile:FLAVORS= ${15 14 13 12 11:L:S/^/llvm/}
./editors/emacs-devel/Makefile:FLAVORS=         full nox
./editors/emacs/Makefile:FLAVORS=                       full canna nox
./editors/ghostwriter/Makefile:FLAVORS= qt5 qt6
./editors/mg/Makefile:FLAVORS=  dynamic static
./editors/vim/Makefile:FLAVORS= console gtk2 gtk3 motif x11 tiny
./emulators/libretro-vice/Makefile:FLAVORS=     x64 x128 x64sc xcbm2 xcbm5x0 xpet xplus4 xscpu64 xvic
./emulators/open-vm-tools/Makefile:FLAVORS=                     default nox11
./emulators/qemu/Makefile:FLAVORS=                      default nox11 tools guestagent
./emulators/qemu6/Makefile:FLAVORS=                     default nox11 tools
./emulators/qemu70/Makefile:FLAVORS=                    default nox11 tools
./emulators/rpcs3/Makefile:FLAVORS=     qt5 qt6
./emulators/yuzu/Makefile:FLAVORS=      qt5 qt6
./games/brogue/Makefile:FLAVORS=        x11 nox11
./games/melonds/Makefile:FLAVORS=       qt5 qt6
./games/stonesoup/Makefile:FLAVORS=     console sdl
./games/vvvvvv/Makefile:FLAVORS=        commercial makeandplay
./games/xnethack/Makefile:FLAVORS=      x11 nox11 qt
./graphics/evince/Makefile:FLAVORS=     full lite
./graphics/gifsicle/Makefile:FLAVORS=           x11 nox11
./graphics/gmic-qt/Makefile:FLAVORS=    none krita gimp # reflect the value of GMIC_QT_HOST for simplicity
./graphics/gpu-firmware-amd-kmod/Makefile:FLAVORS=      aldebaran \
./graphics/gpu-firmware-intel-kmod/Makefile:FLAVORS=    skylake \
./graphics/gpu-firmware-radeon-kmod/Makefile:FLAVORS=   aruba \
./graphics/yacreader/Makefile:FLAVORS=  qt5 qt6
./korean/nanumfonts/Makefile.common:FLAVORS=    ttf otf
./lang/intel-compute-runtime/Makefile:FLAVORS=  ${14 13 12 11:L:S/^/llvm/}
./lang/rust-bootstrap/Makefile:FLAVORS= aarch64 amd64 armv7 i386 powerpc powerpc64 powerpc64le riscv64
./mail/cyrus-imapd34/Makefile:FLAVORS=  basic http
./mail/cyrus-imapd36/Makefile:FLAVORS=  basic http
./mail/postfix-current/Makefile:FLAVORS=                        default ldap sasl
./mail/postfix/Makefile:FLAVORS=                        default ldap mysql pgsql sasl sqlite
./math/qalculate-qt/Makefile:FLAVORS=           qt5 qt6
./multimedia/audacious-plugins/Makefile:FLAVORS=        qt5 qt6 gtk2 gtk3
./multimedia/audacious/Makefile:FLAVORS=        qt5 qt6 gtk2 gtk3
./multimedia/mkvtoolnix/Makefile:FLAVORS=       qt5 nogui
./multimedia/mlt7-qt/Makefile:FLAVORS=  qt5 qt6
./multimedia/winff/Makefile:LAZARUS_NO_FLAVORS= qt5
./net-im/telegram-desktop/Makefile:FLAVORS=     qt5 qt6
./net-mgmt/cnagios/Makefile:FLAVORS=    nagios3 nagios4
./net-p2p/qbittorrent/Makefile:FLAVORS= default nox
./net/asterisk-chan_sccp/Makefile:FLAVORS=      asterisk18 asterisk16
./net/asterisk-g72x/Makefile:FLAVORS=                   asterisk18 asterisk16
./net/bird/Makefile:FLAVORS=    ipv4 ipv6
./net/bird2/Makefile:FLAVORS=   base netlink
./net/freeradius3/Makefile:FLAVORS=     default ldap mysql pgsql sqlite3
./net/haproxy-devel/Makefile:FLAVORS=   default lua
./net/haproxy/Makefile:FLAVORS= default lua
./net/haproxy24/Makefile:FLAVORS=       default lua
./net/haproxy25/Makefile:FLAVORS=       default lua
./net/remmina/Makefile:FLAVORS=         default lite
./net/haproxy26/Makefile:FLAVORS=       default lua
./net/unison/Makefile:FLAVORS=  x11 nox11
./net/unison232/Makefile:FLAVORS=       x11 nox11
./net/unison240/Makefile:FLAVORS=       x11 nox11
./net/unison248/Makefile:FLAVORS=       x11 nox11
./net/unison251/Makefile:FLAVORS=       x11 nox11
./net/wireguard-tools/Makefile:FLAVORS= default lite
./net/wireshark/Makefile:FLAVORS=       default nox11
./news/cleanfeed/Makefile:FLAVORS=      inn inncurrent
./print/pdfmixtool/Makefile:FLAVORS=    qt5 qt6
./science/erkale/Makefile:FLAVORS=      parallel serial
./science/healpix/Makefile:FLAVORS=     cxx c
./science/libtensorflow1/Makefile:FLAVORS=      default noavx
./security/afl++/Makefile:FLAVORS=      llvm gcc
./security/gost-engine/Makefile:FLAVORS=        base openssl30
./security/libressl-devel/Makefile:FLAVORS=     default libtls
./security/libressl/Makefile:FLAVORS=   default libtls
./security/openssh-portable/Makefile:FLAVORS=                   default hpn gssapi
./security/pam_krb5/Makefile:FLAVORS=           mit heimdal_base heimdal_port
./security/qtkeychain/Makefile:FLAVORS= qt5 qt6
./security/sssd/Makefile:FLAVORS=       default smb
./shells/oksh/Makefile:FLAVORS= dynamic static
./sysutils/UEFITool/Makefile:FLAVORS=   qt5 qt6
./sysutils/cpu-x/Makefile:FLAVORS=      gtk3 ncurses
./sysutils/edk2/Makefile:FLAVORS=       macchiatobin fvp rpi3 rpi4 xen_x64 bhyve qemu_x64 qemu_i386
./sysutils/pwsafe/Makefile:FLAVORS=             x11 nox11
./sysutils/s6-rc/Makefile:FLAVORS=      hier run
./sysutils/screenfetch/Makefile:FLAVORS=                default nox11
./sysutils/ssd_report/Makefile:FLAVORS= smart smartmontools
./textproc/fcitx5-qt-common/Makefile:FLAVORS=   # empty
./textproc/fcitx5-gtk-common/Makefile:FLAVORS=  # empty
./www/falkon/Makefile:FLAVORS=  default qtonly
./www/jetty9/Makefile:FLAVORS=  openjdk8 openjdk11
./www/p5-RT-Extension-MandatoryOnTransition/Makefile:FLAVORS=           rt44 rt50
./www/p5-RTx-Calendar/Makefile:FLAVORS= rt44 rt50
./www/rubygem-passenger/Makefile:FLAVORS=       apache nginx
./x11-fm/pcmanfm/Makefile:FLAVORS=      gtk2 gtk3
./x11-servers/xorg-server/Makefile:FLAVORS=     xorg xnest xephyr xvfb
./x11-toolkits/guile-gnome-platform/Makefile:FLAVORS=   lite full
./x11-toolkits/wxgtk30/Makefile:FLAVORS=        gtk3 gtk2
./x11-toolkits/wxgtk32/Makefile:FLAVORS=        gtk3 gtk2
./x11/eww/Makefile:FLAVORS=                     x11 wayland
./x11/gnome/Makefile:FLAVORS=   full lite
./x11/libfm/Makefile:FLAVORS=   gtk2 gtk3
./x11/nvidia-hybrid-graphics/Makefile:FLAVORS=  default 390
./x11/hyprland-share-picker/Makefile:FLAVORS=   qt5 qt6
./x11/waybar/Makefile:FLAVORS=  default hyprland nopulse
./x11/wf-shell/Makefile:FLAVORS=        default nopulse
./x11/workrave/Makefile:FLAVORS=        default xfce
./x11/xdg-desktop-portal-hyprland/Makefile:FLAVORS=     qt5 qt6

I am inclined to fall the flavors "default", "x11" OR "nox11" and "x11", thoughI favorize the former since many ports have a default flavor these days.
Though, I don't know GS good enough, I don't think that X11 is ONE outstanding feature that default flavor should be "nox11".
Comment 8 Michael Osipov 2023-04-24 16:55:57 UTC
Created attachment 241702 [details]
Patch for point 1
Comment 9 Michael Osipov 2023-04-24 17:11:50 UTC
Created attachment 241703 [details]
Patch for point 2

Here is the patch for port flavorization. It reuses only some parts of Chad's patch, but does NOT apply the approach from GS 9. It will be another statically linked device driver like the rest now. Works for me in poudriere.

@diizzy Please have a look also.
Comment 10 Michael Osipov 2023-04-24 18:56:21 UTC
Created attachment 241705 [details]
Patch for point 1
Comment 11 Michael Osipov 2023-04-24 18:56:36 UTC
Created attachment 241706 [details]
Patch for point 2
Comment 12 Michael Osipov 2023-04-24 19:22:29 UTC
Created attachment 241707 [details]
Patch for point 3 + 5

Here is a patch for 3 + 5, based on Chad's patch.

Here is one thing which bugs me I am not certain how to properly solve it: One port requires ghostscript10@default another one ghostscript10@x11.

My patch: both cannot coexist since they install into the same space and both contain statically linked drivers which is now favorized by GS devs.
Chad's patch: Installs base with statically linked drivers, but X11 compiles dynamically which is useless, IMHO, since the actual gs executable has been built for static drivers which obviously won't load the X11.so driver.

Thoughts? Am I wrong? Ideas?
Comment 13 Michael Osipov 2023-04-25 05:39:30 UTC
Like I thought:

[124-release-amd64-default-head] `-- Extracting libXt-1.2.1,1: 100%
pkg-static: ghostscript10-x11-10.01.1_3 conflicts with ghostscript10-10.01.1_3 (installs files into the same place).  Problematic file: /usr/local/bin/dvipdf


with

poudriere bulk -j 124-release-amd64 -p default-head -i graphics/eps2png print/gv
Comment 14 Michael Osipov 2023-04-25 05:41:24 UTC
It really looks like to me that this might better a port OPTION, but dependent port cannot enfore that :-(
Comment 15 Michael Osipov 2023-04-25 08:31:12 UTC
A it turns out, Debian does exactly what I have observed. The port flavors don't make sense:

ghostscript (10.0.0~dfsg-8) unstable; urgency=medium

  * QA upload
  * debian/: No longer build with dynamic modules (Closes: #1023330)
    - X11 support is now part of ghostscript and ghostcript-x is a
      transitional package.

https://packages.debian.org/sid/ghostscript-x where libgs depends on X: https://packages.debian.org/sid/libgs10

==================

Installed Debian 12 Testing: GS is by default linked with X11 libs. Default device is x11alpha and when you invoke GS interactively it of course tries to connect to an X server.

14 ports require X11 which Ghostscript.

So it really looks to be that this should be a port option, the question whether it should be default or not.

Currently, 156 ports define X11 and 104 of them enable X11 by default.
Comment 16 Michael Osipov 2023-04-25 08:48:45 UTC
Created attachment 241733 [details]
Patch for point 1
Comment 17 Chad Jacob Milios 2023-04-25 15:25:07 UTC
(In reply to Michael Osipov from comment #15)

i agree in a perfect world X11 should be made an option and FLAVOR should not be used here; i was only trying to more closely mimic the installation and behavior of the version 7 8 and 9 ports. And as you pointed out however, dependant ports cannot presently enforce OPTIONS in their dependencies. it makes sense some would depend on gs-x11 (which itself depends on gs-base), and allow others to simultaneously depend only on gs-base.

The FLAVORS route (as with the separate-ports route of 7 8 and 9) was set up so the flavors dont conflict with one another, rather -x11 compliments -base (thats why i opted to keep those suffixes rather than go with '' vs -nox11, which to me seemed to imply based on my limited observations made thruout the ports tree that to have no suffix vs a -nox11 suffix would mean theyre mutually exclusive rather than could get installed together, and that the no-suffix version would encompass all the functionality of the lesser and then some)

As you see, ghostscript9-agpl-x11 only installs the one file X11.so (ignoring the obligatory LICENSE in /usr/local/share) and i sought to work as similarly as is prudent

you're probably correct that my decision to put --disable-dynamic in the base flavor and --enable-dynamic in the x11 flavor would build X11.so as utter trash. that's why you're the maintainer and i'm just a pleb :) i'm not actually sure the true dependency graph between libgs.so, gsx, gs's X11.so, and/or any of the ports claiming dependency on ghostscript[789]-x11. i am unclear the context and greater ramifications of {en,dis}able-dynamic.

i have seen ports that USES ghostscript:x11 simply because they themselves utilize x11 yet they're perfectly fine and full featured with libgs.so, without gs's X11.so. i agree the whole tree could use some cleanup around ghostscript and i'd be glad to help with that at your and/or diizzy's direction

i'm currently running a handful of X11 apps through their paces to figure out who actually dynamically links what exactly and why
Comment 18 Michael Osipov 2023-04-25 15:54:51 UTC
Chad for clarification what the library loading is about in C in general and what GS does, this will make it eaiser to understand for you:

1. Static linking: all object code is part of the runtime image (executable) which may result in a huge file (done all at link time)
3. Dynamic linking: executable points to a shared library, executable is small and loader at start time loads the library into memory (may or may not share between other executions), make it replaceable anytime and you don't need to relink your executable
3. loading at runtime: You have a well defined directory full of shared objects, you use dlopen() to load them at runtime and well defined entry points. Exactly what Apache HTTP Server is doing with modules. Same here:
./base/gp_unix.c:    if ((handle = dlopen(buff, RTLD_NOW)) != 0) {

Current setup with GS 10: static linking, after point 1 it is dynamic linking BUT the device drivers are statically integrated into the dynamic library libgs.so, thus not loaded at runtime. GS9 and below do "loading at runtime" which is not deprecated by Artifex that is why Debian doesn't do this anymore.

I hope this helps!

PS: It is a bit confusing ;-)
Comment 19 Michael Osipov 2023-04-25 16:11:22 UTC
(In reply to Chad Jacob Milios from comment #17)

> i agree in a perfect world X11 should be made an option and FLAVOR should not be used here; i was only trying to more closely mimic the installation and behavior of the version 7 8 and 9 ports. And as you pointed out however, dependant ports cannot presently enforce OPTIONS in their dependencies. it makes sense some would depend on gs-x11 (which itself depends on gs-base), and allow others to simultaneously depend only on gs-base.
> 
> The FLAVORS route (as with the separate-ports route of 7 8 and 9) was set up so the flavors dont conflict with one another, rather -x11 compliments -base (thats why i opted to keep those suffixes rather than go with '' vs -nox11, which to me seemed to imply based on my limited observations made thruout the ports tree that to have no suffix vs a -nox11 suffix would mean theyre mutually exclusive rather than could get installed together, and that the no-suffix version would encompass all the functionality of the lesser and then some)
> 
> As you see, ghostscript9-agpl-x11 only installs the one file X11.so (ignoring the obligatory LICENSE in /usr/local/share) and i sought to work as similarly as is prudent

I totally understand your objective here. It, unfortunately, doesn't work for 10 :-(

> you're probably correct that my decision to put --disable-dynamic in the base flavor and --enable-dynamic in the x11 flavor would build X11.so as utter trash. that's why you're the maintainer and i'm just a pleb :) i'm not actually sure the true dependency graph between libgs.so, gsx, gs's X11.so, and/or any of the ports claiming dependency on ghostscript[789]-x11. i am unclear the context and greater ramifications of {en,dis}able-dynamic.

See my preceding explanation.

> i have seen ports that USES ghostscript:x11 simply because they themselves utilize x11 yet they're perfectly fine and full featured with libgs.so, without gs's X11.so. i agree the whole tree could use some cleanup around ghostscript and i'd be glad to help with that at your and/or diizzy's direction

This needs an investigation. I am really now inclined that since X11 is one driver among many, to have it a disabled option by default. We can reconsider if someone starts to complain with a good reason for this.

> i'm currently running a handful of X11 apps through their paces to figure out who actually dynamically links what exactly and why

What you need to figure out whether they use any of the X11 devices at all, if not, they don't need X11. This is my understanding. (could be wrong)

I will meanwhile rework patch for point 2 to a port option.
Comment 20 Michael Osipov 2023-04-28 13:04:49 UTC
Created attachment 241823 [details]
Patch for point 2 (port OPTION)

Here is an alternative to the port FLAVOR.
Comment 21 Michael Osipov 2023-04-28 13:06:05 UTC
Created attachment 241824 [details]
Patch for point 3 + 5 (port OPTION)

Here is an alternative to the port FLAVOR.
Comment 22 Michael Osipov 2023-04-28 13:08:56 UTC
diizzy, please have a look at my alternative. I think it does it's job. Unfortunately, ports which require GS with X11 cannot indicate, but we have to live with that.

Chad, can you go through the listed ports and see whether they link directly to libgs.so? Maybe it just requires some cleanup.
Comment 23 Michael Osipov 2023-05-23 07:23:21 UTC
diizzy, let us know how to process, I like to finalize this before end of the quarter and move myself to GS 10. The GS 9 maintainer is not responding to any bug reports.
Comment 24 Daniel Engberg freebsd_committer freebsd_triage 2023-05-23 20:34:43 UTC
Sorry, I got busy due to circumstances in real life and forgot about this.

Flavoring and dynamic linking looks good, I need to have a closer look at the USES patch and pass it to a few others so we don't overlook anything.

Many thanks for your patience and thanks for the ping :)
Comment 25 Michael Osipov 2023-05-24 05:30:51 UTC
(In reply to Daniel Engberg from comment #24)

Thank you! Please note that flavoring does not work. We need to go with the port OPTION. So we need:
* Patch for point 1
* Patch for point 2 (port OPTION) 
* Patch for point 3 + 5 (port OPTION)
Comment 26 Michael Osipov 2023-06-09 12:40:11 UTC
Gentle ping. Next quarterly is three weeks away. I want to settle this.
Comment 27 Daniel Engberg freebsd_committer freebsd_triage 2023-06-10 10:13:02 UTC
Unless I'm misunderstanding the "quirk" with flavors is that they clash? If that's the case we (in most cases) don't support such a setup (see https://cgit.freebsd.org/ports/tree/graphics/ImageMagick7/Makefile#n27 for example) so I don't think we need to worry about that. I'm not too fond of the idea of using yet another way how we handle variants which looks to be a bit fragile.
Comment 28 Michael Osipov 2023-06-12 06:45:14 UTC
(In reply to Daniel Engberg from comment #27)

Correct, you cannot use them in parallel. The flavors would basically represent the port options. Any combination you try cannot produce the same approach as with the previous version due to the change in the linkning approach.

Which route do you want to go? One of the problems with the flavors is that one port can depend on nox11 and the other on x11 and then you cannot install both, with a port option you could by enabling x11 for both.
Comment 29 Michael Osipov 2023-06-14 09:39:21 UTC
Side note: I have achieved that libtesseract is now externally linkable: https://bugs.ghostscript.com/show_bug.cgi?id=706490 and tested it already in poudiere for the next release. But these chagnes require this one to be solved first.
Comment 30 Daniel Engberg freebsd_committer freebsd_triage 2023-06-14 18:06:29 UTC
Go with flavours, it's what we're moving towards in tree overall.
Comment 31 Michael Osipov 2023-06-14 18:45:59 UTC
(In reply to Daniel Engberg from comment #30)
OK, let me have another look at it tomorrow whether the patches are still fine.
Comment 32 Michael Osipov 2023-06-14 19:00:03 UTC
(In reply to Daniel Engberg from comment #30)

Can you please already apply patch for point 1? It needs to be applied either way to produce the shared library.

What should be the flavor names? I currently have "default" and "x11".
> # grep -r --include='*/Makefile*' FLAVORS= . | grep x11
tells me that my choice is fine or "nox11" and "x11".

I'd expect that if no flavor provided that NO x11 is pulled.
Comment 33 Michael Osipov 2023-06-14 19:41:39 UTC
Question to you folks: For how long should GS 9 be around in the ports tree? No support from upstream. If at least a year, maybe it would be worth the effort to create print/ghostscript9 identical to 10 instead of having -base and -x11?

I am asking since the current GS 9 ignores all open tickets.
Comment 34 Michael Osipov 2023-06-15 10:36:20 UTC
Created attachment 242786 [details]
Patch for point 1
Comment 35 Michael Osipov 2023-06-15 10:37:06 UTC
Created attachment 242787 [details]
Patch for point 2
Comment 36 Michael Osipov 2023-06-15 10:37:32 UTC
Created attachment 242788 [details]
Patch for point 3 + 5
Comment 37 Michael Osipov 2023-06-15 10:38:09 UTC
Rebased patches, still look good to me. Please review.
Comment 38 Daniel Engberg freebsd_committer freebsd_triage 2023-06-17 21:22:47 UTC
Created attachment 242846 [details]
Patch for ghostscript10 (1+2 combined)

So this is 1+2 combined because of convenience

I've substituted some hardcoded values with variables instead to hopefully make it easier to maintain and eventually update to next major version. For the sake of readability we don't require a specific amount of tab (however less is better) rather adopting style to when it's needed while trying to avoid exceeding 78 columns if possible. I've adjusted a few indents where I think it makes it easier to read. While portlint won't complain about it we in general keep non options related stuff in sections above from where we define OPTIONS_ variables in the port Makefile so I've adjusted it accordingly.

Thanks for all the time and work all of you have put into this!
Comment 39 Daniel Engberg freebsd_committer freebsd_triage 2023-06-17 21:28:29 UTC
Created attachment 242848 [details]
Patch for ghostscript10 (1+2 combined) v2

Attach correct patch...
Comment 40 Michael Osipov 2023-06-20 10:02:08 UTC
(In reply to Daniel Engberg from comment #39)
(In reply to Daniel Engberg from comment #38)

Checked the patch. Nice improvements, I think you missed one thing: Since you replaced the major version with '${DISTVERSION:R:R}' you missed to apply this to "libgs.so.10" in Makefile and pkg-plist. I would add a 'GS_MAJOR_VERION=${DISTVERSION:R:R}' use throughout the Makefile and pass 1:1 to PLIST_SUB, then your flexible approach is complete. The rest is totally fine.
Comment 41 Daniel Engberg freebsd_committer freebsd_triage 2023-06-22 22:42:15 UTC
Created attachment 242939 [details]
Patch for ghostscript10 (1+2 combined) v3

Also make use of major version substitution
Comment 42 Michael Osipov 2023-06-23 08:57:01 UTC
Created attachment 242946 [details]
Patch for ghostscript10 (1+2 combined) v3.1

This is the way I expected the patch. GS_MAJOR_VERSION used throughout. Heavily inspired by the openjdk ports. Everything is generic and clear now in the patch.
Comment 43 Daniel Engberg freebsd_committer freebsd_triage 2023-06-23 16:27:24 UTC
The reason why I didn't do it like that is becasue I personally don't like referencing variables that aren't defined when being referenced (readability) if possible but if you're fine with that I'm not going to stop you. :-)
Comment 44 Michael Osipov 2023-06-23 19:01:03 UTC
(In reply to Daniel Engberg from comment #43)

I understand your concern, but if BSD make supports it and it adds consistency, I am using it. ;-) So, I guess we are good with this one (v3.1) and it can be applied?
Comment 45 commit-hook freebsd_committer freebsd_triage 2023-06-24 08:52:10 UTC
A commit in branch main references this bug:

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

commit 22c848a2610119c42e32095a0548ace69926b211
Author:     Chad Jacob Milios <milios@ccsys.com>
AuthorDate: 2023-06-24 07:53:30 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2023-06-24 08:51:24 +0000

    print/ghostscript10: Flavorize and add support for shared library

    Add flavor support, support for shared library and various improvements
    to the port itself. Co-authored by Michael Osipov (maintainer)

    PR:             270989
    Reviewed by:    Michael Osipov (maintainer)

 print/ghostscript10/Makefile  | 118 ++++++++++++++++++++++++++----------------
 print/ghostscript10/pkg-plist |   7 +++
 2 files changed, 80 insertions(+), 45 deletions(-)
Comment 46 Michael Osipov 2023-06-24 09:25:42 UTC
(In reply to commit-hook from comment #45)

Magic, now let's go over to the Uses Makefile...
Comment 47 Matthias Andree freebsd_committer freebsd_triage 2023-06-27 20:11:01 UTC
Comment on attachment 242788 [details]
Patch for point 3 + 5

switching Michael's "patch for point 3 + 5" to "patch" for better BZ presentation
Comment 48 Rene Ladan freebsd_committer freebsd_triage 2023-07-01 10:48:37 UTC
The bindings for Ghostscript 7 and 8 have been removed from the USES
Comment 49 Michael Osipov 2023-07-01 19:57:54 UTC
(In reply to Rene Ladan from comment #48)

Thanks, this is good news. Please note that the Uses Makefile is not broken because it references non-existing ports. I have attached a patch which cleans it up. Can you have a look at it? Tested with Poudriere and it works for me. It is also necessary to MFH afterwards. This one: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=242788&action=diff
Comment 50 Rene Ladan freebsd_committer freebsd_triage 2023-07-02 10:13:24 UTC
(In reply to Michael Osipov from comment #49)

I also removed GhostScript 7 and 8 from the USES Makefile in these two commits. Anyway, looking at the patch for point 3 and 5 now.
Comment 51 Michael Osipov 2023-07-02 17:15:19 UTC
(In reply to Rene Ladan from comment #50)

Thanks, looking forward to your review.
Comment 52 Michael Osipov 2023-07-02 17:38:15 UTC
Created attachment 243151 [details]
Patch for point 3 + 5

René, I have updated the patch for you. Please check this one.
Comment 53 Rene Ladan freebsd_committer freebsd_triage 2023-07-02 17:44:44 UTC
(In reply to Michael Osipov from comment #52)

I already took the changes into account, and updated the _GS_VERSION_MINOR for GhostScript 10.
Comment 54 commit-hook freebsd_committer freebsd_triage 2023-07-02 18:20:24 UTC
A commit in branch main references this bug:

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

commit dd152219f70da0465ee12edb1feeae5e2f802c51
Author:     Rene Ladan <rene@FreeBSD.org>
AuthorDate: 2023-07-02 10:11:36 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-02 18:19:02 +0000

    Mk: ghostscript: modernize

    - add support for GhostScript 10
    - bump versions for dependency lines
    - 9 and agpl are synonymous, represent this in the Makefile

    PR:             270989 (point 3 + 5)
    Reported by:    Chad Jacob Milios <milios@ccsys.com> (original)
    Continued work: Michael Osipov <michael.osipov@siemens.com>
    Reviewed by:    diizzy
    MFH:            2023Q3

 Mk/Uses/ghostscript.mk     | 43 +++++++++++++++++++++++++++----------------
 Mk/bsd.default-versions.mk |  2 +-
 2 files changed, 28 insertions(+), 17 deletions(-)
Comment 55 Michael Osipov 2023-07-02 18:24:46 UTC
(In reply to commit-hook from comment #54)

This looks good to me, should go to 2023Q3 as well since the ports are in sync with head while this is not.

As far as I can see, this issue has been satisifed and can be closed. Daniel, René, thank you for the participation and guidance!
Comment 56 commit-hook freebsd_committer freebsd_triage 2023-07-02 18:44:33 UTC
A commit in branch 2023Q3 references this bug:

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

commit afa132c39bad7dc75f8f8bcb2e7051434643afd7
Author:     Rene Ladan <rene@FreeBSD.org>
AuthorDate: 2023-07-02 10:11:36 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-02 18:43:17 +0000

    Mk: ghostscript: modernize

    - add support for GhostScript 10
    - bump versions for dependency lines
    - 9 and agpl are synonymous, represent this in the Makefile

    PR:             270989 (point 3 + 5)
    Reported by:    Chad Jacob Milios <milios@ccsys.com> (original)
    Continued work: Michael Osipov <michael.osipov@siemens.com>
    Reviewed by:    diizzy
    MFH:            2023Q3

    (cherry picked from commit dd152219f70da0465ee12edb1feeae5e2f802c51)

 Mk/Uses/ghostscript.mk     | 43 +++++++++++++++++++++++++++----------------
 Mk/bsd.default-versions.mk |  2 +-
 2 files changed, 28 insertions(+), 17 deletions(-)
Comment 57 Daniel Engberg freebsd_committer freebsd_triage 2023-07-02 19:16:31 UTC
Thanks to everyone involved for your contributions, patience and to mandree and rene for additional reviewing and guidance.
Comment 58 Peter Much 2023-07-04 00:34:05 UTC
Something is not working well here (2023Q3):

ERROR: path missing: /usr/ports/print/print/ghostscript9-agpl-base

root@vbuild0:/usr/ports/Mk/Uses # cd ../../graphics/graphviz/
root@vbuild0:/usr/ports/graphics/graphviz # make -V LIB_DEPENDS
libltdl.so:devel/libltdl  libpng.so:graphics/png  libwebp.so:graphics/webp  libfreetype.so:print/freetype2  libfontconfig.so:x11-fonts/fontconfig  libexpat.so:textproc/expat2  libharfbuzz.so:print/harfbuzz  libgd.so:graphics/gd libgs.so:print/print/ghostscript9-agpl-base libpoppler-glib.so:graphics/poppler-glib libjpeg.so:graphics/jpeg-turbo libatk-1.0.so:accessibility/at-spi2-core libcairo.so:graphics/cairo libglib-2.0.so:devel/glib20  libintl.so:devel/gettext-runtime libgtk-x11-2.0.so:x11-toolkits/gtk20 libpango-1.0.so:x11-toolkits/pango libintl.so:devel/gettext-runtime
Comment 59 Michael Osipov 2023-07-04 05:35:52 UTC
(In reply to Peter Much from comment #58)

Let me check...
Comment 60 Michael Osipov 2023-07-04 06:27:24 UTC
(In reply to Peter Much from comment #58)

I can reproduce it now in Poudriere, but don't yet understand...
Comment 61 Michael Osipov 2023-07-04 08:14:22 UTC
(In reply to Peter Much from comment #58)

Found it. The port was broken already, but never noticed because it just worked accidentially. Read https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270989#c6 and especially https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270989#c4

A port cannot use variables starting with an underscope, they are an implementation detail, so the failure is expected, like I have described in the comment. Yet another problem print/{PORT} is logically wrong because PORT != PKGNAME, so you end up in print/print/ghostscript...

Not only the grepped ports need to be cleaned up as mentioned, we also need and always needed USES=ghostscript:lib

Willing to work on a patch if a committer will have a look and commit, no issue.
Comment 62 Michael Osipov 2023-07-04 19:26:48 UTC
FTR:

===========
root@deblndw011x:/var/poudriere/ports/default-head/graphics/graphviz (main =)
# git diff -U0 origin/2023Q3... -- Makefile
diff --git a/graphics/graphviz/Makefile b/graphics/graphviz/Makefile
index bf9a8bf286f5..6f7fe8668fb4 100644
--- a/graphics/graphviz/Makefile
+++ b/graphics/graphviz/Makefile
@@ -115 +115 @@ PHP_LIB_DEPENDS=    libpcre.so:devel/pcre \
-GHOSTSCRIPT_LIB_DEPENDS=   libgs.so:print/${_GS_PORT}
+GHOSTSCRIPT_LIB_DEPENDS=   libgs.so:${_GS_PORT}
# git show 78cbcc365c098
commit 78cbcc365c098b3e1bd17683ff24ff7202f14b62
Author: Dima Panov <fluffy@FreeBSD.org>
Date:   2023-07-03T10:30:28+02:00

    graphics/graphviz: unbreak build with GHOSTSCRIPT enabled after dd152219f70d

    Global variable _GS_PORT now have cathegory defined

    Error: graphics/graphviz depends on nonexistent origin 'print/print/ghostscript9-agpl-base';

    Reported by:    poudriere fallout
    Approved by:    portmgr blanket

diff --git a/graphics/graphviz/Makefile b/graphics/graphviz/Makefile
index bf9a8bf286f5..6f7fe8668fb4 100644
--- a/graphics/graphviz/Makefile
+++ b/graphics/graphviz/Makefile
@@ -112,7 +112,7 @@ GUILE_LIB_DEPENDS=  libguile-2.2.so:lang/guile2 \
            libgc-threaded.so:devel/boehm-gc-threaded
 PHP_LIB_DEPENDS=   libpcre.so:devel/pcre \
            libargon2.so:security/libargon2
-GHOSTSCRIPT_LIB_DEPENDS=   libgs.so:print/${_GS_PORT}
+GHOSTSCRIPT_LIB_DEPENDS=   libgs.so:${_GS_PORT}

 XPM_CONFIGURE_WITH=        x
 XPM_CONFIGURE_ENV=     ac_cv_header_sys_inotify_h=no
===========

I still consider it wrong, though it works.
Comment 63 Rene Ladan freebsd_committer freebsd_triage 2023-07-04 19:28:17 UTC
(In reply to Michael Osipov from comment #61)

> Not only the grepped ports need to be cleaned up as mentioned, we also need and > always needed USES=ghostscript:lib

Yes, I concluded the same in a mail to ports-committers@                                                                                                                                                         
                                                                                                                                                                                                                 
> Willing to work on a patch if a committer will have a look and commit, no                                                                                                                                      
> issue.                                                                                                                                                                                                         
>                                                                                                                                                                                                                
Happy to commit a patch.
Comment 64 Michael Osipov 2023-07-05 07:16:30 UTC
(In reply to Rene Ladan from comment #63)

Working on it...
Comment 65 Michael Osipov 2023-07-05 08:47:38 UTC
Created attachment 243258 [details]
Add lib arg support to ghostscript.mk
Comment 66 Michael Osipov 2023-07-05 08:48:01 UTC
Created attachment 243259 [details]
Fix graphics/xfig
Comment 67 Michael Osipov 2023-07-05 08:48:21 UTC
Created attachment 243260 [details]
Fix graphics/inkscape
Comment 68 Michael Osipov 2023-07-05 08:48:38 UTC
Created attachment 243261 [details]
Fix graphics/graphviz
Comment 69 Michael Osipov 2023-07-05 08:51:16 UTC
(In reply to Rene Ladan from comment #63)

Attached a series of four patches which need to be applied in order. They address one bug in ghostscript.mk and introduce ghostscript:lib for downstream ports. graphics/graphviz is a bit tricky because it adds ghostcript twice which isn't supported by the system. Add a merging solution.

Please review. These patches need to be cherry-picked to 2023Q3 as well.
Comment 70 Michael Osipov 2023-07-05 08:54:40 UTC
Tried arg permutations:

args: output
============
9,run: ghostscript9-agpl-base>=9.56.1:print/ghostscript9-agpl-base
9,run,x11: ghostscript9-agpl-base>=9.56.1:print/ghostscript9-agpl-base ghostscript9-agpl-x11>=9.56.1:print/ghostscript9-agpl-x11
10,run: ghostscript10>=10.01.2:print/ghostscript10
10,run,x11: ghostscript10-x11>=10.01.2:print/ghostscript10@x11

9,lib: libgs.so:print/ghostscript9-agpl-base
9,lib,x11: libgs.so:print/ghostscript9-agpl-base libgs.so:print/ghostscript9-agpl-x11
10,lib: libgs.so:print/ghostscript10
10,lib,x11: libgs.so:print/ghostscript10@x11
Comment 71 Rene Ladan freebsd_committer freebsd_triage 2023-07-05 21:00:25 UTC
(In reply to Michael Osipov from comment #70)

Hmm, so some permutations with ,x11 now generate two dependency lines? This shouldn't be a problem I think, it just looks a bit off.
Comment 72 Rene Ladan freebsd_committer freebsd_triage 2023-07-05 21:04:09 UTC
(In reply to Michael Osipov from comment #65)

Hmm, around line 100 the test for _GS_FLAVORED flipped?

-.      if defined(_GS_FLAVORED) || !${_GS_ARGS:Mx11}
+.      if !defined(_GS_FLAVORED) || !${_GS_ARGS:Mx11}
Comment 73 Michael Osipov 2023-07-06 09:12:28 UTC
(In reply to Rene Ladan from comment #71)

That is on purpose for 9 because for X11 you need the base package AND the X1! package which contains X11.so which ist loaded at runtime by libgs.so.
Comment 74 Michael Osipov 2023-07-06 09:13:18 UTC
(In reply to Rene Ladan from comment #72)

As described in the commit message, that is a bug I haven't noticed because. That is why I tried the permutations. Without that fix 9 will not have two deps and miss X11 while 10 will try to install two conflicting flavors.
Comment 75 Rene Ladan freebsd_committer freebsd_triage 2023-07-06 19:49:45 UTC
(In reply to Michael Osipov from comment #74)

Ah, thanks for explaining :)
Comment 76 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:08:11 UTC
A commit in branch main references this bug:

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

commit 8ea04d0733a1b2f6d3b2ffc10ebde2f63239444a
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 20:05:12 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:06:38 +0000

    graphics/inkscape: migrate to USES=ghostscript:run

    PR:             270989

 graphics/inkscape/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Comment 77 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:08:13 UTC
A commit in branch main references this bug:

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

commit dbbf45e73697231a124b467b90dc2f111c3f5cda
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 20:03:09 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:03:41 +0000

    graphics/graphviz: migrate to USES=ghostscript:lib

    PR:             270989

 graphics/graphviz/Makefile | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
Comment 78 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:08:14 UTC
A commit in branch main references this bug:

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

commit 8a465330a8998fd7e49cc5c5f99e37c943140a20
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 19:56:55 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:00:16 +0000

    Mk/Uses: teach USES=ghostscript to support LIB_DEPENDS

    While here fix a logic bug in calculating dependencies.
    PR:             270989

 Mk/Uses/ghostscript.mk | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
Comment 79 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:08:16 UTC
A commit in branch main references this bug:

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

commit 9f2a9b6796ee50611664614a5ced46757e61bdc2
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 20:01:22 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:02:31 +0000

    graphics/xfig: migrate to USES=ghostscript:lib

    PR:             270989

 graphics/xfig/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 80 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:45:25 UTC
A commit in branch 2023Q3 references this bug:

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

commit e665f400d5f7923033ea5c364e4a3d01b5f87972
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 19:56:55 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:41:37 +0000

    Mk/Uses: teach USES=ghostscript to support LIB_DEPENDS

    While here fix a logic bug in calculating dependencies.
    PR:             270989

    (cherry picked from commit 8a465330a8998fd7e49cc5c5f99e37c943140a20)

 Mk/Uses/ghostscript.mk | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
Comment 81 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:45:27 UTC
A commit in branch 2023Q3 references this bug:

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

commit ff8050cc28d8c6e2a467d903d5f27605508da25b
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 20:03:09 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:43:11 +0000

    graphics/graphviz: migrate to USES=ghostscript:lib

    PR:             270989
    (cherry picked from commit dbbf45e73697231a124b467b90dc2f111c3f5cda)

 graphics/graphviz/Makefile | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
Comment 82 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:45:28 UTC
A commit in branch 2023Q3 references this bug:

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

commit ab0dbeaf0a655a391d897918b102c4a6644978a0
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 20:05:12 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:44:07 +0000

    graphics/inkscape: migrate to USES=ghostscript:run

    PR:             270989
    (cherry picked from commit 8ea04d0733a1b2f6d3b2ffc10ebde2f63239444a)

 graphics/inkscape/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Comment 83 commit-hook freebsd_committer freebsd_triage 2023-07-06 20:45:30 UTC
A commit in branch 2023Q3 references this bug:

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

commit 7b1c375b1ba074eb654e915a6c6df433652b187c
Author:     Michael Osipov <michael.osipov@siemens.com>
AuthorDate: 2023-07-06 20:01:22 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-07-06 20:41:58 +0000

    graphics/xfig: migrate to USES=ghostscript:lib

    PR:             270989
    (cherry picked from commit 9f2a9b6796ee50611664614a5ced46757e61bdc2)

 graphics/xfig/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 84 Michael Osipov 2023-07-07 06:53:54 UTC
(In reply to Peter Much from comment #58)

Peter, please try this on your end. It should work for you now as expected.
Comment 85 Peter Much 2023-07-10 07:56:38 UTC
(In reply to Michael Osipov from comment #84)
Confirmed, things work fine now here. :)

I also took the time to read this whole issue and understand what it is about. This is not a bug report, it rather is a really nice development+tutorial work. Well done & thank You for the effort!

Concerning the x11 switch on the ghostscript: I always wondered why the port does magically change it's name whether I switch the X11 option on or off (back some 20 yrs ago, when one could select the drivers individually). I found it disturbing, as x11 is just another driver - but then, at that time we used to consider whether to install x11 on a target, or whether to install compilers on a target, etc.etc., because the disks might not fit all of it.
So from my understanding, the X11 switch is a systemwide switch, there should not be an issue that some port would require ghoststript specifically with or without X.
Comment 86 Michael Osipov 2023-07-10 10:03:31 UTC
(In reply to Peter Much from comment #85)

The problem/challenge with 10 is that all drivers are now integrated into libgs.so and loading them dynamically from libgs.so, e.g. epson.so, X11.so, pcl.so is discouraged/deprecated (though you can configure this at compile time) since they leak symbols to the outside world and can cause collisions. Therefore, there is no real way to satisfy both needs: those who don't want anything installed from X11 and those who need to visualize something.
Comment 87 Peter Much 2023-07-10 13:03:45 UTC
(In reply to Michael Osipov from comment #86)
Yes, in this case it seems creating two mutually exclusive versions is the only way.
Comment 88 Michael Osipov 2023-07-11 07:07:59 UTC
Guys, please close the issue.
Comment 89 Michael Osipov 2023-08-31 13:24:07 UTC
Chad, please note Bug 272541.