334.5. hplip-3.26.4
HP printer and scanner drivers — hpcups, the hp backend, PPDs and the hpaio SANE backend
| Version | 3.26.4, release 1 |
| Shelf | printing — Printing, printer drivers, labels, scanning and OCR |
| Phase | 44_apps (Applications), 347 of 422 in build order |
| Licence | GPL-2.0-or-later AND MIT AND BSD-3-Clause |
| Homepage | https://developers.hp.com/hp-linux-imaging-and-printing |
| Build time | 2.0 SBU |
| Installed size | 31.0 MiB in 1649 files |
| Recipe | ports/core/printing/hplip/kpkgbuild |
About
HPLIP is HP’s printing and scanning software for Linux. This port ships its print and scan path only: the hpcups CUPS filter, the hp CUPS backend for USB and network printers, the printer descriptions as a CUPS driver file and as PPDs, and the hpaio SANE backend. The Qt toolbox, fax support and the hp-* Python tools are not built or are removed after the install; among those tools is hp-plugin, which downloads HP’s closed plugin, and the system does not carry it.
Sources
hplip-3.26.4.tar.gz(29.5 MiB)
sha256b9c61252754f35b4a237396ca8961e7b3e0c56db76d66a6712b7bf3e30e69463
upstream: https://downloads.sourceforge.net/hplip/hplip-3.26.4.tar.gz
archive copy: sources-3/printing--hplip-3.26.4.tar.gz
Dependencies
Depends on: cups, cups-filters, ghostscript, libusb, libjpeg-turbo, dbus, sane-backends, python3, zlib, net-snmp, avahi, openssl.
Required by: no port names it.
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-qt5, line 25: qt5-qtbase
Patches
build.sh applies these; kpkg applies nothing by itself.
add-cast.patch— adds the(void **)cast that thebb_orblite_opencall inorblite.cneeds to match its declaration.add-const-to-cast.patch— writes theconst SANE_Device ***cast fororblite_get_devicesinhpaio.c, andconst SANE_Char* const*in place ofSANE_Char**in the casts of the Orblite option tables, to match the types those members are declared with.add-missing-headers-and-macros.patch— defines_GNU_SOURCEincommon/utils.c,protocol/hp_ipp.candscan/sane/sclpml.c, includes<unistd.h>,<dlfcn.h>,<sys/time.h>andorblite.hin the files that call their functions without them, and includes<string.h>as a system header incommon/utils.c.add-missing-prototypes.patch— declares_releaseCupsInstance,addCupsPrinter,delCupsPrinter,setDefaultCupsPrinterandcontrolCupsPrinterinprotocol/hp_ipp.h.add-missing-type-to-variable-decl.patch— writesstatic int columninprnt/hpps/pserror.c, which declared it with no type.disable_upgrade.patch— makesupgrade.pyprint an error and exit before it does anything. Its message namesapk, the package manager of the distribution the patch comes from; on KDOS the package is updated throughkpkg.dont-return-value-from-void-func.patch— rewritessane_hpaio_cancel, avoidfunction, as anif/else ifchain that calls each backend’s cancel function instead of returning its result.fix-func-decl-missing-arg.patch— givesbb_is_paper_in_adfitsstruct ledm_session *parameter inscan/sane/ledmi.h, where it was declared with an empty parameter list.fix-memmove.patch— usesmemmoveinstead ofmemcpywhereio/hpmud/musb.cstrips the two length bytes from a device id, a copy whose source and destination overlap.hplip-no-urlopener.patch— the opener classes inbase/device.pyderive fromurllib.request.URLopener; the patch makes them plain classes and calls theiropen_hpmethod directly. The standard library of the tree’s Python has noURLopener, so without the patch the module fails at import.more-imageprocessor-removes.patch— removes every mention of the prebuiltlibImageProcessorfromMakefile.in(as a distributed file, its header as anhpcupssource, the libraryhpcupslinks, and the install rule that copies it to$(libdir)and linkslibImageProcessor.so) and the link fromhplipclassdriver.spec. It also makes the install putHPLIP.confin$(DESTDIR)/usr/share/ipp-usb/quirks, where upstream copies it to the build machine’s/usr/share/ipp-usb/quirksonly when that directory exists.no-empty-glob.patch— makescreatePPD.shskip a glob that matched nothing, instead of runninggzipon the literal pattern.python3.patch— Workaround patch for missing Python3 transition of the old (pre-USB-storage) photo memory card support (pcardext) as this part builds in Python3 environments but with pointer-related warnings which are fatal errors for Ubuntu's build servers. The patch silences the warnings but the memory card support is dropped in Python3 environments. This patch is supplied by the HPLIP upstream developers and will be replaced by a more proper solution in the next upstream release of HPLIP (see LP: #1275353)types-musl.patch— defines__S64_TYPEand__U64_TYPEfrom the word size when the C library is not glibc, and drops OrbliteScan’sSInt64,UInt64,int64_tanduint64_ttypedefs inLinuxCommon.h. Those macros are glibc’s internal names, which musl does not provide.use-correct-macro.patch— usesDBGinstead of the undefined_DBGinorblite.c.
The header, prototype, type, cast, macro and void-return patches correct C that GCC rejects as an error by default.
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/44_apps/phase.env && kpkg install hplip'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/printing/hplip.
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/hplip
echo 'b9c61252754f35b4a237396ca8961e7b3e0c56db76d66a6712b7bf3e30e69463 hplip-3.26.4.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/hplip
SRC=$SRC_ROOT/hplip-3.26.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf hplip-3.26.4.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:
for p in fix-memmove disable_upgrade more-imageprocessor-removes no-empty-glob \
types-musl python3 add-cast add-const-to-cast add-missing-headers-and-macros \
add-missing-prototypes add-missing-type-to-variable-decl \
dont-return-value-from-void-func fix-func-decl-missing-arg use-correct-macro \
hplip-no-urlopener; do
patch -p1 -i "$PORT_SRC/$p.patch"
done
GNUMAKEFLAGS="CFLAGS=-std=c++11" save_CFLAGS="$CFLAGS" ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib \
--with-docdir=/usr/share/doc/hplip \
--disable-doc-build \
--disable-gui-build \
--disable-fax-build \
--disable-qt3 --disable-qt4 --disable-qt5 \
--disable-policykit \
--disable-imageProcessor-build \
--enable-network-build \
--enable-scan-build \
--enable-dbus-build \
--enable-hpcups-install \
--disable-class-driver \
--enable-cups-drv-install \
--enable-cups-ppd-install
make
make -j1 DESTDIR=$PKG install
rm -rf "$PKG/usr/bin" "$PKG/etc/udev" "$PKG/etc/sane.d" "$PKG/usr/share/hal" \
"$PKG/usr/lib/systemd" "$PKG/usr/share/applications" "$PKG/etc/xdg" \
"$PKG/usr/lib/cups/filter/pstotiff" "$PKG/usr/share/doc"
rm -f "$PKG"/usr/share/man/man1/hp-*.1
install -Dm644 /dev/stdin "$PKG/etc/sane.d/dll.d/hpaio" <<'CONF'
hpaio
CONF
if find "$PKG" -name 'libImageProcessor*' -o -name 'hbpl1-*.so' -o -name 'lj-*.so' | grep -q .; then
echo 'hplip: a prebuilt HP object reached the package' >&2
exit 1
fi
test -f "$PKG/usr/share/ipp-usb/quirks/HPLIP.conf"
The switches, and why each is set:
save_CFLAGS="$CFLAGS"— set in configure’s environment.configure.inreplacesCFLAGSwith Python’s include flags for itsPython.hcheck and then restores it from$save_CFLAGS, a variable it never sets; without this the tree’sCFLAGSwould be emptied for the whole build.--disable-doc-build— Build no HTML documentation.--disable-gui-build,--disable-qt3,--disable-qt4,--disable-qt5— No HP Device Manager or other Qt tools.--disable-fax-build— No fax support.--disable-policykit— No polkit helper for the tools; upstream’s default.--disable-imageProcessor-build—libImageProcessoris a prebuilt closed object in the tarball; with the switch on,hpcupslinks it.--enable-network-build— Build the network half ofhpmud, thehp:/netbackend and network scanning throughhpaio. It links net-snmp for device status and avahi’s client library for mDNS discovery; configure stops without either.--enable-scan-build,--enable-dbus-build,--enable-hpcups-install— ThehpaioSANE backend, D-Bus support, and thehpcupsfilter; all three are upstream’s defaults.--disable-class-driver— Build the full HPLIP driver set rather than the class driver alone; upstream’s default.--enable-cups-drv-install,--enable-cups-ppd-install— Install both the dynamic.drvdescription CUPS generates PPDs from and the static, gzipped PPDs.
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/hplip, 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 hplip-3.26.4-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/hplip, and runs the triggers its paths call for.
Contents
Installed libraries: libhpdiscovery.so, libhpip.so, libhpipp.so, libhpmud.so.
Installed directories: /etc/hp, /usr/share/cups/drv/hp, /usr/share/hplip, /usr/share/licenses/hplip, /usr/share/ppd/HP.
Notes
After the install build.sh removes /usr/bin (the hp-* tools) and their manual pages, the udev rules, the HAL and systemd files, the desktop entries and the XDG autostart entry, the pstotiff filter, and the documentation. It also removes /etc/sane.d, whose dll.conf belongs to sane-backends, and enables hpaio instead through a file of its own, /etc/sane.d/dll.d/hpaio.
The tarball carries prebuilt closed objects: libImageProcessor and the hbpl1-* and lj-* printer plugins. None of them may reach the package, so build.sh fails the build if a file by any of those names is in $PKG, and checks that HPLIP.conf, the quirks file for ipp-usb, is.
make install runs with -j1, overriding the tree’s parallel MAKEFLAGS for that one step; see A parallel install race.