Skip to the content.

46. Printing


This chapter contains spooling printer management systems and ghostscript applications to render PostScript for display on terminals or paper.

46.1 Cups-2.4.2


Introduction to Cups

The Common Unix Printing System (CUPS) is a print spooler and associated utilities. It is based on the “Internet Printing Protocol” and provides printing services to most PostScript and raster printers.

This package is known to build and work properly using an LFS 11.3 platform.

Package Information

Cups Dependencies

Required

GnuTLS-3.8.0

colord-1.4.6, dbus-1.14.6, libusb-1.0.26, Linux-PAM-1.5.2, and xdg-utils-1.1.3

Optional

Avahi-0.8, libpaper-1.1.24+nmu5, MIT Kerberos V5-1.20.1, PHP-8.2.3, and Python-2.7.18

Required (Postinstall)

cups-filters-1.28.16

Optional (Postinstall)

Gutenprint-5.3.4 and hplip (HP printers)

User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/cups

Kernel Configuration

Note

There used to be a conflict between the Cups libusb backend and the usblp kernel driver. This is no longer the case and cups will work with both of these enabled.

If you want to use the kernel usblp driver (for example, if you wish to use escputil from Gutenprint-5.3.4) enable the following options in your kernel configuration and recompile the kernel:

Device Drivers  --->
    [*] USB support  --->                            [CONFIG_USB_SUPPORT]
        <*/M>  OHCI HCD (USB 1.1) support            [CONFIG_USB_OHCI_HCD]
        <*/M>  UHCI HCD (most Intel and VIA) support [CONFIG_USB_UHCI_HCD]
        <*/M>  USB Printer support                   [CONFIG_USB_PRINTER]

If you have a parallel printer, enable the following options in your kernel configuration and recompile the kernel:

Device Drivers  --->
    <*/M> Parallel port support  --->       [CONFIG_PARPORT]
        <*/M> PC-style hardware             [CONFIG_PARPORT_PC]
    Character devices  --->
        <*/M> Parallel printer support      [CONFIG_PRINTER]

Installation of Cups

You will need to add an lp user, as Cups will create some files owned by this user. (The lp user is the default used by Cups, but may be changed to a different user by passing a parameter to the configure script.) Use the following command as the root user:

useradd -c "Print Service User" -d /var/spool/cups -g lp -s /bin/false -u 9 lp

You will also need a dedicated group that will contain users allowed to do Cups administrative tasks. Add the group by running the following command as the root user:

groupadd -g 19 lpadmin

If you want to add a user to the Cups administrative group, run the following command as the root user:

usermod -a -G lpadmin <username>

If you didn’t install xdg-utils-1.1.3, use the following sed to change the default browser that will be used to access the Cups web interface:

sed -i 's#@CUPS_HTMLVIEW@#firefox#' desktop/cups.desktop.in

Replace firefox with the web browser of your choice.

Build Cups by running the following commands:

./configure --libdir=/usr/lib            \
            --with-system-groups=lpadmin \
            --with-docdir=/usr/share/cups/doc-2.4.2 &&
make

To test the results, issue: LC_ALL=C make -k check. An already active graphical session with bus address is necessary to run the tests. Make sure that there is not other instance of Cups running, otherwise at least 4 tests will fail with “address in use”. One test, httpAddrGetList, is known to fail.

Now, as the root user:

make install &&
ln -svnf ../cups/doc-2.4.2 /usr/share/doc/cups-2.4.2

Create a basic Cups client configuration file by running the following command as the root user:

echo "ServerName /run/cups/cups.sock" > /etc/cups/client.conf

Note

This package installs icon files into the /usr/share/icons/hicolor hierarchy and you can improve system performance and memory usage by updating /usr/share/icons/hicolor/index.theme. To perform the update you must have GTK+-2.24.33 or GTK+-3.24.36 installed and issue the following command as the root user:

gtk-update-icon-cache -qtf /usr/share/icons/hicolor

Command Explanations

sed … configure: This sed removes a compiler option which is no longer supported. Leaving this change out, the compilation will run thru but a warning about an invalid warning option will be emitted on every compiler invocation.

