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>
8 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; This file is part of GNU Guix.
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.
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.
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/>.
25 (define-module (gnu packages cups)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages algebra)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages avahi)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages groff)
36 #:use-module (gnu packages libusb)
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages pretty-print)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages scanner)
41 #:use-module (gnu packages image)
42 #:use-module (gnu packages fonts) ;font-dejavu
43 #:use-module (gnu packages fontutils)
44 #:use-module (gnu packages ghostscript)
45 #:use-module (gnu packages glib)
46 #:use-module (gnu packages pdf)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages tls))
50 (define-public cups-filters
57 (string-append "https://openprinting.org/download/cups-filters/"
58 "cups-filters-" version ".tar.xz"))
61 "0i7mvvnq7ayhxn1ajci8h7l3cijzwr9d50p58h0rbsh9hf63zblq"))
62 (modules '((guix build utils)))
64 ;; install backends, banners and filters to cups-filters output
65 ;; directory, not the cups server directory
67 (substitute* "Makefile.in"
68 (("CUPS_DATADIR = @CUPS_DATADIR@")
69 "CUPS_DATADIR = $(PREFIX)/share/cups")
70 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
71 "pkgcupsserverrootdir = $(PREFIX)")
72 ;; Choose standard directories notably so that binaries are
74 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
75 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
76 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
77 "pkgfilterdir = $(PREFIX)/lib/cups/filter"))
78 ;; Find bannertopdf data such as the print test page in our
79 ;; output directory, not CUPS's prefix.
80 (substitute* "configure"
81 (("\\{CUPS_DATADIR\\}/data")
82 "{prefix}/share/cups/data"))))))
83 (build-system gnu-build-system)
85 `(#:make-flags (list (string-append "PREFIX=" %output))
87 `("--disable-driverless" ; TODO: enable this
88 "--disable-mutool" ; depends on yet another PDF library (mupdf)
90 ;; Look for the "domain socket of CUPS" in /var/run/cups.
91 "--localstatedir=/var"
93 ;; Free software for the win.
94 "--with-acroread-path=evince"
96 ,(string-append "--with-test-font-path="
97 (assoc-ref %build-inputs "font-dejavu")
98 "/share/fonts/truetype/DejaVuSans.ttf")
99 ,(string-append "--with-gs-path="
100 (assoc-ref %build-inputs "ghostscript")
102 ,(string-append "--with-shell="
103 (assoc-ref %build-inputs "bash")
105 ,(string-append "--with-rcdir="
106 (assoc-ref %outputs "out") "/etc/rc.d"))
108 #:phases (modify-phases %standard-phases
109 (add-after 'unpack 'patch-foomatic-hardcoded-file-names
110 (lambda* (#:key inputs outputs #:allow-other-keys)
111 ;; Foomatic has hardcoded file names we need to fix.
112 (let ((out (assoc-ref outputs "out"))
113 (gs (assoc-ref inputs "ghostscript")))
114 (substitute* "filter/foomatic-rip/foomaticrip.c"
115 (("/usr/local/lib/cups/filter")
116 (string-append out "/lib/cups/filter")))
118 (add-after 'install 'wrap-filters
119 (lambda* (#:key inputs outputs #:allow-other-keys)
120 ;; Some filters expect to find 'gs' in $PATH. We cannot
121 ;; just hard-code its absolute file name in the source
122 ;; because foomatic-rip, for example, has tests like
123 ;; 'startswith(cmd, "gs")'.
124 (let ((out (assoc-ref outputs "out"))
125 (ghostscript (assoc-ref inputs "ghostscript")))
126 (for-each (lambda (file)
129 (,(string-append ghostscript
131 (find-files (string-append
132 out "/lib/cups/filter")))
135 `(("glib" ,glib "bin") ; for gdbus-codegen
136 ("pkg-config" ,pkg-config)))
139 ("fontconfig" ,fontconfig)
140 ("freetype" ,freetype)
141 ("font-dejavu" ,font-dejavu) ; also needed by test suite
142 ("ghostscript" ,ghostscript/cups)
152 ("cups-minimal" ,cups-minimal)))
153 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
154 (synopsis "OpenPrinting CUPS filters and backends")
156 "Contains backends, filters, and other software that was once part of the
157 core CUPS distribution but is no longer maintained by Apple Inc. In addition
158 it contains additional filters developed independently of Apple, especially
159 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
160 ;; Different filters and backends have different licenses; see COPYING for
162 (license (list license:gpl2
169 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
170 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
171 ;; satisfy this dependency.
172 (define-public cups-minimal
174 (name "cups-minimal")
179 (uri (string-append "https://github.com/apple/cups/releases/download/v"
180 version "/cups-" version "-source.tar.gz"))
183 "16qn41b84xz6khrr2pa2wdwlqxr29rrrkjfi618gbgdkq9w5ff20"))))
184 (build-system gnu-build-system)
187 '("--disable-launchd"
191 ;; Seven tests fail, mostly because of files that are provided by the
192 ;; cups-filters package.
195 (modify-phases %standard-phases
196 (add-before 'configure 'patch-makedefs
198 (substitute* "Makedefs.in"
199 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
200 (("/bin/sh") (which "sh")))))
201 ;; Make the compressed manpages writable so that the
202 ;; reset-gzip-timestamps phase does not error out.
203 (add-before 'reset-gzip-timestamps 'make-manpages-writable
204 (lambda* (#:key outputs #:allow-other-keys)
205 (let* ((out (assoc-ref outputs "out"))
206 (man (string-append out "/share/man")))
207 (for-each (lambda (file) (chmod file #o644))
208 (find-files man "\\.gz")))))
209 (add-before 'build 'patch-tests
211 (substitute* "test/ippserver.c"
212 (("# else /\\* HAVE_AVAHI \\*/")
213 "#elif defined(HAVE_AVAHI)")))))))
215 `(("pkg-config" ,pkg-config)))
219 (home-page "https://www.cups.org")
220 (synopsis "The Common Unix Printing System")
222 "CUPS is a printing system that uses the Internet Printing Protocol
223 (@dfn{IPP}). It provides System V and BSD command-line interfaces, as well
224 as a Web interface and a C programming interface to manage printers and print
225 jobs. It supports printing to both local (parallel, serial, USB) and
226 networked printers, and printers can be shared from one computer to another.
227 Internally, CUPS uses PostScript Printer Description (@dfn{PPD}) files to
228 describe printer capabilities and features, and a wide variety of generic and
229 device-specific programs to convert and print many types of files.")
230 (license license:gpl2)))
233 (package (inherit cups-minimal)
236 `(;; Three tests fail:
237 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
238 ;; Get-Jobs Operation"
239 ;; * test of number of error/warning messages, probably related to a
243 '("--disable-launchd"
246 (modify-phases %standard-phases
247 (add-before 'configure 'patch-makedefs
249 (substitute* "Makedefs.in"
250 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
251 (("/bin/sh") (which "sh")))))
252 (add-before 'check 'patch-tests
254 (let ((filters (assoc-ref %build-inputs "cups-filters"))
255 (catpath (string-append
256 (assoc-ref %build-inputs "coreutils") "/bin/"))
257 (testdir (string-append (getcwd) "/tmp/")))
259 (substitute* "test/run-stp-tests.sh"
260 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
262 ;; allow installation of filters from output dir and from
264 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
267 (assoc-ref %outputs "out") "/lib/cups/filter "
268 filters "/lib/cups/filter"))
270 ;; check for charsets in cups-filters output
271 (("/usr/share/cups/charsets")
272 (string-append filters "/share/cups/charsets"))
274 ;; install additional required filters
275 (("instfilter texttopdf texttopdf pdf")
277 "instfilter texttopdf texttopdf pdf;"
278 "instfilter imagetoraster imagetoraster raster;"
279 "instfilter gstoraster gstoraster raster;"
280 "instfilter urftopdf urftopdf pdf;"
281 "instfilter rastertopdf rastertopdf pdf;"
282 "instfilter pstopdf pstopdf pdf"))
284 ;; specify location of lpstat binary
285 (("description=\"`lpstat -l")
286 "description=\"`../systemv/lpstat -l")
288 ;; patch shebangs of embedded scripts
289 (("#!/bin/sh") (string-append "#!" (which "sh")))
291 ;; also link mime definitions from cups-filters
292 ;; to enable the additional filters for the test suite
293 (("ln -s \\$root/conf/mime\\.types")
296 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
297 "ln -s $root/conf/mime.types"))
298 (("ln -s \\$root/conf/mime\\.convs")
301 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
302 "ln -s $root/conf/mime.convs")))
304 ;; fix search path for "cat"
305 (substitute* "cups/testfile.c"
306 (("cupsFileFind\\(\"cat\", \"/bin\"")
307 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
308 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
309 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))))))
310 ;; Make the compressed manpages writable so that the
311 ;; reset-gzip-timestamps phase does not error out.
312 (add-before 'reset-gzip-timestamps 'make-manpages-writable
313 (lambda* (#:key outputs #:allow-other-keys)
314 (let* ((out (assoc-ref outputs "out"))
315 (man (string-append out "/share/man")))
316 (for-each (lambda (file) (chmod file #o644))
317 (find-files man "\\.gz")))))
318 (add-after 'install 'install-cups-filters-symlinks
319 (lambda* (#:key inputs outputs #:allow-other-keys)
320 (let ((out (assoc-ref outputs "out"))
321 (cups-filters (assoc-ref inputs "cups-filters")))
324 (string-append cups-filters "/share/cups/charsets")
325 (string-append out "/share/charsets"))
327 ;; mime types, driver file, ppds
330 (symlink (string-append cups-filters f)
331 (string-append out f)))
332 '("/share/cups/mime/cupsfilters.types"
333 "/share/cups/mime/cupsfilters.convs"
334 "/share/cups/drv/cupsfilters.drv"
341 (string-append out "/lib/cups/filter" (basename f))))
342 (find-files (string-append cups-filters "/lib/cups/filter")))
347 (symlink (string-append cups-filters f)
348 (string-append out "/lib/cups/backend/"
350 '("/lib/cups/backend/parallel"
351 "/lib/cups/backend/serial"))
354 (let ((banners "/share/cups/banners"))
355 (delete-file-recursively (string-append out banners))
356 (symlink (string-append cups-filters banners)
357 (string-append out banners)))
360 (let ((data "/share/cups/data"))
361 (delete-file-recursively (string-append out data))
362 (symlink (string-append cups-filters data)
363 (string-append out data)))))))))
367 ("cups-filters" ,cups-filters)
376 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
377 "/hplip-" version ".tar.gz"))
380 "0xda7x7xxjvzn1l0adlvbwcw21crq1r3r79bkf94q3m5i6abx49g"))
381 (modules '((guix build utils)))
383 ;; Fix type mismatch.
384 '(substitute* "prnt/hpcups/genPCLm.cpp"
385 (("boolean") "bool")))))
386 (build-system gnu-build-system)
387 (home-page "http://hplipopensource.com/")
388 (synopsis "HP Printer Drivers")
389 (description "Hewlett-Packard Printer Drivers and PPDs.")
391 ;; The 'COPYING' file lists directories where each of these 3 licenses
393 (license (list license:gpl2+ license:bsd-3 license:expat))
395 ;; TODO install apparmor profile files eventually.
398 `("--disable-network-build"
399 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
400 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
401 ;; Disable until mime.types merging works (FIXME).
402 "--disable-fax-build"
403 "--enable-hpcups-install"
404 "--enable-new-hpcups"
405 "--enable-cups_ppd_install"
406 "--enable-cups_drv_install"
407 ;; TODO add foomatic drv install eventually.
408 ;; TODO --enable-policykit eventually.
409 ,(string-append "--with-cupsfilterdir="
410 (assoc-ref %outputs "out") "/lib/cups/filter")
411 ,(string-append "--with-cupsbackenddir="
412 (assoc-ref %outputs "out") "/lib/cups/backend")
413 ,(string-append "--with-icondir="
414 (assoc-ref %outputs "out") "/share/applications")
415 ,(string-append "--with-systraydir="
416 (assoc-ref %outputs "out") "/etc/xdg"))
418 #:imported-modules ((guix build python-build-system)
419 ,@%gnu-build-system-modules)
420 #:modules ((guix build gnu-build-system)
422 ((guix build python-build-system) #:prefix python:))
424 #:phases (modify-phases %standard-phases
425 (add-after 'unpack 'fix-hard-coded-file-names
426 (lambda* (#:key inputs outputs #:allow-other-keys)
427 (let ((out (assoc-ref outputs "out"))
428 ;; FIXME: use merged ppds (I think actually only
429 ;; drvs need to be merged).
430 (cupsdir (assoc-ref inputs "cups-minimal")))
431 (substitute* "base/g.py"
432 (("'/usr/share;[^']*'")
433 (string-append "'" cupsdir "/share'"))
434 (("'/etc/hp/hplip.conf'")
435 (string-append "'" out
436 "/etc/hp/hplip.conf" "'")))
438 (substitute* "Makefile.in"
439 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
440 ;; FIXME Use beginning-of-word in regexp.
441 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
442 (("/usr/include/libusb-1.0")
443 (string-append (assoc-ref inputs "libusb")
444 "/include/libusb-1.0"))
445 (("hplip_statedir =.*$")
446 ;; Don't bail out while trying to create
447 ;; /var/lib/hplip. We can safely change its value
448 ;; here because it's hard-coded in the code anyway.
449 "hplip_statedir = $(prefix)\n")
450 (("hplip_confdir = /etc/hp")
451 ;; This is only used for installing the default config.
452 (string-append "hplip_confdir = " out
454 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
455 ;; Note: We don't use hal.
456 (string-append "halpredir = " out
457 "/share/hal/fdi/preprobe/10osvendor"))
458 (("rulesdir = /etc/udev/rules.d")
459 ;; udev rules will be merged by base service.
460 (string-append "rulesdir = " out
461 "/lib/udev/rules.d"))
462 (("rulessystemdir = /usr/lib/systemd/system")
463 ;; We don't use systemd.
464 (string-append "rulessystemdir = " out
465 "/lib/systemd/system"))
467 (string-append out "/etc/sane.d"))))))
469 ;; Wrap bin/* so that the Python libs are found.
470 (add-after 'install 'wrap-binaries
471 (assoc-ref python:%standard-phases 'wrap)))))
473 ;; Python3 support is available starting from hplip@3.15.2.
474 (inputs `(("libjpeg" ,libjpeg)
475 ("cups-minimal" ,cups-minimal)
477 ("sane-backends" ,sane-backends-minimal)
480 ("python-wrapper" ,python-wrapper)
482 ;; TODO: Make hp-setup find python-dbus.
483 ("python-dbus" ,python-dbus)))
484 (native-inputs `(("pkg-config" ,pkg-config)
487 (define-public foomatic-filters
489 (name "foomatic-filters")
494 "http://www.openprinting.org/download/foomatic/"
495 name "-" version ".tar.gz"))
498 "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2"))
500 (search-patches "foomatic-filters-CVE-2015-8327.patch"
501 "foomatic-filters-CVE-2015-8560.patch"))))
502 (build-system gnu-build-system)
504 "https://wiki.linuxfoundation.org/openprinting/database/foomatic")
507 ("pkg-config" ,pkg-config)))
512 '( ;; Specify the installation directories.
513 #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS="
514 (assoc-ref %outputs "out")
516 (string-append "ac_cv_path_CUPS_FILTERS="
517 (assoc-ref %outputs "out")
519 (string-append "ac_cv_path_PPR_INTERFACES="
520 (assoc-ref %outputs "out")
521 "/lib/ppr/interfaces")
522 (string-append "ac_cv_path_PPR_LIB="
523 (assoc-ref %outputs "out")
526 ;; For some reason these are misdiagnosed.
527 "ac_cv_func_malloc_0_nonnull=yes"
528 "ac_cv_func_realloc_0_nonnull=yes")
529 #:test-target "tests"))
530 (synopsis "Convert PostScript to the printer's native format")
532 "This package contains filter scripts used by the printer spoolers to
533 convert the incoming PostScript data into the printer's native format using a
534 printer/driver specific, but spooler-independent PPD file.")
535 (license license:gpl2+)))
537 (define-public foo2zjs
543 ;; XXX: This is an unversioned URL!
544 (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz")
547 "10m1ksbzqsrsl4faqyl73ahfnj2hv1y3zrmr366zvjg7w3l6ag5n"))))
548 (build-system gnu-build-system)
550 '(#:phases (modify-phases %standard-phases
552 (lambda* (#:key outputs #:allow-other-keys)
553 (substitute* (find-files "." "^Makefile$")
554 ;; Set the installation directory.
555 (("^PREFIX[[:blank:]]*=.*$")
556 (string-append "PREFIX = "
557 (assoc-ref outputs "out")
559 (("^UDEVBIN[[:blank:]]*=.*$")
560 "UDEVBIN = $(PREFIX)/bin\n")
561 ;; Don't try to chown/chgrp the installed files.
566 ;; Placate the dependency checks.
567 (("/usr/include/stdio.h")
571 ;; Ensure fixed timestamps in man pages.
572 (("^MODTIME[[:blank:]]*=.*$")
573 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
575 (add-after 'install 'remove-pdf
576 (lambda* (#:key outputs #:allow-other-keys)
577 ;; Remove 'manual.pdf' which is (1) useless (it's a
578 ;; concatenation of man pages), and (2) not
579 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
580 (let ((out (assoc-ref outputs "out")))
581 (for-each delete-file
582 (find-files out "^manual\\.pdf$"))
584 #:parallel-build? #f ;broken makefile
585 #:tests? #f ;no tests
586 #:make-flags '("CC=gcc")))
588 `(("ghostscript" ,ghostscript)
589 ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip'
593 (home-page "http://foo2zjs.rkkda.com/")
594 (synopsis "Printer driver for ZjStream-based printers")
596 "foo2zjs is a printer driver for printers that use the Zenographics
597 ZjStream wire protocol for their print data, often erroneously referred to as
598 winprinters or GDI printers.
600 It supports Minolta/QMS@tie{}Magicolor, Minolta@tie{}Color@tie{}PageWorks/Pro,
601 HP@tie{}LaserJet, and possibly other printers. See @file{README} for details.")
602 (license (list license:expat ; icc2ps/*.[ch]
603 license:gpl2+)))) ; everything else
609 ;; XXX: This currently works. But it will break as soon as a newer
610 ;; version is available since the URLs for older versions are not
611 ;; preserved. An alternative source will be added as soon as
615 ;; The uri has to be chopped up in order to satisfy guix lint.
616 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/06/86/80/"
617 "9955e43f3aead20366851d24cea65de779cf5aa7/"
618 "epson-inkjet-printer-escpr-1.6.18-1lsb3.2.tar.gz"))
621 "137jf52dhi5v2rkmlw4b73f7r7f98m61dpgsb7yvqs2f0yhsjsb3"))))
622 (build-system gnu-build-system)
625 `(,(string-append "--prefix="
626 (assoc-ref %outputs "out"))
627 ,(string-append "--with-cupsfilterdir="
628 (assoc-ref %outputs "out") "/lib/cups/filter")
629 ,(string-append "--with-cupsppddir="
630 (assoc-ref %outputs "out") "/share/ppd"))))
631 (inputs `(("cups" ,cups-minimal)))
632 (synopsis "ESC/P-R printer driver")
634 "This package provides a filter for the Common UNIX Printing
635 System (CUPS). It offers high-quality printing with Seiko Epson color ink jet
636 printers. It can only be used with printers that support the Epson ESC/P-R
638 (home-page "http://download.ebz.epson.net/dsc/search/01/search")
639 (license license:gpl2+)))