154.3. ghostscript-10.08.0
PostScript and PDF interpreter
| Version | 10.08.0, release 1 |
| Shelf | printing — Printing, printer drivers, labels, scanning and OCR |
| Phase | 41_system (System), 102 of 1047 in build order |
| Licence | AGPL-3.0-or-later |
| Homepage | https://www.ghostscript.com/ |
| Build time | 3.1 SBU |
| Installed size | 33.7 MiB in 215 files |
| Recipe | ports/core/printing/ghostscript/kpkgbuild |
About
Ghostscript interprets PostScript and PDF and renders them to a printer’s language, a raster or another document format. In KDOS it is where print jobs and OCR pipelines end: the CUPS filters turn a PDF into the raster or page description a printer takes through it, and ocrmypdf and other document tools call gs. This build installs Ghostscript as a shared library, libgs, with gs as a small program that loads it.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/printing.txt:
Where every print queue and every OCR pipeline ends. --with-system-libtiff and friends, because the bundled copies build fine and then the machine carries two of each and only one gets a security fix.
Sources
ghostscript-10.08.0.tar.xz(66.0 MiB)
sha256c20492bc8ebb96c87fa2e52a0926e1cda8cde95d66145e018ac713fed5da38cf
upstream: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10080/ghostscript-10.08.0.tar.xz
archive copy: sources-3/printing--ghostscript-10.08.0.tar.xz
Dependencies
Depends on: brotli, freetype2, fontconfig, libjpeg-turbo, libpng, libtiff, libidn, jbig2dec, openjpeg, zlib, cups, libpaper.
Required by (22): cups-filters, fig2dev, foomatic-db, foomatic-db-engine, gimp, gnuastro, goffice, graphicsmagick, groff, hplip, kdegraphics-thumbnailers, kimageformats, libcupsfilters, libppd, libspectre, lyx, netpbm, ocrmypdf, octave, splix, texlive, veusz.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
--disable-gtk, line 16: gtk3 (explained with the switches below)--disable-dbus, line 24: dbus (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
sprintf-guard.patch— Add#undef sprintfafter the includes ofbase/mkromfs.candcups/gdevcups.c. Both#define sprintf sprintfbefore their includes so that Ghostscript’sstdio_.hleavessprintfalone instead of turning it into the poison nameDO_NOT_USE_SPRINTF; the fortified<stdio.h>this tree compiles against, whichstdio_.hincludes before that check,#undefssprintf, so the guard is gone and the files’ ownsprintf()calls would reach the poison name.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install ghostscript'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/printing/ghostscript.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/printing/ghostscript
echo 'c20492bc8ebb96c87fa2e52a0926e1cda8cde95d66145e018ac713fed5da38cf ghostscript-10.08.0.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/ghostscript
SRC=$SRC_ROOT/ghostscript-10.08.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ghostscript-10.08.0.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _tag and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
rm -rf brotli freetype jbig2dec jpeg libpng tiff zlib openjpeg
patch -p1 -i "$PORT_SRC/sprintf-guard.patch"
CC="gcc -std=gnu11" CFLAGS="${CFLAGS/-std=gnu11/}" ./configure --prefix=/usr --libdir=/usr/lib \
--with-system-libtiff --disable-gtk \
--with-drivers=ALL --without-x \
--enable-fontconfig \
--enable-cups --with-pdftoraster \
--enable-openjpeg \
--with-jbig2dec \
--with-libidn \
--with-libpaper \
--disable-dbus
make so
make DESTDIR=$PKG soinstall
ln -sf gsc "$PKG/usr/bin/gs"
The switches, and why each is set:
--with-system-libtiff— Link the libtiff port. With the bundledbrotli,freetype,jbig2dec,jpeg,libpng,tiff,zlibandopenjpegdirectories deleted first (therm -rf), configure finds the system copy of each. Ghostscript decides between its copy and the system’s by whether the directory exists, and refuses to mix them (“Mixing local libtiff with shared libjpeg not supported”), so the directories are removed rather than switched off. The machine then carries one copy of each library, the one its port updates.--disable-gtk— Buildgsx, the loader that would show pages in a GTK window, from the same text-onlydxmainc.casgsc, so it links no GTK.--with-drivers=ALL— Compile every output device intolibgs, printers included.--without-x— Build no X11 display device.--enable-fontconfig— Find system fonts through fontconfig for fonts a document names but does not embed.--enable-cups— Build thecupsraster output device, which writes CUPS raster for the printer drivers, and with--with-pdftorasterCUPS’pdftorasterfilter.--enable-openjpeg— Decode JPEG 2000 images in PDFs with openjpeg.--with-jbig2dec— Decode JBIG2 images with jbig2dec.--with-libidn— Prepare Unicode PDF passwords with libidn (SASLprep).--with-libpaper— Take the default paper size from libpaper.--disable-dbus— Do not use D-Bus to talk to other services.CC="gcc -std=gnu11"— Ghostscript’s build addsCFLAGSto its C++ compiles too, so the C standard is moved out ofCFLAGS(CFLAGS="${CFLAGS/-std=gnu11/}") intoCC, which only the C compiler runs as; see C flags handed to the C++ compiler.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/ghostscript, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf ghostscript-10.08.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/ghostscript, and runs the triggers its paths call for.
Contents
Installed programs: dvipdf, eps2eps, gs, gsbj, gsc, gsdj, gsdj500, gslj, gslp, gsnd, gsx, lprsetup.sh, pdf2dsc, pdf2ps, pf2afm, pfbtopfa, pphs, printafm, ps2ascii, ps2epsi, ps2pdf, ps2pdf12, ps2pdf13, ps2pdf14, ps2pdfwr, ps2ps, ps2ps2, unix-lpr.sh.
Installed libraries: libgs.so.
Installed directories: /usr/include/ghostscript, /usr/share/doc/ghostscript, /usr/share/ghostscript, /usr/share/licenses/ghostscript.
Short descriptions
dvipdf |
Convert TeX DVI file to PDF using ghostscript and dvips |
gs |
Ghostscript (PostScript and PDF language interpreter and previewer) |
gslp |
Format and print text using ghostscript gsbj - Format and print text for BubbleJet printer using ghostscript gsdj - Format and print text for DeskJet printer using ghostscript gsdj500 - Format and print text for DeskJet 500 BubbleJet using ghostscript gslj - Format and print text for LaserJet printer using ghostscript |
gsnd |
Run ghostscript (PostScript and PDF engine) without display |
pdf2ps |
Ghostscript PDF to PostScript translator |
pf2afm |
Make an AFM file from Postscript (PFB/PFA/PFM) font files using ghostscript |
pfbtopfa |
Convert Postscript .pfb fonts to .pfa format using ghostscript |
printafm |
Print the metrics from a Postscript font in AFM format using ghostscript |
ps2ascii |
Ghostscript translator from PostScript or PDF to text |
ps2epsi |
generate conforming Encapsulated PostScript |
ps2pdf |
Convert PostScript to PDF using ghostscript ps2pdf12 - Convert PostScript to PDF 1.2 (Acrobat 3-and-later compatible) using ghostscript ps2pdf13 - Convert PostScript to PDF 1.3 (Acrobat 4-and-later compatible) using ghostscript ps2pdf14 - Convert PostScript to PDF 1.4 (Acrobat 5-and-later compatible) using ghostscript |
ps2pdfwr |
Convert PostScript to PDF without specifying CompatibilityLevel, using ghostscript |
ps2ps |
Ghostscript PostScript "distiller" |
Notes
make so and make soinstall build and install the shared-library form: libgs.so and the loaders gsc and gsx. build.sh links gs to gsc, because the shared install names its text loader gsc and every caller runs gs. With every driver compiled in, --enable-dynamic (loadable drivers) would add nothing; upstream deprecates it and refuses it beside its default hidden visibility.
Not every bundled directory goes. lcms2mt stays because Ghostscript uses its own thread-safe fork of Little CMS, which the system lcms2 is not; leptonica and tesseract stay because they are the OCR device, locked to Ghostscript’s version of them, and configure builds that device only from its own source directories. extract (the Office document writers) and ijs stay as well; no port in the tree builds either. These copies are compiled into libgs.