CC=gcc CXX=g++: Setting them if you prefer to use gcc instead of clang, which is now preferred by the upstream.

--with-system-groups=lpadmin: This switch ensures that only lpadmin will be used as the Cups administrative group.

--disable-libusb: Use this switch if you have installed libusb-1.0.26, but wish to use the kernel usblp driver.

--enable-libpaper: Use this switch if you have installed libpaper and wish to use it with Cups.

Configuring Cups

Config Files

/etc/cups/*

Configuration Information

Normally, printers are set up via a web browser. The Cups server will normally connect via the url http://localhost:631. From there printers, print jobs, and the server configuration can be set up and managed. Remote system administration can also be set up. Configuration can also be done from the command line via the lpadmin, lpoptions, and lpstat commands.

Configuration of Cups is dependent on the type of printer and can be complex. Generally, PostScript printers are easier. For detailed instructions on configuration and use of Cups, see https://www.cups.org/documentation.html.

For non-PostScript printers to print with Cups, you need to install ghostscript-10.00.0 to convert PostScript to raster images and a driver (e.g. from Gutenprint-5.3.4) to convert the resulting raster images to a form that the printer understands. Foomatic drivers use ghostscript-10.00.0 to convert PostScript to a printable form directly, but this is considered suboptimal by Cups developers.

Linux PAM Configuration

If CUPS has been built with Linux PAM support, you need to create a PAM configuration file to get it working correctly with BLFS.

Issue the following command as the root user to create the configuration file for Linux PAM:

cat > /etc/pam.d/cups << "EOF"
# Begin /etc/pam.d/cups

auth    include system-auth
account include system-account
session include system-session

# End /etc/pam.d/cups
EOF

Systemd Unit

To start the cupsd daemon when something tries to access it, enable the previously installed systemd units by running the following command as the root user:

systemctl enable cups

Contents

Installed Programs: cancel, cupsaccept, cups-config, cupsctl, cupsd, cupsdisable, cupsenable, cupsfilter, cupsreject, cupstestppd, ippeveprinter, ipptool, lp, lpadmin, lpc, lpinfo, lpmove, lpoptions, lpq, lpr, lprm, lpstat, ppdc, ppdhtml, ppdi, ppdmerge, and ppdpo

Installed Libraries: libcupsimage.so and libcups.so

Installed Directories: /etc/cups, /usr/{include,lib,share}/cups, /usr/share/doc/cups-2.4.2, and /var/{cache,log,run,spool}/cups

Short Descriptions

cancel cancels existing print jobs from the print queues.

cupsaccept accept jobs sent to a destination.

cups-config is a Cups program configuration utility.

cupsctl updates or queries the cupsd.conf file for a server.

cupsd is the scheduler for the Common Unix Printing System.

cupsdisable stop printers and classes.

cupsenable start printers and classes.

cupsfilter is a front-end to the Cups filter subsystem which allows you to convert a file to a specific format.

cupsreject reject jobs sent to a destination.

cupstestppd tests the conformance of PPD files.

ippeveprinter is an IPP Everywhere printer for CUPS.

ipptool sends IPP requests to the specified URI and tests and/or displays the results.

lp submits files for printing or alters a pending job.

lpadmin configures printer and class queues provided by Cups.

lpc provides limited control over printer and class queues provided by Cups.

lpinfo lists the available devices or drivers known to the Cups server.

lpmove moves the specified job to a new destination.

lpoptions displays or sets printer options and defaults.

lpq shows the current print queue status on the named printer.

lpr submits files for printing.

lprm cancels print jobs that have been queued for printing.

lpstat displays status information about the current classes, jobs, and printers.

ppdc compiles PPDC source files into one or more PPD files.

ppdhtml reads a driver information file and produces a HTML summary page that lists all of the drivers in a file and the supported options.

ppdi imports one or more PPD files into a PPD compiler source file.

ppdmerge merges two or more PPD files into a single, multi-language PPD file.

ppdpo extracts UI strings from PPDC source files and updates either a GNU gettext or Mac OS X strings format message catalog source file for translation.

libcups.so contains the Cups API functions.

46.2 cups-filters-1.28.16


Introduction to CUPS Filters

The CUPS Filters package contains backends, filters and other software that was once part of the core CUPS distribution but is no longer maintained by Apple Inc.

This package is known to build and work properly using an LFS 11.3 platform.

Package Information

CUPS Filters Dependencies

Required

Cups-2.4.2, GLib-2.74.5, ghostscript-10.00.0, Little CMS-2.14, Poppler-23.02.0, and Qpdf-11.2.0

Dejavu fonts (the build fails if they are not installed, although they are only required for the tests), libexif-0.6.24, libjpeg-turbo-2.1.5.1, libpng-1.6.39, libtiff-4.5.0, and mupdf-1.21.1 (mutool)

Optional

Avahi-0.8 (required to build the DNSSD backend of the cups-browsed daemon, which is needed for operating some network printers), OpenLDAP-2.6.4, PHP-8.2.3 (use of this might be broken), Liblouis (Braille), and Liblouisutdml (Braille)

Optional printer drivers (runtime)

Gutenprint-5.3.4 (for supported printers), or other printer drivers, such as hplip

User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/cups-filters

Installation of CUPS Filters

Install CUPS Filters by running the following commands:

./configure --prefix=/usr        \
            --sysconfdir=/etc    \
            --localstatedir=/var \
            --without-rcdir      \
            --disable-static     \
            --disable-avahi      \
            --docdir=/usr/share/doc/cups-filters-1.28.16 &&
make

To test the results, issue: make check. DejaVu fonts are needed for the tests.

Now, as the root user:

make install

Install the systemd unit by running the following command as the root user:

install -v -m644 utils/cups-browsed.service /lib/systemd/system/cups-browsed.service

Command Explanations

--disable-avahi: This switch is needed if the optional Avahi-0.8 is not installed. Remove it if avahi is installed and you need network printer discovery capabilities.

--without-rcdir: This switch disables installation of the bundled bootscript which is not compatible with BLFS.

--disable-static: This switch prevents installation of static versions of the libraries.

--with-test-font-path=`VALUE`: If you wish to run the tests, but you do not have the default /usr/share/fonts/dejavu/DejaVuSans.ttf use this switch to specify where DejaVuSans.ttf (or perhaps some other text TTF font - untested) is located.

Configuring CUPS Filters

Systemd Units

To start the cups-browsed daemon at boot, enable the previously installed systemd unit by running the following command as the root user:

systemctl enable cups-browsed

Contents

Installed Programs: cups-browsed, driverless, driverless-fax, and foomatic-rip

Installed Libraries: libcupsfilters.so and libfontembed.so

Installed Directories: /usr/include/{cupsfilters,fontembed}, /usr/lib/cups/{backend,driver,filter}, /usr/share/cups/{braille,charsets}, /usr/share/doc/cups-filters-1.28.16, and /usr/share/ppd/cupsfilters

Short Descriptions

cups-browsed is a daemon for browsing the Bonjour and CUPS broadcasts of shared, remote CUPS printers.

driverless is a PPD generator utility for driverless printing.

driverless-fax is a wrapper to driverless for FAX type devices.

foomatic-rip is a universal print filter/RIP wrapper which can be used as CUPS filter or stand-alone for spooler-less, direct printing.

libcupsfilters.so contains CUPS Filters API functions.

46.3 ghostscript-10.00.0


Introduction to Ghostscript

Ghostscript is a versatile processor for PostScript data with the ability to render PostScript to different targets. It is a mandatory part of the cups printing stack.

This package is known to build and work properly using an LFS 11.3 platform.

Package Information

Additional Downloads

If you wish, you can download additional fonts.

Standard Fonts

Other Fonts

Ghostscript Dependencies

Cups-2.4.2 (required for building the “cups” device backend, which is needed by cups-filters), Fontconfig-2.14.2 (required, if you are installing any suggested font), FreeType-2.13.0, Little CMS-2.14, libjpeg-turbo-2.1.5.1, libpng-1.6.39, libtiff-4.5.0, and OpenJPEG-2.5.0

Optional

Cairo-1.17.6, GTK+-3.24.36, libidn-1.41, libpaper-1.1.24+nmu5, and a graphical environment

User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/gs

Installation of Ghostscript

Note

The Ghostscript build system is not user-friendly. In order to use system copies of various graphics libraries, you must do it using unconventional methods.

Ghostscript includes (old) copies of several libraries. Some of these seem to have been patched to fix known vulnerabilities, but others of these copies are less-well maintained. To ensure that any future fixes are applied throughout the whole system, it is recommended that you first install the released versions of these libraries and then configure Ghostscript to link to them.

If you have installed the recommended dependencies on your system, remove the copies of freetype, lcms2, libjpeg, libpng, and openjpeg:

rm -rf freetype lcms2mt jpeg libpng openjpeg

Compile Ghostscript:

rm -rf zlib &&

./configure --prefix=/usr           \
            --disable-compile-inits \
            --with-system-libtiff   &&
make

Note

The shared library depends on GTK+-3.24.36. It is only used by external programs like asymptote-2.85, dvisvgm-3.0.3, and ImageMagick-7.1.0-61.

To compile the shared library libgs.so, run the following additional command as an unprivileged user:

make so

This package does not come with a test suite. A set of example files may be used for testing, but it is only possible after installation of the package.

Now, as the root user:

make install

If you want the shared library too:

make soinstall &&
install -v -m644 base/*.h /usr/include/ghostscript &&
ln -sfvn ghostscript /usr/include/ps

Now make the documentation accessible from a standard place:

mv -v /usr/share/doc/ghostscript/10.00.0 /usr/share/doc/ghostscript-10.00.0  &&
rm -rfv /usr/share/doc/ghostscript &&
cp -r examples/ /usr/share/ghostscript/10.00.0/

If you have downloaded the fonts, unpack them to /usr/share/ghostscript and ensure the ownership of the files are root: root.

tar -xvf ../ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript --no-same-owner &&
tar -xvf ../gnu-gs-fonts-other-6.0.tar.gz     -C /usr/share/ghostscript --no-same-owner &&
fc-cache -v /usr/share/ghostscript/fonts/

You can now test the rendering of various postscript and pdf files from the /usr/share/ghostscript/10.00.0/examples . To do this, run the following command (in a X Windows display):

gs -q -dBATCH /usr/share/ghostscript/10.00.0/examples/tiger.eps

Command Explanations

rm -rf zlib : zlib was installed as part of LFS.

--disable-compile-inits: This option makes gs and libgs.so slightly smaller.

--with-system-libtiff: Remove this option if you’ve not installed libtiff-4.5.0.

install -v -m644 base/*.h… : Some packages (ImageMagick is one) need the Ghostscript interface headers in place to link to the shared library. These commands install the headers.

ln -sfvn ghostscript /usr/include/ps: Some packages expect to find the interface headers in an alternate location.

mv -v /usr/share/doc/ghostscript/10.00.0 /usr/share/doc/ghostscript-10.00.0: This moves the documentation where it is expected to be found.

--disable-cups: this option will save a tiny amount of space by not linking gs and libgs.so to the Cups-2.4.2 libraries if you have installed those.

Contents

Installed Programs: dvipdf, eps2eps, gs, gsbj, gsc (from soinstall), gsdj, gsdj500, gslj, gslp, gsnd, gsx (from soinstall), lprsetup.sh, pdf2dsc, pdf2ps, pf2afm, pfbtopfa, pphs, printafm, ps2ascii, ps2epsi, ps2pdf, ps2pdf12, ps2pdf13, ps2pdf14, ps2pdfwr, ps2ps, ps2ps2, and unix-lpr.sh

Installed Library: libgs.so

Installed Directories: /usr/include/ghostscript, /usr/share/ghostscript, and /usr/share/doc/ghostscript-10.00.0

Short Descriptions

gs is an interpreter for Adobe Systems’ PostScript(tm) and Portable Document Format (PDF).

libgs.so provides Ghostscript functionality to other programs, such as GSView, ImageMagick, and libspectre.

Ghostscript provides many different scripts used to convert PostScript, PDF, and other formats. Please refer to the HTML documentation or the man pages for information about the capabilities provided.

46.4 Gutenprint-5.3.4


Introduction to Gutenprint

The Gutenprint (formerly Gimp-Print) package contains high quality drivers for many brands and models of printers for use with Cups-2.4.2 and the GIMP-2.0. See a list of supported printers at https://gutenprint.sourceforge.net/p_Supported_Printers.php.

This package is known to build and work properly using an LFS 11.3 platform.

Package Information

Gutenprint Dependencies

Cups-2.4.2 and Gimp-2.10.32

Two families of DyeSub photo printers each require another library at runtime. Unless you have one of these devices you will not want these libraries.

For the Sinfonia S6145 and the Ciaat Brava 21, libS6145ImageReProcess, see Peachy Photos (Sinfonia) for instructions on how to build and test this.

For the Mitsubishi D70 family and the similar Kodak 305, libMitsuD70ImageReProcess, see Peachy Photos (Mitsubishi CP-D70) for instructions on how to build and test this.

Optional (to Regenerate Documentation)

ImageMagick-7.1.0-61, texlive-20220321 (or install-tl-unx), Doxygen-1.9.6, and DocBook-utils-0.6.14

User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/gutenprint

Kernel Configuration

If you intend to use escputil with a USB-connected Epson Stylus printer for commands such as –ink-level which need to access the raw device, you must enable the kernel’s usblp driver. Enable the following options in your kernel configuration and recompile the kernel:

Device Drivers  --->
    [*] USB support  --->                          [CONFIG_USB_SUPPORT]
        <*/M>  OHCI HCD (USB 1.1) support            [CONFIG_USB_OHCI_HCD]
        <*/M>  UHCI HCD (most Intel and VIA) support [CONFIG_USB_UHCI_HCD]
        <*/M>  USB Printer support                   [CONFIG_USB_PRINTER]

