1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2015, 2016, 2017 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>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages cups)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages algebra)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages avahi)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages groff)
35 #:use-module (gnu packages libusb)
36 #:use-module (gnu packages perl)
37 #:use-module (gnu packages pretty-print)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages scanner)
40 #:use-module (gnu packages image)
41 #:use-module (gnu packages fonts) ;font-dejavu
42 #:use-module (gnu packages fontutils)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages glib)
45 #:use-module (gnu packages pdf)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages tls))
49 (define-public cups-filters
56 (string-append "https://openprinting.org/download/cups-filters/"
57 "cups-filters-" version ".tar.xz"))
60 "1mg397kgfx0rs9j852f8ppmvaz2al5l75ildbgiqg6j3gwq5jssw"))
61 (modules '((guix build utils)))
63 ;; install backends, banners and filters to cups-filters output
64 ;; directory, not the cups server directory
66 (substitute* "Makefile.in"
67 (("CUPS_DATADIR = @CUPS_DATADIR@")
68 "CUPS_DATADIR = $(PREFIX)/share/cups")
69 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
70 "pkgcupsserverrootdir = $(PREFIX)")
71 ;; Choose standard directories notably so that binaries are
73 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
74 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
75 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
76 "pkgfilterdir = $(PREFIX)/lib/cups/filter"))
77 ;; Find bannertopdf data such as the print test page in our
78 ;; output directory, not CUPS's prefix.
79 (substitute* "configure"
80 (("\\{CUPS_DATADIR\\}/data")
81 "{prefix}/share/cups/data"))))))
82 (build-system gnu-build-system)
84 `(#:make-flags (list (string-append "PREFIX=" %output))
86 `("--disable-driverless" ; TODO: enable this
87 "--disable-mutool" ; depends on yet another PDF library (mupdf)
89 ;; Look for the "domain socket of CUPS" in /var/run/cups.
90 "--localstatedir=/var"
92 ;; Free software for the win.
93 "--with-acroread-path=evince"
95 ,(string-append "--with-test-font-path="
96 (assoc-ref %build-inputs "font-dejavu")
97 "/share/fonts/truetype/DejaVuSans.ttf")
98 ,(string-append "--with-gs-path="
99 (assoc-ref %build-inputs "ghostscript")
101 ,(string-append "--with-shell="
102 (assoc-ref %build-inputs "bash")
104 ,(string-append "--with-rcdir="
105 (assoc-ref %outputs "out") "/etc/rc.d"))
107 #:phases (modify-phases %standard-phases
108 (add-after 'unpack 'patch-foomatic-hardcoded-file-names
109 (lambda* (#:key inputs outputs #:allow-other-keys)
110 ;; Foomatic has hardcoded file names we need to fix.
111 (let ((out (assoc-ref outputs "out"))
112 (gs (assoc-ref inputs "ghostscript")))
113 (substitute* "filter/foomatic-rip/foomaticrip.c"
114 (("/usr/local/lib/cups/filter")
115 (string-append out "/lib/cups/filter")))
117 (add-after 'install 'wrap-filters
118 (lambda* (#:key inputs outputs #:allow-other-keys)
119 ;; Some filters expect to find 'gs' in $PATH. We cannot
120 ;; just hard-code its absolute file name in the source
121 ;; because foomatic-rip, for example, has tests like
122 ;; 'startswith(cmd, "gs")'.
123 (let ((out (assoc-ref outputs "out"))
124 (ghostscript (assoc-ref inputs "ghostscript")))
125 (for-each (lambda (file)
128 (,(string-append ghostscript
130 (find-files (string-append
131 out "/lib/cups/filter")))
134 `(("glib" ,glib "bin") ; for gdbus-codegen
135 ("pkg-config" ,pkg-config)))
138 ("fontconfig" ,fontconfig)
139 ("freetype" ,freetype)
140 ("font-dejavu" ,font-dejavu) ; also needed by test suite
141 ("ghostscript" ,ghostscript/cups)
151 ("cups-minimal" ,cups-minimal)))
152 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
153 (synopsis "OpenPrinting CUPS filters and backends")
155 "Contains backends, filters, and other software that was once part of the
156 core CUPS distribution but is no longer maintained by Apple Inc. In addition
157 it contains additional filters developed independently of Apple, especially
158 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
159 ;; Different filters and backends have different licenses; see COPYING for
161 (license (list license:gpl2
168 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
169 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
170 ;; satisfy this dependency.
171 (define-public cups-minimal
173 (name "cups-minimal")
178 (uri (string-append "https://github.com/apple/cups/releases/download/v"
179 version "/cups-" version "-source.tar.gz"))
182 "1k4qxafmapq6hzbkh273fdyzkj9alw6ppwz5k933bhsi4svlsvar"))))
183 (build-system gnu-build-system)
186 '("--disable-launchd"
190 ;; Seven tests fail, mostly because of files that are provided by the
191 ;; cups-filters package.
194 (modify-phases %standard-phases
195 (add-before 'configure 'patch-makedefs
197 (substitute* "Makedefs.in"
198 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
199 (("/bin/sh") (which "sh")))))
200 ;; Make the compressed manpages writable so that the
201 ;; reset-gzip-timestamps phase does not error out.
202 (add-before 'reset-gzip-timestamps 'make-manpages-writable
203 (lambda* (#:key outputs #:allow-other-keys)
204 (let* ((out (assoc-ref outputs "out"))
205 (man (string-append out "/share/man")))
206 (for-each (lambda (file) (chmod file #o644))
207 (find-files man "\\.gz")))))
208 (add-before 'build 'patch-tests
210 (substitute* "test/ippserver.c"
211 (("# else /\\* HAVE_AVAHI \\*/")
212 "#elif defined(HAVE_AVAHI)")))))))
214 `(("pkg-config" ,pkg-config)))
218 (home-page "https://www.cups.org")
219 (synopsis "The Common Unix Printing System")
221 "CUPS is a printing system that uses the Internet Printing Protocol
222 (@dfn{IPP}). It provides System V and BSD command-line interfaces, as well
223 as a Web interface and a C programming interface to manage printers and print
224 jobs. It supports printing to both local (parallel, serial, USB) and
225 networked printers, and printers can be shared from one computer to another.
226 Internally, CUPS uses PostScript Printer Description (@dfn{PPD}) files to
227 describe printer capabilities and features, and a wide variety of generic and
228 device-specific programs to convert and print many types of files.")
229 (license license:gpl2)))
232 (package (inherit cups-minimal)
235 `(;; Three tests fail:
236 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
237 ;; Get-Jobs Operation"
238 ;; * test of number of error/warning messages, probably related to a
242 '("--disable-launchd"
245 (modify-phases %standard-phases
246 (add-before 'configure 'patch-makedefs
248 (substitute* "Makedefs.in"
249 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
250 (("/bin/sh") (which "sh")))))
251 (add-before 'check 'patch-tests
253 (let ((filters (assoc-ref %build-inputs "cups-filters"))
254 (catpath (string-append
255 (assoc-ref %build-inputs "coreutils") "/bin/"))
256 (testdir (string-append (getcwd) "/tmp/")))
258 (substitute* "test/run-stp-tests.sh"
259 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
261 ;; allow installation of filters from output dir and from
263 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
266 (assoc-ref %outputs "out") "/lib/cups/filter "
267 filters "/lib/cups/filter"))
269 ;; check for charsets in cups-filters output
270 (("/usr/share/cups/charsets")
271 (string-append filters "/share/cups/charsets"))
273 ;; install additional required filters
274 (("instfilter texttopdf texttopdf pdf")
276 "instfilter texttopdf texttopdf pdf;"
277 "instfilter imagetoraster imagetoraster raster;"
278 "instfilter gstoraster gstoraster raster;"
279 "instfilter urftopdf urftopdf pdf;"
280 "instfilter rastertopdf rastertopdf pdf;"
281 "instfilter pstopdf pstopdf pdf"))
283 ;; specify location of lpstat binary
284 (("description=\"`lpstat -l")
285 "description=\"`../systemv/lpstat -l")
287 ;; patch shebangs of embedded scripts
288 (("#!/bin/sh") (string-append "#!" (which "sh")))
290 ;; also link mime definitions from cups-filters
291 ;; to enable the additional filters for the test suite
292 (("ln -s \\$root/conf/mime\\.types")
295 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
296 "ln -s $root/conf/mime.types"))
297 (("ln -s \\$root/conf/mime\\.convs")
300 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
301 "ln -s $root/conf/mime.convs")))
303 ;; fix search path for "cat"
304 (substitute* "cups/testfile.c"
305 (("cupsFileFind\\(\"cat\", \"/bin\"")
306 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
307 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
308 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))))))
309 ;; Make the compressed manpages writable so that the
310 ;; reset-gzip-timestamps phase does not error out.
311 (add-before 'reset-gzip-timestamps 'make-manpages-writable
312 (lambda* (#:key outputs #:allow-other-keys)
313 (let* ((out (assoc-ref outputs "out"))
314 (man (string-append out "/share/man")))
315 (for-each (lambda (file) (chmod file #o644))
316 (find-files man "\\.gz")))))
317 (add-after 'install 'install-cups-filters-symlinks
318 (lambda* (#:key inputs outputs #:allow-other-keys)
319 (let ((out (assoc-ref outputs "out"))
320 (cups-filters (assoc-ref inputs "cups-filters")))
323 (string-append cups-filters "/share/cups/charsets")
324 (string-append out "/share/charsets"))
326 ;; mime types, driver file, ppds
329 (symlink (string-append cups-filters f)
330 (string-append out f)))
331 '("/share/cups/mime/cupsfilters.types"
332 "/share/cups/mime/cupsfilters.convs"
333 "/share/cups/drv/cupsfilters.drv"
340 (string-append out "/lib/cups/filter" (basename f))))
341 (find-files (string-append cups-filters "/lib/cups/filter")))
346 (symlink (string-append cups-filters f)
347 (string-append out "/lib/cups/backend/"
349 '("/lib/cups/backend/parallel"
350 "/lib/cups/backend/serial"))
353 (let ((banners "/share/cups/banners"))
354 (delete-file-recursively (string-append out banners))
355 (symlink (string-append cups-filters banners)
356 (string-append out banners)))
359 (let ((data "/share/cups/data"))
360 (delete-file-recursively (string-append out data))
361 (symlink (string-append cups-filters data)
362 (string-append out data)))))))))
366 ("cups-filters" ,cups-filters)
375 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
376 "/hplip-" version ".tar.gz"))
379 "0v27hg856b5z2rilczcbfgz8ksxn0n810g1glac3mxkj8qbl8wqg"))))
380 (build-system gnu-build-system)
381 (home-page "http://hplipopensource.com/")
382 (synopsis "HP Printer Drivers")
383 (description "Hewlett-Packard Printer Drivers and PPDs.")
385 ;; The 'COPYING' file lists directories where each of these 3 licenses
387 (license (list license:gpl2+ license:bsd-3 license:expat))
389 ;; TODO install apparmor profile files eventually.
392 `("--disable-network-build"
393 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
394 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
395 ;; Disable until mime.types merging works (FIXME).
396 "--disable-fax-build"
397 "--enable-hpcups-install"
398 "--enable-new-hpcups"
399 "--enable-cups_ppd_install"
400 "--enable-cups_drv_install"
401 ;; TODO add foomatic drv install eventually.
402 ;; TODO --enable-policykit eventually.
403 ,(string-append "--with-cupsfilterdir="
404 (assoc-ref %outputs "out") "/lib/cups/filter")
405 ,(string-append "--with-cupsbackenddir="
406 (assoc-ref %outputs "out") "/lib/cups/backend")
407 ,(string-append "--with-icondir="
408 (assoc-ref %outputs "out") "/share/applications")
409 ,(string-append "--with-systraydir="
410 (assoc-ref %outputs "out") "/etc/xdg"))
412 #:imported-modules ((guix build python-build-system)
413 ,@%gnu-build-system-modules)
414 #:modules ((guix build gnu-build-system)
416 ((guix build python-build-system) #:prefix python:))
418 #:phases (modify-phases %standard-phases
419 (add-after 'unpack 'fix-hard-coded-file-names
420 (lambda* (#:key inputs outputs #:allow-other-keys)
421 (let ((out (assoc-ref outputs "out"))
422 ;; FIXME: use merged ppds (I think actually only
423 ;; drvs need to be merged).
424 (cupsdir (assoc-ref inputs "cups-minimal")))
425 (substitute* "base/g.py"
426 (("'/usr/share;[^']*'")
427 (string-append "'" cupsdir "/share'"))
428 (("'/etc/hp/hplip.conf'")
429 (string-append "'" out
430 "/etc/hp/hplip.conf" "'")))
432 (substitute* "Makefile.in"
433 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
434 ;; FIXME Use beginning-of-word in regexp.
435 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
436 (("/usr/include/libusb-1.0")
437 (string-append (assoc-ref inputs "libusb")
438 "/include/libusb-1.0"))
439 (("^\tinstall-dist_hplip_stateDATA")
440 ;; Remove dependencies on
441 ;; 'install-dist_hplip_stateDATA' so we don't bail
442 ;; out while trying to create /var/lib/hplip.
444 (("hplip_confdir = /etc/hp")
445 ;; This is only used for installing the default config.
446 (string-append "hplip_confdir = " out
448 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
449 ;; Note: We don't use hal.
450 (string-append "halpredir = " out
451 "/share/hal/fdi/preprobe/10osvendor"))
452 (("rulesdir = /etc/udev/rules.d")
453 ;; udev rules will be merged by base service.
454 (string-append "rulesdir = " out
455 "/lib/udev/rules.d"))
456 (("rulessystemdir = /usr/lib/systemd/system")
457 ;; We don't use systemd.
458 (string-append "rulessystemdir = " out
459 "/lib/systemd/system"))
461 (string-append out "/etc/sane.d"))))))
463 ;; Wrap bin/* so that the Python libs are found.
464 (add-after 'install 'wrap-binaries
465 (assoc-ref python:%standard-phases 'wrap)))))
467 ;; Python3 support is available starting from hplip@3.15.2.
468 (inputs `(("libjpeg" ,libjpeg)
469 ("cups-minimal" ,cups-minimal)
471 ("sane-backends" ,sane-backends-minimal)
473 ("python-wrapper" ,python-wrapper)
475 ;; TODO: Make hp-setup find python-dbus.
476 ("python-dbus" ,python-dbus)))
477 (native-inputs `(("pkg-config" ,pkg-config)))))
479 (define-public foomatic-filters
481 (name "foomatic-filters")
486 "http://www.openprinting.org/download/foomatic/"
487 name "-" version ".tar.gz"))
490 "17w26r15094j4fqifa7f7i7jad4gsy9zdlq69kffrykcw31qx3q8"))
492 (search-patches "foomatic-filters-CVE-2015-8327.patch"
493 "foomatic-filters-CVE-2015-8560.patch"))))
494 (build-system gnu-build-system)
496 "https://wiki.linuxfoundation.org/openprinting/database/foomatic")
499 ("pkg-config" ,pkg-config)))
504 '( ;; Specify the installation directories.
505 #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS="
506 (assoc-ref %outputs "out")
508 (string-append "ac_cv_path_CUPS_FILTERS="
509 (assoc-ref %outputs "out")
511 (string-append "ac_cv_path_PPR_INTERFACES="
512 (assoc-ref %outputs "out")
513 "/lib/ppr/interfaces")
514 (string-append "ac_cv_path_PPR_LIB="
515 (assoc-ref %outputs "out")
518 ;; For some reason these are misdiagnosed.
519 "ac_cv_func_malloc_0_nonnull=yes"
520 "ac_cv_func_realloc_0_nonnull=yes")
521 #:test-target "tests"))
522 (synopsis "Convert PostScript to the printer's native format")
524 "This package contains filter scripts used by the printer spoolers to
525 convert the incoming PostScript data into the printer's native format using a
526 printer/driver specific, but spooler-independent PPD file.")
527 (license license:gpl2+)))
529 (define-public foo2zjs
531 ;; The tarball is called "foo2zjs", but the web page talks about
532 ;; "foo2xqx". Go figure!
537 ;; XXX: This is an unversioned URL!
538 (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz")
541 "0amjj3jr6s6h7crzxyx11v31sj0blz7k5c2vycz4gn8cxlmk3c7w"))))
542 (build-system gnu-build-system)
544 '(#:phases (modify-phases %standard-phases
546 (lambda* (#:key outputs #:allow-other-keys)
547 (substitute* (find-files "." "^Makefile$")
548 ;; Set the installation directory.
549 (("^PREFIX[[:blank:]]*=.*$")
550 (string-append "PREFIX = "
551 (assoc-ref outputs "out")
553 (("^UDEVBIN[[:blank:]]*=.*$")
554 "UDEVBIN = $(PREFIX)/bin\n")
555 ;; Don't try to chown/chgrp the installed files.
560 ;; Placate the dependency checks.
561 (("/usr/include/stdio.h")
565 ;; Ensure fixed timestamps in man pages.
566 (("^MODTIME[[:blank:]]*=.*$")
567 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
569 (add-after 'install 'remove-pdf
570 (lambda* (#:key outputs #:allow-other-keys)
571 ;; Remove 'manual.pdf' which is (1) useless (it's a
572 ;; concatenation of man pages), and (2) not
573 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
574 (let ((out (assoc-ref outputs "out")))
575 (for-each delete-file
576 (find-files out "^manual\\.pdf$"))
578 #:parallel-build? #f ;broken makefile
579 #:tests? #f ;no tests
580 #:make-flags '("CC=gcc")))
582 `(("ghostscript" ,ghostscript)
583 ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip'
587 (home-page "http://foo2xqx.rkkda.com/")
588 (synopsis "Printer driver for XQX stream protocol")
590 "This package provides a printer driver notably for the ZJS and XQX
591 protocols, which cover printers made by Konica, HP (LaserJet), Oki, Samsung,
592 and more. See @file{README} for details.")
593 (license license:gpl2+)))
599 ;; XXX: This currently works. But it will break as soon as a newer
600 ;; version is available since the URLs for older versions are not
601 ;; preserved. An alternative source will be added as soon as
605 ;; The uri has to be chopped up in order to satisfy guix lint.
606 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/06/66/09/"
607 "4ac2bf69bb1ddf4a9ad525596615cbb40fe4dad5/"
608 "epson-inkjet-printer-escpr-1.6.17-1lsb3.2.tar.gz"))
611 "0m6v1wdavw4r25jfywqchsx0v9ss1l5fr8vq9d0d8cmjnz8mqblv"))))
612 (build-system gnu-build-system)
615 `(,(string-append "--prefix="
616 (assoc-ref %outputs "out"))
617 ,(string-append "--with-cupsfilterdir="
618 (assoc-ref %outputs "out") "/lib/cups/filter")
619 ,(string-append "--with-cupsppddir="
620 (assoc-ref %outputs "out") "/share/ppd"))))
621 (inputs `(("cups" ,cups-minimal)))
622 (synopsis "ESC/P-R printer driver")
624 "This package provides a filter for the Common UNIX Printing
625 System (CUPS). It offers high-quality printing with Seiko Epson color ink jet
626 printers. It can only be used with printers that support the Epson ESC/P-R
628 (home-page "http://download.ebz.epson.net/dsc/search/01/search")
629 (license license:gpl2+)))