Skip to content

ghostscript: use the registry's zlib; drop the bundled tesseract OCR - #1574

Open
bryan-minimal wants to merge 1 commit into
mainfrom
ghostscript-system-libs
Open

bryan-minimal wants to merge 1 commit into
mainfrom
ghostscript-system-libs

Conversation

@bryan-minimal

Copy link
Copy Markdown
Member

Makes packages/ghostscript use the registry's zlib instead of the copy bundled in the 10.08.0 tarball, and drops the bundled tesseract/leptonica OCR. From the ghostscript row of the 2026-11-18 unbundle survey; pkgs#1541 (or-tools) is the model.

What changed

Ghostscript's configure uses a bundled library whenever that library's directory exists in the source tree, so build.sh deletes the directory. Debian does the same thing with Files-Excluded.

Bundled dir Action Why
zlib/ (zlib 1.3.2) deleted; zlib added to build_deps + runtime_deps We package zlib, and Debian excludes zlib/*. The libpng and freetype that gs already links also link libz, so until now a gs process carried two zlibs, and pkgscan could not see the bundled one.
tesseract/, leptonica/ deleted; --without-tesseract This is the largest compile in the package (C++). configure can only use these bundled copies, never a system tesseract. Debian excludes both.
freetype, lcms2mt, jpeg, libpng, openjpeg unchanged (already deleted on main)
brotli/ (1.2.0) kept We package brotli 1.2.1, but Debian keeps gs's copy (no libbrotli-dev build-dep). Separate follow-up if wanted.
jbig2dec, ijs, extract, tiff, cups/libs kept Not packaged here.
expat n/a The ghostscript tarball has no expat/ dir. configure only looks for expat when xps/xps.mak exists, which is only in the full ghostpdl tree, so gs never linked expat. No expat dep was added.

runtime_deps: subsetOf gcc ["libgcc", "libstdcpp"] becomes ["libgcc"]. libstdc++ was only needed for tesseract; without it gs is plain C.

Fail-closed checks in build.sh

  • After configure: the generated Makefile must have SHARE_ZLIB=1 and OCR_VERSION=0.
  • After install: readelf -d usr/bin/gs must list libz.so.1 and must not list libstdc++*. The full NEEDED list is printed to the build log.

User-visible change

The OCR output devices are removed: ocr, hocr, pdfocr8, pdfocr24, pdfocr32. Before this PR, gs -sDEVICE=pdfocr24 ... produced a searchable PDF with a text layer recognised by the built-in tesseract, and ocr/hocr wrote text or hOCR. Those commands now fail with Unknown device. All other devices are unaffected. To OCR a document, run the rendered image through a standalone tesseract.

A grep of packages/ for pdfocr, hocr, ghostscript and tesseract finds nothing outside this package, and no package imports ghostscript.

Observation (pre-existing, not changed here)

--with-system-libtiff is passed, but no libtiff package exists. configure's xyes branch then prints "Disabling tiff and xps output devices", so on main the tiff* and fax (tiffg3/tiffg4/faxg*) devices and xpswrite are already missing. Dropping the flag would build the bundled tiff/ instead. That is a separate decision.

🤖 Generated with Claude Code

configure uses a bundled library whenever its directory is in the source
tree. build.sh now also deletes zlib/ (bundled zlib 1.3.2), so gs links
the zlib package, and builds --without-tesseract with the tesseract and
leptonica trees deleted (the largest compile in the package). Debian
excludes all three trees.

User-visible: the ocr, hocr, pdfocr8, pdfocr24 and pdfocr32 devices are
gone. No registry package uses them.

build.sh fails closed if configure keeps a bundled zlib or OCR, if gs
does not need libz.so.1, or if it still needs libstdc++ (libstdcpp is
dropped from runtime_deps: it was only for tesseract).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 18, 2026 20:38
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 57 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 63 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9cebbef and 81c1e2d.

Files selected for processing: 2

  • packages/ghostscript/build.ncl
  • packages/ghostscript/build.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope matches the title. Both files change only what the PR body states: the zlib dependency, the deleted zlib, tesseract and leptonica trees, --without-tesseract, and the fail-closed checks.

Clobber none. #1372 added libstdcpp to runtime_deps because gs loaded it. This PR removes it together with its only stated consumer, and build.sh fails if gs still needs libstdc++.

Correctness The change is good. zlib is in build_deps and runtime_deps, and the zlib package ships the header, zlib.pc and libz.so*. The readelf pipeline fails closed: an empty result fails the libz.so.1 check. readelf comes from binutils through toolchain. No other package or stack imports ghostscript or names the removed OCR devices. The gs --version smoketest loads the binary, so a missing libz.so.1 at runtime fails it.

Not checked I did not build the package. I did not read the upstream 10.08.0 Makefile.in and configure.ac, because the fetch was denied. So the exact lines SHARE_ZLIB=1 and OCR_VERSION=0, and the claim that gs is plain C without tesseract, are not confirmed. A mismatch fails the build and does not ship a bad package.

glibc,
subsetOf gcc ["libgcc", "libstdcpp"],
# libstdcpp was for the bundled tesseract OCR (C++), now not built;
# build.sh fails if gs still needs libstdc++.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · This comment tells the history of the change, not the state of the code. After the merge, libstdcpp is not in the file, so the reader has nothing to attach "was for ... now not built" to. Write the present fact, for example: "gs is plain C without the bundled tesseract. build.sh fails if it needs libstdc++." The same pattern is in build.sh at lines 8-9 ("before, one gs process carried two zlibs") and line 60-61 ("build.ncl no longer carries libstdcpp").

# Fail closed: gs must link the registry's zlib (libz.so.1), and without
# tesseract it is plain C, so it must not need libstdc++ (build.ncl no longer
# carries libstdcpp as a runtime dep).
command -v readelf >/dev/null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · If readelf is absent, this line ends the build under set -e and prints nothing. Every other guard in this script prints an ERROR line first. Add a message, or remove the line: an absent readelf gives an empty needed, and the libz.so.1 check then fails with its own message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants