154.2. cups-2.4.20
Print spooler and associated utilities
| Version | 2.4.20, release 1 |
| Shelf | printing — Printing, printer drivers, labels, scanning and OCR |
| Phase | 41_system (System), 46 of 1047 in build order |
| Licence | Apache-2.0 WITH LLVM-exception |
| Homepage | https://openprinting.github.io/cups/ |
| Build time | 0.7 SBU |
| Installed size | 14.1 MiB in 862 files |
| Recipe | ports/core/printing/cups/kpkgbuild |
About
CUPS is the print system: the cupsd scheduler that holds the queues, libcups that every printing application links, the lp, lpstat and lpadmin commands, and the filters and backends that carry a job to a printer. On KDOS it prints to driverless (IPP Everywhere) printers it discovers through avahi, and Plasma’s print-manager manages its queues; see Printing. /etc/init.d/80_cups.sh runs cupsd -f under supervision.
Sources
cups-2.4.20.tar.gz(7.8 MiB)
sha256213084ea7bf4f9fb718a9743eed81ef2600b8c90448ead7fa77cedcf0eadc076
upstream: https://github.com/OpenPrinting/cups/archive/v2.4.20/cups-2.4.20-source.tar.gz
archive copy: sources-3/printing--cups-2.4.20.tar.gz
Dependencies
Depends on: gnutls, libusb, pam, dbus, xdg-utils, avahi, zlib, acl, libpaper.
Required by (29): bluez, brlaser, chromium, cups-browsed, cups-filters, darktable, foomatic-db, foomatic-db-engine, freerdp, ghostscript, gtk3, gtk4, gutenprint, hplip, libcupsfilters, libppd, libreoffice, openjdk, print-manager, python3-cups, qt5-qtbase, qt6-qtbase, qt6-qtwebengine, remmina, samba, splix, system-config-printer, tk, wine.
Patches
build.sh applies these; kpkg applies nothing by itself.
Each patch’s own Subject: line names what it changes; the background is here.
local-names-through-avahi.patch gives httpAddrGetList(), the lookup every libcups client connects through, a second way to resolve a host name in the mDNS .local domain. musl has no NSS, so no nss-mdns module answers such a name for getaddrinfo(), and every printer that DNS-SD discovers is named by one: without the patch cupsd refuses to add a discovered driverless printer with Unable to connect to <host>.local:8631: Name does not resolve, although Avahi resolved the service. When getaddrinfo() fails for a name ending in .local (or .local.), the patch asks the Avahi daemon through avahi-client, which libcups already links under --with-dnssd=avahi, waits at most two seconds, and returns the address with the port asked for; an IPv6 link-local answer carries the interface it came on as its scope. cupsd, the ipp backend, lpadmin, lpstat, cups-browsed and Plasma’s printer settings then all resolve .local names. A lookup that getaddrinfo() answers, and every name outside .local, is unchanged. With the Avahi daemon down the second lookup fails at once and the original error stands.
no-idle-exit.patch removes the IdleExitTimeout line from the cupsd.conf that make install writes. The scheduler knows that directive only when it is built for on-demand starts, which --with-ondemand=no turns off, so with the line in place every start of cupsd logs Unknown directive IdleExitTimeout in /var/log/cups/error_log. No configure switch leaves it out: --with-idle-exit-timeout=no still writes it, as IdleExitTimeout 0.
local-names-through-avahi.patch— http-addrlist: resolve a .local host name through Avahi when getaddrinfo cannotno-idle-exit.patch— cupsd.conf: write no IdleExitTimeout, which only an on-demand cupsd knows
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 cups'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/printing/cups.
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/cups
echo '213084ea7bf4f9fb718a9743eed81ef2600b8c90448ead7fa77cedcf0eadc076 cups-2.4.20.tar.gz' | 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/cups
SRC=$SRC_ROOT/cups-2.4.20
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf cups-2.4.20.tar.gz -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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/no-idle-exit.patch"
patch -p1 -i "$PORT_SRC/local-names-through-avahi.patch"
export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=8388608"
./configure \
--prefix=/usr \
--libdir=/usr/lib \
--sysconfdir=/etc \
--localstatedir=/var \
--with-menudir=/usr/share/applications \
--with-icondir=/usr/share/icons \
--with-logdir=/var/log/cups \
--with-docdir=/usr/share/cups \
--with-rundir=/run/cups \
--with-cupsd-file-perm=0755 \
--with-cups-user=lp \
--with-cups-group=lp \
--with-system-groups="lpadmin root" \
--with-domainsocket=/run/cups/cups.sock \
--enable-acl \
--enable-dbus \
--enable-pam \
--enable-libpaper \
--with-dnssd=avahi \
--with-dbusdir=/usr/share/dbus-1 \
--enable-libusb \
--enable-raw-printing \
--enable-relro \
--with-tls=gnutls \
--with-optim="${CFLAGS/-std=gnu11/}" \
--without-rcdir \
--without-systemd \
--with-ondemand=no
make
make BUILDROOT=$PKG install
install -d -m 755 $PKG/etc/pam.d
cat > $PKG/etc/pam.d/cups << "EOF"
auth required pam_unix.so
account required pam_unix.so
EOF
chmod 644 $PKG/etc/pam.d/cups
rm -fr $PKG/tmp $PKG/run $PKG/var/run
chmod 0755 $PKG/var/cache
chmod 0755 $PKG/var/spool
chmod -R +w $PKG
The switches, and why each is set:
-Wl,-z,stack-size=8388608, added toLDFLAGS— ask for an 8 MiB stack in each program’sPT_GNU_STACKheader, the size a thread gets by default on glibc. musl gives each new thread 128 KiB unless that header asks for more, and libcups starts every thread with default attributes (_cupsThreadCreate).cupsdadds a driverless printer on such a thread: it connects to the printer, resolves its.localname through Avahi (local-names-through-avahi.patch) and builds the PPD from the printer’s attributes, all on that one stack. CUPS’sMakedefsputsLDFLAGSon its programs (cupsd, the commands, backends and filters) and not onlibcups.so, so the size reaches no program that only links the library.readelf -lW /usr/sbin/cupsdshows it as theGNU_STACKentry’s0x800000.--with-menudir=/usr/share/applications— Install the CUPS web interface’s desktop entry in the standard place, with--with-icondir=/usr/share/iconsfor its icons.--with-logdir=/var/log/cups— Wherecupsdwrites its logs; with--with-docdir=/usr/share/cups(the web interface’s pages) and--with-rundir=/run/cups(its run-time state) the paths are stated rather than derived from the prefix.--with-domainsocket=/run/cups/cups.sock— The local socket clients reach the scheduler on. The init script creates/run/cupsbefore it startscupsd.--with-cupsd-file-perm=0755— The modemake installgivescupsd. Upstream’s default is0700, which the package lint refuses, because a file that is not readable by everyone must be a credential on its allowlist.--with-cups-user=lp— Run filters and backends aslp, in grouplp(--with-cups-group=lp); both are infs/etc/passwdandfs/etc/group.--with-system-groups="lpadmin root"— Members oflpadmin, and root, may manage printers:/etc/cups/cups-files.confsaysSystemGroup lpadmin root. Without the switch configure picks the groups it finds in the build root’s/etc/group, so the result would follow the build machine. Thekdosaccount is inlpadmin, which is the authority print-manager acts with.rootis there becausecupsdgrants an administrative request only to a member of a system group, and root’s own group isroot: withlpadminalone,sudo lpinfo -vandsudo lpadminare answeredForbidden.lpadminstays first, the group that owns the local root certificate.--enable-acl— Link acl, so thatcupsdgives every system group after the first,roothere, read access to its local root certificate with a POSIX ACL.--enable-dbus— Send job and printer events on the system D-Bus, with--with-dbusdir=/usr/share/dbus-1naming where the bus configuration goes.--enable-pam— Authenticate web interface andlpadminrequests through PAM;build.shwrites/etc/pam.d/cups, which checks the password withpam_unix.--enable-libpaper— Take the default paper size from libpaper.--with-dnssd=avahi— Discover and share printers with DNS-SD through Avahi’s API.--enable-libusb— The USB backend through libusb.--enable-raw-printing— Accept jobs sent as raw data, passed to the printer without filtering. It is the default.--enable-relro— Link CUPS’s programs and libraries with-Wl,-z,relro,-z,now.--with-tls=gnutls— Encrypt IPP connections with gnutls.--with-optim— The optimisation flags CUPS compiles both its C and its C++ with. It is given the tree’sCFLAGSwith-std=gnu11removed, because that standard is valid for C only andg++warns about it on every C++ file; see C flags handed to the C++ compiler.--without-rcdir— Install no System V init scripts; the init script is KDOS’s own.--without-systemd— Install no systemd units, and with--with-ondemand=nobuild no socket-activation support. KDOS has no systemd, socupsdruns all the time while the service is enabled.
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/cups, 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 cups-2.4.20-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/cups, and runs the triggers its paths call for.
Contents
Installed programs: cancel, cups-config, cupsaccept, cupsctl, cupsd, cupsdisable, cupsenable, cupsfilter, cupsreject, cupstestppd, ippeveprinter, ippfind, ipptool, lp, lpadmin, lpc, lpinfo, lpmove, lpoptions, lpq, lpr, lprm, lpstat, ppdc, ppdhtml, ppdi, ppdmerge, ppdpo.
Installed libraries: libcups.so, libcupsimage.so.
Installed directories: /etc/cups/ppd, /etc/cups/ssl, /usr/include/cups, /usr/lib/cups/cgi-bin, /usr/lib/cups/command, /usr/lib/cups/daemon, /usr/lib/cups/monitor, /usr/lib/cups/notifier, /usr/share/cups/da, /usr/share/cups/de, /usr/share/cups/es, /usr/share/cups/examples, /usr/share/cups/fr, /usr/share/cups/help, /usr/share/cups/images, /usr/share/cups/ipptool, /usr/share/cups/ja, /usr/share/cups/ppdc, /usr/share/cups/profiles, /usr/share/cups/pt_BR, /usr/share/cups/ru, /usr/share/cups/templates, /usr/share/licenses/cups, /var/cache/cups, /var/log/cups, /var/spool.
Short descriptions
cancel |
cancel jobs |
cups-config |
get cups api, compiler, directory, and link information (deprecated). |
cupsaccept |
accept/reject jobs sent to a destination |
cupsctl |
configure cupsd.conf options |
cupsd |
cups scheduler |
cupsenable |
stop/start printers and classes |
cupsfilter |
convert a file to another format using cups filters (deprecated) |
cupstestppd |
test conformance of ppd files (deprecated) |
ippeveprinter |
an ipp everywhere printer application for cups |
ippfind |
find internet printing protocol printers |
ipptool |
perform internet printing protocol requests |
lp |
print files |
lpadmin |
configure cups printers and classes |
lpc |
line printer control program (deprecated) |
lpinfo |
show available devices or drivers (deprecated) |
lpmove |
move a job or all jobs to a new destination |
lpoptions |
display or set printer options and defaults |
lpq |
show printer queue status |
lpr |
print files |
lprm |
cancel print jobs |
lpstat |
print cups status information |
ppdc |
cups ppd compiler (deprecated) |
ppdhtml |
cups html summary generator (deprecated) |
ppdi |
import ppd files (deprecated) |
ppdmerge |
merge ppd files (deprecated) |
ppdpo |
ppd message catalog generator (deprecated) |
cups.pc |
CUPS API Library |
Notes
build.sh stages the install with make BUILDROOT=$PKG install. BUILDROOT is the prefix every install path in CUPS’s Makedefs is built on; it defaults to $(DSTROOT)$(DESTDIR), so setting it directly stages the same tree.
After the install build.sh removes /tmp, /run and /var/run from the package (tmpfs at run time, and refused by the lint), sets /var/cache and /var/spool to 0755, and makes every staged file writable by its owner.
The configuration files under /etc/cups and the backends under /usr/lib/cups/backend keep the restricted modes CUPS gives them; both paths are on the lint’s allowlist of files that need not be world-readable. The installer enables the service by default; a person who turns printing off in the installer gets /etc/service.disabled/cups, and service enable cups turns it back on.