gnu: emacs-flycheck-cpplint: Set cpplint path.
[jackhill/guix/guix.git] / gnu / packages / cups.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2015, 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
6 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2017 Mark H Weaver <mhw@netris.org>
8 ;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages cups)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages algebra)
28 #:use-module (gnu packages autotools)
29 #:use-module (gnu packages avahi)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages fonts) ; font-dejavu
32 #:use-module (gnu packages fontutils)
33 #:use-module (gnu packages ghostscript)
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages groff)
36 #:use-module (gnu packages image)
37 #:use-module (gnu packages libusb)
38 #:use-module (gnu packages pdf)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages polkit)
42 #:use-module (gnu packages pretty-print)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages python-xyz)
45 #:use-module (gnu packages qt)
46 #:use-module (gnu packages scanner)
47 #:use-module (gnu packages tls)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix build-system python)
50 #:use-module (guix download)
51 #:use-module (guix svn-download)
52 #:use-module ((guix licenses) #:prefix license:)
53 #:use-module (guix packages)
54 #:use-module (guix utils)
55 #:use-module (srfi srfi-1)
56 #:use-module (ice-9 match))
57
58 (define-public cups-filters
59 (package
60 (name "cups-filters")
61 (version "1.25.1")
62 (source(origin
63 (method url-fetch)
64 (uri
65 (string-append "https://openprinting.org/download/cups-filters/"
66 "cups-filters-" version ".tar.xz"))
67 (sha256
68 (base32
69 "0nlq44jnjcnrbdv0dv5myg5kaycmk6a4klynpvj65xvn3l9cq28s"))
70 (modules '((guix build utils)))
71 (snippet
72 ;; install backends, banners and filters to cups-filters output
73 ;; directory, not the cups server directory
74 '(begin
75 (substitute* "Makefile.in"
76 (("CUPS_DATADIR = @CUPS_DATADIR@")
77 "CUPS_DATADIR = $(PREFIX)/share/cups")
78 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
79 "pkgcupsserverrootdir = $(PREFIX)")
80 ;; Choose standard directories notably so that binaries are
81 ;; stripped.
82 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
83 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
84 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
85 "pkgfilterdir = $(PREFIX)/lib/cups/filter"))
86 ;; Find bannertopdf data such as the print test page in our
87 ;; output directory, not CUPS's prefix.
88 (substitute* "configure"
89 (("\\{CUPS_DATADIR\\}/data")
90 "{prefix}/share/cups/data"))
91 #t))))
92 (build-system gnu-build-system)
93 (arguments
94 `(#:make-flags (list (string-append "PREFIX=" %output))
95 #:configure-flags
96 `("--disable-driverless" ; TODO: enable this
97 "--disable-mutool" ; depends on yet another PDF library (mupdf)
98
99 ;; Look for the "domain socket of CUPS" in /var/run/cups.
100 "--localstatedir=/var"
101
102 ;; Free software for the win.
103 "--with-acroread-path=evince"
104
105 ,(string-append "--with-test-font-path="
106 (assoc-ref %build-inputs "font-dejavu")
107 "/share/fonts/truetype/DejaVuSans.ttf")
108 ,(string-append "--with-gs-path="
109 (assoc-ref %build-inputs "ghostscript")
110 "/bin/gsc")
111 ,(string-append "--with-shell="
112 (assoc-ref %build-inputs "bash")
113 "/bin/bash")
114 ,(string-append "--with-rcdir="
115 (assoc-ref %outputs "out") "/etc/rc.d"))
116
117 #:phases (modify-phases %standard-phases
118 (add-after 'unpack 'patch-foomatic-hardcoded-file-names
119 (lambda* (#:key inputs outputs #:allow-other-keys)
120 ;; Foomatic has hardcoded file names we need to fix.
121 (let ((out (assoc-ref outputs "out"))
122 (gs (assoc-ref inputs "ghostscript")))
123 (substitute* "filter/foomatic-rip/foomaticrip.c"
124 (("/usr/local/lib/cups/filter")
125 (string-append out "/lib/cups/filter")))
126 #t)))
127 (add-after 'unpack 'patch-for-poppler
128 (lambda _
129 (substitute* "filter/pdf.cxx"
130 (("GooString \\*field_name;" m)
131 (string-append "const " m)))
132 #t))
133 (add-after 'install 'wrap-filters
134 (lambda* (#:key inputs outputs #:allow-other-keys)
135 ;; Some filters expect to find 'gs' in $PATH. We cannot
136 ;; just hard-code its absolute file name in the source
137 ;; because foomatic-rip, for example, has tests like
138 ;; 'startswith(cmd, "gs")'.
139 (let ((out (assoc-ref outputs "out"))
140 (ghostscript (assoc-ref inputs "ghostscript")))
141 (for-each (lambda (file)
142 (wrap-program file
143 `("PATH" ":" prefix
144 (,(string-append ghostscript
145 "/bin")))))
146 (find-files (string-append
147 out "/lib/cups/filter")))
148 #t))))))
149 (native-inputs
150 `(("glib" ,glib "bin") ; for gdbus-codegen
151 ("pkg-config" ,pkg-config)))
152 (inputs
153 `(("avahi" ,avahi)
154 ("fontconfig" ,fontconfig)
155 ("freetype" ,freetype)
156 ("font-dejavu" ,font-dejavu) ; also needed by test suite
157 ("ghostscript" ,ghostscript/cups)
158 ("ijs" ,ijs)
159 ("dbus" ,dbus)
160 ("lcms" ,lcms)
161 ("libjpeg" ,libjpeg)
162 ("libpng" ,libpng)
163 ("libtiff" ,libtiff)
164 ("glib" ,glib)
165 ("qpdf" ,qpdf)
166 ("poppler" ,poppler)
167 ("cups-minimal" ,cups-minimal)))
168 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
169 (synopsis "OpenPrinting CUPS filters and backends")
170 (description
171 "Contains backends, filters, and other software that was once part of the
172 core CUPS distribution but is no longer maintained by Apple Inc. In addition
173 it contains additional filters developed independently of Apple, especially
174 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
175 ;; Different filters and backends have different licenses; see COPYING for
176 ;; details
177 (license (list license:gpl2
178 license:gpl2+
179 license:gpl3
180 license:gpl3+
181 license:lgpl2.0+
182 license:expat))))
183
184 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
185 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
186 ;; satisfy this dependency.
187 (define-public cups-minimal
188 (package
189 (name "cups-minimal")
190 (version "2.2.11")
191 (source
192 (origin
193 (method url-fetch)
194 (uri (string-append "https://github.com/apple/cups/releases/download/v"
195 version "/cups-" version "-source.tar.gz"))
196 (sha256
197 (base32
198 "0v5p10lyv8wv48s8ghkhjmdrxg6iwj8hn36v1ilkz46n7y0i107m"))))
199 (build-system gnu-build-system)
200 (arguments
201 `(#:configure-flags
202 '("--disable-launchd"
203 "--disable-systemd"
204 "--disable-avahi"
205 "--disable-dnssd")
206 ;; Seven tests fail, mostly because of files that are provided by the
207 ;; cups-filters package.
208 #:tests? #f
209 #:phases
210 (modify-phases %standard-phases
211 (add-before 'configure 'patch-makedefs
212 (lambda _
213 (substitute* "Makedefs.in"
214 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
215 (("/bin/sh") (which "sh")))
216 #t))
217 ;; Make the compressed manpages writable so that the
218 ;; reset-gzip-timestamps phase does not error out.
219 (add-before 'reset-gzip-timestamps 'make-manpages-writable
220 (lambda* (#:key outputs #:allow-other-keys)
221 (let* ((out (assoc-ref outputs "out"))
222 (man (string-append out "/share/man")))
223 (for-each (lambda (file) (chmod file #o644))
224 (find-files man "\\.gz"))
225 #t)))
226 (add-before 'build 'patch-tests
227 (lambda _
228 (substitute* "test/ippserver.c"
229 (("# else /\\* HAVE_AVAHI \\*/")
230 "#elif defined(HAVE_AVAHI)"))
231 #t)))))
232 (native-inputs
233 `(("pkg-config" ,pkg-config)))
234 (inputs
235 `(("zlib" ,zlib)
236 ("gnutls" ,gnutls)))
237 (home-page "https://www.cups.org")
238 (synopsis "The Common Unix Printing System")
239 (description
240 "CUPS is a printing system that uses the Internet Printing Protocol
241 (@dfn{IPP}). It provides System V and BSD command-line interfaces, as well
242 as a Web interface and a C programming interface to manage printers and print
243 jobs. It supports printing to both local (parallel, serial, USB) and
244 networked printers, and printers can be shared from one computer to another.
245 Internally, CUPS uses PostScript Printer Description (@dfn{PPD}) files to
246 describe printer capabilities and features, and a wide variety of generic and
247 device-specific programs to convert and print many types of files.")
248 (license license:gpl2)))
249
250 (define-public cups
251 (package (inherit cups-minimal)
252 (name "cups")
253 (arguments
254 `(;; Three tests fail:
255 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
256 ;; Get-Jobs Operation"
257 ;; * test of number of error/warning messages, probably related to a
258 ;; missing font.
259 #:tests? #f
260 #:configure-flags
261 '("--disable-launchd"
262 "--disable-systemd")
263 #:phases
264 (modify-phases %standard-phases
265 (add-before 'configure 'patch-makedefs
266 (lambda _
267 (substitute* "Makedefs.in"
268 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
269 (("/bin/sh") (which "sh")))
270 #t))
271 (add-before 'check 'patch-tests
272 (lambda _
273 (let ((filters (assoc-ref %build-inputs "cups-filters"))
274 (catpath (string-append
275 (assoc-ref %build-inputs "coreutils") "/bin/"))
276 (testdir (string-append (getcwd) "/tmp/")))
277 (mkdir testdir)
278 (substitute* "test/run-stp-tests.sh"
279 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
280
281 ;; allow installation of filters from output dir and from
282 ;; cups-filters
283 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
284 (string-append
285 "for dir in "
286 (assoc-ref %outputs "out") "/lib/cups/filter "
287 filters "/lib/cups/filter"))
288
289 ;; check for charsets in cups-filters output
290 (("/usr/share/cups/charsets")
291 (string-append filters "/share/cups/charsets"))
292
293 ;; install additional required filters
294 (("instfilter texttopdf texttopdf pdf")
295 (string-append
296 "instfilter texttopdf texttopdf pdf;"
297 "instfilter imagetoraster imagetoraster raster;"
298 "instfilter gstoraster gstoraster raster;"
299 "instfilter urftopdf urftopdf pdf;"
300 "instfilter rastertopdf rastertopdf pdf;"
301 "instfilter pstopdf pstopdf pdf"))
302
303 ;; specify location of lpstat binary
304 (("description=\"`lpstat -l")
305 "description=\"`../systemv/lpstat -l")
306
307 ;; patch shebangs of embedded scripts
308 (("#!/bin/sh") (string-append "#!" (which "sh")))
309
310 ;; also link mime definitions from cups-filters
311 ;; to enable the additional filters for the test suite
312 (("ln -s \\$root/conf/mime\\.types")
313 (string-append
314 "ln -s " filters
315 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
316 "ln -s $root/conf/mime.types"))
317 (("ln -s \\$root/conf/mime\\.convs")
318 (string-append
319 "ln -s " filters
320 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
321 "ln -s $root/conf/mime.convs")))
322
323 ;; fix search path for "cat"
324 (substitute* "cups/testfile.c"
325 (("cupsFileFind\\(\"cat\", \"/bin\"")
326 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
327 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
328 (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))
329 #t)))
330 ;; Make the compressed manpages writable so that the
331 ;; reset-gzip-timestamps phase does not error out.
332 (add-before 'reset-gzip-timestamps 'make-manpages-writable
333 (lambda* (#:key outputs #:allow-other-keys)
334 (let* ((out (assoc-ref outputs "out"))
335 (man (string-append out "/share/man")))
336 (for-each (lambda (file) (chmod file #o644))
337 (find-files man "\\.gz"))
338 #t)))
339 (add-after 'install 'install-cups-filters-symlinks
340 (lambda* (#:key inputs outputs #:allow-other-keys)
341 (let ((out (assoc-ref outputs "out"))
342 (cups-filters (assoc-ref inputs "cups-filters")))
343 ;; charsets
344 (symlink
345 (string-append cups-filters "/share/cups/charsets")
346 (string-append out "/share/charsets"))
347
348 ;; mime types, driver file, ppds
349 (for-each
350 (lambda (f)
351 (symlink (string-append cups-filters f)
352 (string-append out f)))
353 '("/share/cups/mime/cupsfilters.types"
354 "/share/cups/mime/cupsfilters.convs"
355 "/share/cups/drv/cupsfilters.drv"
356 "/share/ppd"))
357
358 ;; filters
359 (for-each
360 (lambda (f)
361 (symlink f
362 (string-append out "/lib/cups/filter" (basename f))))
363 (find-files (string-append cups-filters "/lib/cups/filter")))
364
365 ;; backends
366 (for-each
367 (lambda (f)
368 (symlink (string-append cups-filters f)
369 (string-append out "/lib/cups/backend/"
370 (basename f))))
371 '("/lib/cups/backend/parallel"
372 "/lib/cups/backend/serial"))
373
374 ;; banners
375 (let ((banners "/share/cups/banners"))
376 (delete-file-recursively (string-append out banners))
377 (symlink (string-append cups-filters banners)
378 (string-append out banners)))
379
380 ;; assorted data
381 (let ((data "/share/cups/data"))
382 (delete-file-recursively (string-append out data))
383 (symlink (string-append cups-filters data)
384 (string-append out data)))
385
386 #t))))))
387 (inputs
388 `(("avahi" ,avahi)
389 ("gnutls" ,gnutls)
390 ("cups-filters" ,cups-filters)
391 ("zlib" ,zlib)))))
392
393 (define-public cups-pk-helper
394 (package
395 (name "cups-pk-helper")
396 (version "0.2.6")
397 (source (origin
398 (method url-fetch)
399 (uri (string-append "https://freedesktop.org/software/"
400 name "/releases/" name "-" version ".tar.xz"))
401 (sha256
402 (base32
403 "0a52jw6rm7lr5nbyksiia0rn7sasyb5cjqcb95z1wxm2yprgi6lm"))))
404 (build-system gnu-build-system)
405 (native-inputs
406 `(("intltool" ,intltool)
407 ("pkg-config" ,pkg-config)
408 ("glib" ,glib)
409 ("polkit" ,polkit)
410 ("cups" ,cups)))
411 (home-page "https://www.freedesktop.org/wiki/Software/cups-pk-helper/")
412 (synopsis "PolicyKit helper to configure CUPS with fine-grained privileges")
413 (description
414 "This package provides the org.opensuse.CupsPkHelper.Mechanism DBus
415 system service which uses @file{cups-pk-helper-mechanism}. This package
416 should only be used as part of the Guix cups-pk-helper service.")
417 (license license:gpl2+)))
418
419 (define-public hplip
420 (package
421 (name "hplip")
422 (version "3.19.11")
423 (source (origin
424 (method url-fetch)
425 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
426 "/hplip-" version ".tar.gz"))
427 (sha256
428 (base32
429 "0lfmym225dr4qnssglqd0gyf0nmm7jpbzkdr1s2wyknmx8z7fx9x"))
430 (modules '((guix build utils)))
431 (patches (search-patches "hplip-remove-imageprocessor.patch"))
432 (snippet
433 '(begin
434 ;; Delete non-free blobs: .so files, pre-compiled
435 ;; 'locatedriver' executable, etc.
436 (for-each delete-file
437 (find-files "."
438 (lambda (file stat)
439 (elf-file? file))))
440 (delete-file "prnt/hpcups/ImageProcessor.h")
441
442 ;; Install binaries under libexec/hplip instead of
443 ;; share/hplip; that'll at least ensure they get stripped.
444 ;; It's not even clear that they're of any use though...
445 (substitute* "Makefile.in"
446 (("^dat2drvdir =.*")
447 "dat2drvdir = $(pkglibexecdir)\n")
448 (("^locatedriverdir =.*")
449 "locatedriverdir = $(pkglibexecdir)\n"))
450 #t))))
451 (build-system gnu-build-system)
452 (home-page "https://developers.hp.com/hp-linux-imaging-and-printing")
453 (synopsis "HP printer drivers")
454 (description
455 "Hewlett-Packard printer drivers and PostScript Printer Descriptions
456 (@dfn{PPD}s).")
457
458 ;; The 'COPYING' file lists directories where each of these 3 licenses
459 ;; applies.
460 (license (list license:gpl2+ license:bsd-3 license:expat))
461
462 ;; TODO install apparmor profile files eventually.
463 (arguments
464 `(#:configure-flags
465 `("--disable-network-build"
466 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
467 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
468 ,(string-append "LDFLAGS=-Wl,-rpath="
469 (assoc-ref %outputs "out") "/lib")
470 ;; Disable until mime.types merging works (FIXME).
471 "--disable-fax-build"
472 "--enable-hpcups-install"
473 "--enable-new-hpcups"
474 "--enable-cups_ppd_install"
475 "--enable-cups_drv_install"
476 ;; TODO add foomatic drv install eventually.
477 ;; TODO --enable-policykit eventually.
478 ,(string-append "--with-cupsfilterdir="
479 (assoc-ref %outputs "out") "/lib/cups/filter")
480 ,(string-append "--with-cupsbackenddir="
481 (assoc-ref %outputs "out") "/lib/cups/backend")
482 ,(string-append "--with-icondir="
483 (assoc-ref %outputs "out") "/share/applications")
484 ,(string-append "--with-systraydir="
485 (assoc-ref %outputs "out") "/etc/xdg")
486 "--enable-qt5" "--disable-qt4")
487
488 #:imported-modules ((guix build python-build-system)
489 ,@%gnu-build-system-modules)
490 #:modules ((guix build gnu-build-system)
491 (guix build utils)
492 ((guix build python-build-system) #:prefix python:))
493
494 #:phases
495 (modify-phases %standard-phases
496 (add-after 'unpack 'fix-hard-coded-file-names
497 (lambda* (#:key inputs outputs #:allow-other-keys)
498 (let ((out (assoc-ref outputs "out"))
499 ;; FIXME: use merged ppds (I think actually only
500 ;; drvs need to be merged).
501 (cupsdir (assoc-ref inputs "cups-minimal")))
502 (substitute* "base/g.py"
503 (("'/usr/share;[^']*'")
504 (string-append "'" cupsdir "/share'"))
505 (("'/etc/hp/hplip.conf'")
506 (string-append "'" out
507 "/etc/hp/hplip.conf" "'")))
508
509 (substitute* "Makefile.in"
510 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
511 ;; FIXME Use beginning-of-word in regexp.
512 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
513 (("/usr/include/libusb-1.0")
514 (string-append (assoc-ref inputs "libusb")
515 "/include/libusb-1.0"))
516 (("hplip_statedir =.*$")
517 ;; Don't bail out while trying to create
518 ;; /var/lib/hplip. We can safely change its value
519 ;; here because it's hard-coded in the code anyway.
520 "hplip_statedir = $(prefix)\n")
521 (("hplip_confdir = /etc/hp")
522 ;; This is only used for installing the default config.
523 (string-append "hplip_confdir = " out
524 "/etc/hp"))
525 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
526 ;; We don't use hal.
527 (string-append "halpredir = " out
528 "/share/hal/fdi/preprobe/10osvendor"))
529 (("rulesdir = /etc/udev/rules.d")
530 ;; udev rules will be merged by base service.
531 (string-append "rulesdir = " out
532 "/lib/udev/rules.d"))
533 (("rulessystemdir = /usr/lib/systemd/system")
534 ;; We don't use systemd.
535 (string-append "rulessystemdir = " out
536 "/lib/systemd/system"))
537 (("/etc/sane.d")
538 (string-append out "/etc/sane.d"))))))
539 (add-after 'install 'wrap-binaries
540 ;; Scripts in /bin are all symlinks to .py files in /share/hplip.
541 ;; Symlinks are immune to the Python build system's 'WRAP phase,
542 ;; and the .py files can't be wrapped because they are reused as
543 ;; modules. Replacing the symlinks in /bin with copies and
544 ;; wrapping them also doesn't work (“ModuleNotFoundError:
545 ;; No module named 'base'”). Behold: a custom WRAP-PROGRAM.
546 (lambda* (#:key inputs outputs #:allow-other-keys)
547 (let* ((out (assoc-ref outputs "out"))
548 (bin (string-append out "/bin"))
549 (python (assoc-ref inputs "python")))
550 (with-directory-excursion bin
551 (for-each (lambda (file)
552 (let ((target (readlink file)))
553 (delete-file file)
554 (with-output-to-file file
555 (lambda _
556 (format #t
557 "#!~a~@
558 export PYTHONPATH=\"~a:~a\"~@
559 exec -a \"$0\" \"~a/~a\" \"$@\"~%"
560 (which "bash")
561 (string-append
562 out "/lib/python"
563 (python:python-version python)
564 "/site-packages")
565 (getenv "PYTHONPATH")
566 bin target)))
567 (chmod file #o755)))
568 (find-files "." (lambda (file stat)
569 (eq? 'symlink (stat:type stat)))))
570 #t)))))))
571
572 ;; Note that the error messages printed by the tools in the case of
573 ;; missing dependencies are often downright misleading.
574 ;; TODO: hp-toolbox still fails to start with:
575 ;; from dbus.mainloop.pyqt5 import DBusQtMainLoop
576 ;; ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
577 (inputs
578 `(("cups-minimal" ,cups-minimal)
579 ("dbus" ,dbus)
580 ("libjpeg" ,libjpeg)
581 ("libusb" ,libusb)
582 ("python" ,python)
583 ("python-dbus" ,python-dbus)
584 ("python-pygobject" ,python-pygobject)
585 ("python-pyqt" ,python-pyqt)
586 ("python-wrapper" ,python-wrapper)
587 ("sane-backends" ,sane-backends-minimal)
588 ("zlib" ,zlib)))
589 (native-inputs
590 `(("perl" ,perl)
591 ("pkg-config" ,pkg-config)))))
592
593 (define-public hplip-minimal
594 (package
595 (inherit hplip)
596 (name "hplip-minimal")
597 (arguments
598 (substitute-keyword-arguments (package-arguments hplip)
599 ((#:configure-flags cf)
600 ;; Produce a "light build", meaning that only the printer (CUPS) and
601 ;; scanner (SANE) support gets built, without all the 'hp-*'
602 ;; command-line tools.
603 `(cons "--enable-lite-build"
604 (delete "--enable-qt5" ,cf)))
605 ((#:phases phases)
606 ;; The 'wrap-binaries' is not needed here since the 'hp-*' programs
607 ;; are not installed.
608 `(alist-delete 'wrap-binaries ,phases))))
609 (inputs (remove (match-lambda
610 ((label . _)
611 (string-prefix? "python" label)))
612 (package-inputs hplip)))
613 (synopsis "GUI-less version of hplip")))
614
615 (define-public foomatic-filters
616 (package
617 (name "foomatic-filters")
618 (version "4.0.17")
619 (source (origin
620 (method url-fetch)
621 (uri (string-append
622 "http://www.openprinting.org/download/foomatic/"
623 "foomatic-filters-" version ".tar.gz"))
624 (sha256
625 (base32
626 "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2"))
627 (patches
628 (search-patches "foomatic-filters-CVE-2015-8327.patch"
629 "foomatic-filters-CVE-2015-8560.patch"))))
630 (build-system gnu-build-system)
631 (home-page
632 "https://wiki.linuxfoundation.org/openprinting/database/foomatic")
633 (native-inputs
634 `(("perl" ,perl)
635 ("pkg-config" ,pkg-config)))
636 (inputs
637 `(("dbus" ,dbus)
638 ("a2ps" ,a2ps)))
639 (arguments
640 '( ;; Specify the installation directories.
641 #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS="
642 (assoc-ref %outputs "out")
643 "/lib/cups/backend")
644 (string-append "ac_cv_path_CUPS_FILTERS="
645 (assoc-ref %outputs "out")
646 "/lib/cups/filter")
647 (string-append "ac_cv_path_PPR_INTERFACES="
648 (assoc-ref %outputs "out")
649 "/lib/ppr/interfaces")
650 (string-append "ac_cv_path_PPR_LIB="
651 (assoc-ref %outputs "out")
652 "/lib/ppr/lib")
653
654 ;; For some reason these are misdiagnosed.
655 "ac_cv_func_malloc_0_nonnull=yes"
656 "ac_cv_func_realloc_0_nonnull=yes")
657 #:test-target "tests"))
658 (synopsis "Convert PostScript to the printer's native format")
659 (description
660 "This package contains filter scripts used by the printer spoolers to
661 convert the incoming PostScript data into the printer's native format using a
662 printer/driver specific, but spooler-independent PPD file.")
663 (license license:gpl2+)))
664
665 (define-public foo2zjs
666 (package
667 (name "foo2zjs")
668 (version "20190909")
669 (source (origin
670 (method url-fetch)
671 ;; XXX: This is an unversioned URL!
672 (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz")
673 (sha256
674 (base32
675 "1nn84c045mbv6yzpjfggc6152bvgrmcxiyvgz9v2w3sws7ihshrm"))))
676 (build-system gnu-build-system)
677 (arguments
678 '(#:phases (modify-phases %standard-phases
679 (replace 'configure
680 (lambda* (#:key outputs #:allow-other-keys)
681 (substitute* (find-files "." "^Makefile$")
682 ;; Set the installation directory.
683 (("^PREFIX[[:blank:]]*=.*$")
684 (string-append "PREFIX = "
685 (assoc-ref outputs "out")
686 "\n"))
687 (("^UDEVBIN[[:blank:]]*=.*$")
688 "UDEVBIN = $(PREFIX)/bin\n")
689 ;; Don't try to chown/chgrp the installed files.
690 (("-oroot")
691 "")
692 (("-glp")
693 "")
694 ;; Placate the dependency checks.
695 (("/usr/include/stdio.h")
696 "/etc/passwd")
697 (("/usr/")
698 "$(PREFIX)/")
699 ;; Ensure fixed timestamps in man pages.
700 (("^MODTIME[[:blank:]]*=.*$")
701 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
702 #t))
703 (add-after 'install 'remove-pdf
704 (lambda* (#:key outputs #:allow-other-keys)
705 ;; Remove 'manual.pdf' which is (1) useless (it's a
706 ;; concatenation of man pages), and (2) not
707 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
708 (let ((out (assoc-ref outputs "out")))
709 (for-each delete-file
710 (find-files out "^manual\\.pdf$"))
711 #t))))
712 #:parallel-build? #f ;broken makefile
713 #:tests? #f ;no tests
714 #:make-flags '("CC=gcc")))
715 (inputs
716 `(("ghostscript" ,ghostscript)
717 ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip'
718 (native-inputs
719 `(("bc" ,bc)
720 ("groff" ,groff)))
721 (home-page "http://foo2zjs.rkkda.com/")
722 (synopsis "Printer driver for ZjStream-based printers")
723 (description
724 "foo2zjs is a printer driver for printers that use the Zenographics
725 ZjStream wire protocol for their print data, often erroneously referred to as
726 winprinters or GDI printers.
727
728 It supports Minolta/QMS@tie{}Magicolor, Minolta@tie{}Color@tie{}PageWorks/Pro,
729 HP@tie{}LaserJet, and possibly other printers. See @file{README} for details.")
730 (license (list license:expat ; icc2ps/*.[ch]
731 license:gpl2+)))) ; everything else
732
733 (define-public escpr
734 (package
735 (name "escpr")
736 (version "1.6.30")
737 ;; XXX: This currently works. But it will break as soon as a newer
738 ;; version is available since the URLs for older versions are not
739 ;; preserved. An alternative source will be added as soon as
740 ;; available.
741 (source (origin
742 (method url-fetch)
743 ;; The uri has to be chopped up in order to satisfy guix lint.
744 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/08/18/20/"
745 "e94de600e28e510c1cfa158929d8b2c0aadc8aa0/"
746 "epson-inkjet-printer-escpr-1.6.30-1lsb3.2.tar.gz"))
747 (sha256
748 (base32
749 "0m8pyfkixisp0vclwxj340isn15zzisal0v2xvv66kxfd68dzf12"))))
750 (build-system gnu-build-system)
751 (arguments
752 `(#:configure-flags
753 `(,(string-append "--prefix="
754 (assoc-ref %outputs "out"))
755 ,(string-append "--with-cupsfilterdir="
756 (assoc-ref %outputs "out") "/lib/cups/filter")
757 ,(string-append "--with-cupsppddir="
758 (assoc-ref %outputs "out") "/share/ppd"))))
759 (inputs `(("cups" ,cups-minimal)))
760 (synopsis "ESC/P-R printer driver")
761 (description
762 "This package provides a filter for the Common UNIX Printing
763 System (CUPS). It offers high-quality printing with Seiko Epson color ink jet
764 printers. It can only be used with printers that support the Epson ESC/P-R
765 language.")
766 (home-page "http://download.ebz.epson.net/dsc/search/01/search")
767 (license license:gpl2+)))
768
769 (define-public splix
770 ;; The last release was in 2009. The SVN repository contains 5 years of
771 ;; unreleased bug fixes and support for newer printer models.
772 (let ((revision 315))
773 (package
774 (name "splix")
775 (version (string-append "2.0.0-" (number->string revision)))
776 (source
777 (origin
778 (method svn-fetch)
779 (uri (svn-reference
780 (url "https://svn.code.sf.net/p/splix/code/splix/")
781 (revision revision)))
782 (file-name (string-append name "-" version "-checkout"))
783 (sha256
784 (base32 "16wbm4xnz35ca3mw2iggf5f4jaxpyna718ia190ka6y4ah932jxl"))))
785 (build-system gnu-build-system)
786 ;; 90% (3.8 MiB) of output are .ppd files. Don't install them by default:
787 ;; CUPS has been able to read the .drv sources directly since version 1.2.
788 (outputs (list "out" "ppd"))
789 (arguments
790 '(#:make-flags
791 (list (string-append "CUPSDRV="
792 (assoc-ref %outputs "out") "/share/cups/drv")
793 (string-append "CUPSFILTER="
794 (assoc-ref %outputs "out") "/lib/cups/filter")
795 (string-append "CUPSPPD="
796 (assoc-ref %outputs "ppd") "/share/cups/model")
797 "CACHESIZE=100" ; pages in RAM, ±300 KiB each
798 "THREADS=4") ; compress and print faster
799 #:phases
800 (modify-phases %standard-phases
801 (delete 'configure) ; no configure script
802 (add-before 'build 'build-.drv-files
803 (lambda* (#:key make-flags #:allow-other-keys)
804 (apply invoke "make" "drv" make-flags)))
805 (add-after 'install 'install-.drv-files
806 (lambda* (#:key make-flags #:allow-other-keys)
807 (apply invoke "make" "install" "DRV_ONLY=1" make-flags))))
808 #:tests? #f)) ; no test suite
809 (inputs
810 `(("cups" ,cups-minimal)
811 ("zlib" ,zlib)
812
813 ;; This dependency can be dropped by setting DISABLE_JBIG=1, but the
814 ;; result will not support some printers like the Samsung CLP-600.
815 ("jbigkit" ,jbigkit)))
816 (synopsis "QPDL (SPL2) printer driver")
817 (description
818 "SpliX is a set of CUPS drivers for printers that speak @acronym{QPDL,
819 Quick Page Description Language}, also called @acronym{SPL2, Samsung Printer
820 Language version 2}. These include many laser printers sold by Samsung,
821 Xerox, Lexmark, Toshiba, and Dell.
822
823 Colour printers need colour profile files to get better results. These
824 @file{cms} files are provided by the printer's manufacturer and must be
825 obtained and installed separately.")
826 (home-page "http://splix.ap2c.org/")
827 (license license:gpl2))))
828
829 (define-public python-pycups
830 (package
831 (name "python-pycups")
832 (version "1.9.74")
833 (source
834 (origin
835 (method url-fetch)
836 (uri (pypi-uri "pycups" version ".tar.bz2"))
837 (sha256
838 (base32
839 "1ffp7sswhdsfpy88zg0cc8kl04wygkjs01rlm9f0spbwk8jhy2c6"))))
840 (build-system python-build-system)
841 (arguments
842 '(;; Tests require CUPS to be running
843 #:tests? #f))
844 (inputs
845 `(("cups" ,cups)))
846 (home-page "https://github.com/zdohnal/pycups")
847 (synopsis "Python bindings for libcups")
848 (description
849 "This package provides Python bindings for libcups, wrapping the CUPS
850 API.")
851 (license license:gpl2+)))