Installation of Gutenprint

Install Gutenprint by running the following commands:

sed -i 's|$(PACKAGE)/doc|doc/$(PACKAGE)-$(VERSION)|' \
       {,doc/,doc/developer/}Makefile.in &&

./configure --prefix=/usr --disable-static &&
make

To test the results, issue: make check. The tests take a very long time and use a lot of disk space. When last tested (version 5.2.15 in June 2019) this needed 75 SBU and 13.5 GB to complete the tests (one test, rastertogutenprint failed because the CUPS ppds are for a previous version. Maybe genppds should be run before the tests). Note that the tests used only one CPU.

Now, as the root user:

make install &&
install -v -m755 -d /usr/share/doc/gutenprint-5.3.4/api/gutenprint{,ui2} &&
install -v -m644    doc/gutenprint/html/* \
                    /usr/share/doc/gutenprint-5.3.4/api/gutenprint &&
install -v -m644    doc/gutenprintui2/html/* \
                    /usr/share/doc/gutenprint-5.3.4/api/gutenprintui2

Command Explanations

sed -i ‘…’ …Makefile.in: This command is used so that the package documentation is installed in the conventional /usr/share/doc directory structure instead of /usr/share/gutenprint/doc.

--disable-static: This switch prevents installation of static versions of the libraries.

Configuring Gutenprint

Configuration Information

For CUPS to see newly installed print drivers, it has to be restarted (as the root user):

systemctl restart cups

Then point your web browser to http://localhost:631/ to add a new printer to CUPS.

Contents

Installed Programs: cups-calibrate, cups-genppd.5.2, cups-genppdupdate, escputil, and testpattern

Installed Libraries: libgutenprint.so, libgutenprintui2.so and optionally, various CUPS filters and backend drivers under /usr/lib/gutenprint/5.2/modules/

Installed Directories: /usr/{include,lib,share}/gutenprint, /usr/include/gutenprintui2 and /usr/share/doc/gutenprint-5.3.4

Short Descriptions

cups-calibrate calibrates the color output of printers using the Gutenprint, CUPS or ESP Print Pro drivers.

cups-genppd.5.2 generates Gutenprint PPD files for use with CUPS.

cups-genppdupdate regenerates the Gutenprint PPD files in use by CUPS.

escputil is a command line utility to perform various maintenance tasks on Epson Stylus inkjet printers.

testpattern is a test program to learn how to use libgutenprint.