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 ;; Delay to avoid module circularity problems.
50 (define ghostscript/cups
52 (package/inherit ghostscript
53 (name "ghostscript-with-cups")
54 (inputs `(("cups" ,cups-minimal)
55 ,@(package-inputs ghostscript))))))
57 (define-public cups-filters
64 (string-append "https://openprinting.org/download/cups-filters/"
65 "cups-filters-" version ".tar.xz"))
68 "1mg397kgfx0rs9j852f8ppmvaz2al5l75ildbgiqg6j3gwq5jssw"))
69 (modules '((guix build utils)))
71 ;; install backends, banners and filters to cups-filters output
72 ;; directory, not the cups server directory
74 (substitute* "Makefile.in"
75 (("CUPS_DATADIR = @CUPS_DATADIR@")
76 "CUPS_DATADIR = $(PREFIX)/share/cups")
77 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
78 "pkgcupsserverrootdir = $(PREFIX)")
79 ;; Choose standard directories notably so that binaries are
81 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
82 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
83 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
84 "pkgfilterdir = $(PREFIX)/lib/cups/filter"))
85 ;; Find bannertopdf data such as the print test page in our
86 ;; output directory, not CUPS's prefix.
87 (substitute* "configure"
88 (("\\{CUPS_DATADIR\\}/data")
89 "{prefix}/share/cups/data"))))))
90 (build-system gnu-build-system)
92 `(#:make-flags (list (string-append "PREFIX=" %output))
94 `("--disable-driverless" ; TODO: enable this
95 "--disable-mutool" ; depends on yet another PDF library (mupdf)
97 ;; Look for the "domain socket of CUPS" in /var/run/cups.
98 "--localstatedir=/var"
100 ;; Free software for the win.
101 "--with-acroread-path=evince"
103 ,(string-append "--with-test-font-path="
104 (assoc-ref %build-inputs "font-dejavu")
105 "/share/fonts/truetype/DejaVuSans.ttf")
106 ,(string-append "--with-gs-path="
107 (assoc-ref %build-inputs "ghostscript")
109 ,(string-append "--with-shell="
110 (assoc-ref %build-inputs "bash")
112 ,(string-append "--with-rcdir="
113 (assoc-ref %outputs "out") "/etc/rc.d"))
115 #:phases (modify-phases %standard-phases
116 (add-after 'unpack 'patch-foomatic-hardcoded-file-names
117 (lambda* (#:key inputs outputs #:allow-other-keys)
118 ;; Foomatic has hardcoded file names we need to fix.
119 (let ((out (assoc-ref outputs "out"))
120 (gs (assoc-ref inputs "ghostscript")))
121 (substitute* "filter/foomatic-rip/foomaticrip.c"
122 (("/usr/local/lib/cups/filter")
123 (string-append out "/lib/cups/filter")))
125 (add-after 'install 'wrap-filters
126 (lambda* (#:key inputs outputs #:allow-other-keys)
127 ;; Some filters expect to find 'gs' in $PATH. We cannot
128 ;; just hard-code its absolute file name in the source
129 ;; because foomatic-rip, for example, has tests like
130 ;; 'startswith(cmd, "gs")'.
131 (let ((out (assoc-ref outputs "out"))
132 (ghostscript (assoc-ref inputs "ghostscript")))
133 (for-each (lambda (file)
136 (,(string-append ghostscript
138 (find-files (string-append
139 out "/lib/cups/filter")))
142 `(("glib" ,glib "bin") ; for gdbus-codegen
143 ("pkg-config" ,pkg-config)))
146 ("fontconfig" ,fontconfig)
147 ("freetype" ,freetype)
148 ("font-dejavu" ,font-dejavu) ; also needed by test suite
149 ("ghostscript" ,(force ghostscript/cups))
159 ("cups-minimal" ,cups-minimal)))
160 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
161 (synopsis "OpenPrinting CUPS filters and backends")
163 "Contains backends, filters, and other software that was once part of the
164 core CUPS distribution but is no longer maintained by Apple Inc. In addition
165 it contains additional filters developed independently of Apple, especially
166 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
167 ;; Different filters and backends have different licenses; see COPYING for
169 (license (list license:gpl2
176 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
177 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
178 ;; satisfy this dependency.
179 (define-public cups-minimal
181 (name "cups-minimal")
186 (uri (string-append "https://github.com/apple/cups/releases/download/v"
187 version "/cups-" version "-source.tar.gz"))
190 "1k4qxafmapq6hzbkh273fdyzkj9alw6ppwz5k933bhsi4svlsvar"))))
191 (build-system gnu-build-system)
194 '("--disable-launchd"
198 ;; Seven tests fail, mostly because of files that are provided by the
199 ;; cups-filters package.
202 (modify-phases %standard-phases
203 (add-before 'configure 'patch-makedefs
205 (substitute* "Makedefs.in"
206 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
207 (("/bin/sh") (which "sh")))))
208 ;; Make the compressed manpages writable so that the
209 ;; reset-gzip-timestamps phase does not error out.
210 (add-before 'reset-gzip-timestamps 'make-manpages-writable
211 (lambda* (#:key outputs #:allow-other-keys)
212 (let* ((out (assoc-ref outputs "out"))
213 (man (string-append out "/share/man")))
214 (for-each (lambda (file) (chmod file #o644))
215 (find-files man "\\.gz")))))
216 (add-before 'build 'patch-tests
218 (substitute* "test/ippserver.c"
219 (("# else /\\* HAVE_AVAHI \\*/")
220 "#elif defined(HAVE_AVAHI)")))))))
222 `(("pkg-config" ,pkg-config)))
226 (home-page "https://www.cups.org")
227 (synopsis "The Common Unix Printing System")
229 "CUPS is a printing system that uses the Internet Printing Protocol
230 (@dfn{IPP}). It provides System V and BSD command-line interfaces, as well
231 as a Web interface and a C programming interface to manage printers and print
232 jobs. It supports printing to both local (parallel, serial, USB) and
233 networked printers, and printers can be shared from one computer to another.
234 Internally, CUPS uses PostScript Printer Description (@dfn{PPD}) files to
235 describe printer capabilities and features, and a wide variety of generic and
236 device-specific programs to convert and print many types of files.")
237 (license license:gpl2)))
240 (package (inherit cups-minimal)
243 `(;; Three tests fail:
244 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
245 ;; Get-Jobs Operation"
246 ;; * test of number of error/warning messages, probably related to a
250 '("--disable-launchd"
253 (modify-phases %standard-phases
254 (add-before 'configure 'patch-makedefs
256 (substitute* "Makedefs.in"
257 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
258 (("/bin/sh") (which "sh")))))
259 (add-before 'check 'patch-tests
261 (let ((filters (assoc-ref %build-inputs "cups-filters"))
262 (catpath (string-append
263 (assoc-ref %build-inputs "coreutils") "/bin/"))
264 (testdir (string-append (getcwd) "/tmp/")))
266 (substitute* "test/run-stp-tests.sh"
267 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
269 ;; allow installation of filters from output dir and from
271 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
274 (assoc-ref %outputs "out") "/lib/cups/filter "
275 filters "/lib/cups/filter"))
277 ;; check for charsets in cups-filters output
278 (("/usr/share/cups/charsets")
279 (string-append filters "/share/cups/charsets"))
281 ;; install additional required filters
282 (("instfilter texttopdf texttopdf pdf")
284 "instfilter texttopdf texttopdf pdf;"
285 "instfilter imagetoraster imagetoraster raster;"
286 "instfilter gstoraster gstoraster raster;"
287 "instfilter urftopdf urftopdf pdf;"
288 "instfilter rastertopdf rastertopdf pdf;"
289 "instfilter pstopdf pstopdf pdf"))
291 ;; specify location of lpstat binary
292 (("description=\"`lpstat -l")
293 "description=\"`../systemv/lpstat -l")
295 ;; patch shebangs of embedded scripts
296 (("#!/bin/sh") (string-append "#!" (which "sh")))
298 ;; also link mime definitions from cups-filters
299 ;; to enable the additional filters for the test suite
300 (("ln -s \\$root/conf/mime\\.types")
303 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
304 "ln -s $root/conf/mime.types"))
305 (("ln -s \\$root/conf/mime\\.convs")
308 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
309 "ln -s $root/conf/mime.convs")))
311 ;; fix search path for "cat"
312 (substitute* "cups/testfile.c"
313 (("cupsFileFind\\(\"cat\", \"/bin\"")
314 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
315 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
316 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))))))
317 ;; Make the compressed manpages writable so that the
318 ;; reset-gzip-timestamps phase does not error out.
319 (add-before 'reset-gzip-timestamps 'make-manpages-writable
320 (lambda* (#:key outputs #:allow-other-keys)
321 (let* ((out (assoc-ref outputs "out"))
322 (man (string-append out "/share/man")))
323 (for-each (lambda (file) (chmod file #o644))
324 (find-files man "\\.gz")))))
325 (add-after 'install 'install-cups-filters-symlinks
326 (lambda* (#:key inputs outputs #:allow-other-keys)
327 (let ((out (assoc-ref outputs "out"))
328 (cups-filters (assoc-ref inputs "cups-filters")))
331 (string-append cups-filters "/share/cups/charsets")
332 (string-append out "/share/charsets"))
334 ;; mime types, driver file, ppds
337 (symlink (string-append cups-filters f)
338 (string-append out f)))
339 '("/share/cups/mime/cupsfilters.types"
340 "/share/cups/mime/cupsfilters.convs"
341 "/share/cups/drv/cupsfilters.drv"
348 (string-append out "/lib/cups/filter" (basename f))))
349 (find-files (string-append cups-filters "/lib/cups/filter")))
354 (symlink (string-append cups-filters f)
355 (string-append out "/lib/cups/backend/"
357 '("/lib/cups/backend/parallel"
358 "/lib/cups/backend/serial"))
361 (let ((banners "/share/cups/banners"))
362 (delete-file-recursively (string-append out banners))
363 (symlink (string-append cups-filters banners)
364 (string-append out banners)))
367 (let ((data "/share/cups/data"))
368 (delete-file-recursively (string-append out data))
369 (symlink (string-append cups-filters data)
370 (string-append out data)))))))))
374 ("cups-filters" ,cups-filters)
383 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
384 "/hplip-" version ".tar.gz"))
387 "0v27hg856b5z2rilczcbfgz8ksxn0n810g1glac3mxkj8qbl8wqg"))))
388 (build-system gnu-build-system)
389 (home-page "http://hplipopensource.com/")
390 (synopsis "HP Printer Drivers")
391 (description "Hewlett-Packard Printer Drivers and PPDs.")
393 ;; The 'COPYING' file lists directories where each of these 3 licenses
395 (license (list license:gpl2+ license:bsd-3 license:expat))
397 ;; TODO install apparmor profile files eventually.
400 `("--disable-network-build"
401 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
402 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
403 ;; Disable until mime.types merging works (FIXME).
404 "--disable-fax-build"
405 "--enable-hpcups-install"
406 "--enable-new-hpcups"
407 "--enable-cups_ppd_install"
408 "--enable-cups_drv_install"
409 ;; TODO add foomatic drv install eventually.
410 ;; TODO --enable-policykit eventually.
411 ,(string-append "--with-cupsfilterdir="
412 (assoc-ref %outputs "out") "/lib/cups/filter")
413 ,(string-append "--with-cupsbackenddir="
414 (assoc-ref %outputs "out") "/lib/cups/backend")
415 ,(string-append "--with-icondir="
416 (assoc-ref %outputs "out") "/share/applications")
417 ,(string-append "--with-systraydir="
418 (assoc-ref %outputs "out") "/etc/xdg"))
420 #:imported-modules ((guix build python-build-system)
421 ,@%gnu-build-system-modules)
422 #:modules ((guix build gnu-build-system)
424 ((guix build python-build-system) #:prefix python:))
426 #:phases (modify-phases %standard-phases
427 (add-after 'unpack 'fix-hard-coded-file-names
428 (lambda* (#:key inputs outputs #:allow-other-keys)
429 (let ((out (assoc-ref outputs "out"))
430 ;; FIXME: use merged ppds (I think actually only
431 ;; drvs need to be merged).
432 (cupsdir (assoc-ref inputs "cups-minimal")))
433 (substitute* "base/g.py"
434 (("'/usr/share;[^']*'")
435 (string-append "'" cupsdir "/share'"))
436 (("'/etc/hp/hplip.conf'")
437 (string-append "'" out
438 "/etc/hp/hplip.conf" "'")))
440 (substitute* "Makefile.in"
441 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
442 ;; FIXME Use beginning-of-word in regexp.
443 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
444 (("/usr/include/libusb-1.0")
445 (string-append (assoc-ref inputs "libusb")
446 "/include/libusb-1.0"))
447 (("^\tinstall-dist_hplip_stateDATA")
448 ;; Remove dependencies on
449 ;; 'install-dist_hplip_stateDATA' so we don't bail
450 ;; out while trying to create /var/lib/hplip.
452 (("hplip_confdir = /etc/hp")
453 ;; This is only used for installing the default config.
454 (string-append "hplip_confdir = " out
456 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
457 ;; Note: We don't use hal.
458 (string-append "halpredir = " out
459 "/share/hal/fdi/preprobe/10osvendor"))
460 (("rulesdir = /etc/udev/rules.d")
461 ;; udev rules will be merged by base service.
462 (string-append "rulesdir = " out
463 "/lib/udev/rules.d"))
464 (("rulessystemdir = /usr/lib/systemd/system")
465 ;; We don't use systemd.
466 (string-append "rulessystemdir = " out
467 "/lib/systemd/system"))
469 (string-append out "/etc/sane.d"))))))
471 ;; Wrap bin/* so that the Python libs are found.
472 (add-after 'install 'wrap-binaries
473 (assoc-ref python:%standard-phases 'wrap)))))
475 ;; Python3 support is available starting from hplip@3.15.2.
476 (inputs `(("libjpeg" ,libjpeg)
477 ("cups-minimal" ,cups-minimal)
479 ("sane-backends" ,sane-backends-minimal)
481 ("python-wrapper" ,python-wrapper)
483 ;; TODO: Make hp-setup find python-dbus.
484 ("python-dbus" ,python-dbus)))
485 (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 "17w26r15094j4fqifa7f7i7jad4gsy9zdlq69kffrykcw31qx3q8"))
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
539 ;; The tarball is called "foo2zjs", but the web page talks about
540 ;; "foo2xqx". Go figure!
545 ;; XXX: This is an unversioned URL!
546 (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz")
549 "0amjj3jr6s6h7crzxyx11v31sj0blz7k5c2vycz4gn8cxlmk3c7w"))))
550 (build-system gnu-build-system)
552 '(#:phases (modify-phases %standard-phases
554 (lambda* (#:key outputs #:allow-other-keys)
555 (substitute* (find-files "." "^Makefile$")
556 ;; Set the installation directory.
557 (("^PREFIX[[:blank:]]*=.*$")
558 (string-append "PREFIX = "
559 (assoc-ref outputs "out")
561 (("^UDEVBIN[[:blank:]]*=.*$")
562 "UDEVBIN = $(PREFIX)/bin\n")
563 ;; Don't try to chown/chgrp the installed files.
568 ;; Placate the dependency checks.
569 (("/usr/include/stdio.h")
573 ;; Ensure fixed timestamps in man pages.
574 (("^MODTIME[[:blank:]]*=.*$")
575 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
577 (add-after 'install 'remove-pdf
578 (lambda* (#:key outputs #:allow-other-keys)
579 ;; Remove 'manual.pdf' which is (1) useless (it's a
580 ;; concatenation of man pages), and (2) not
581 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
582 (let ((out (assoc-ref outputs "out")))
583 (for-each delete-file
584 (find-files out "^manual\\.pdf$"))
586 #:parallel-build? #f ;broken makefile
587 #:tests? #f ;no tests
588 #:make-flags '("CC=gcc")))
590 `(("ghostscript" ,ghostscript)
591 ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip'
595 (home-page "http://foo2xqx.rkkda.com/")
596 (synopsis "Printer driver for XQX stream protocol")
598 "This package provides a printer driver notably for the ZJS and XQX
599 protocols, which cover printers made by Konica, HP (LaserJet), Oki, Samsung,
600 and more. See @file{README} for details.")
601 (license license:gpl2+)))
607 ;; XXX: This currently works. But it will break as soon as a newer
608 ;; version is available since the URLs for older versions are not
609 ;; preserved. An alternative source will be added as soon as
613 ;; The uri has to be chopped up in order to satisfy guix lint.
614 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/06/66/09/"
615 "4ac2bf69bb1ddf4a9ad525596615cbb40fe4dad5/"
616 "epson-inkjet-printer-escpr-1.6.17-1lsb3.2.tar.gz"))
619 "0m6v1wdavw4r25jfywqchsx0v9ss1l5fr8vq9d0d8cmjnz8mqblv"))))
620 (build-system gnu-build-system)
623 `(,(string-append "--prefix="
624 (assoc-ref %outputs "out"))
625 ,(string-append "--with-cupsfilterdir="
626 (assoc-ref %outputs "out") "/lib/cups/filter")
627 ,(string-append "--with-cupsppddir="
628 (assoc-ref %outputs "out") "/share/ppd"))))
629 (inputs `(("cups" ,cups-minimal)))
630 (synopsis "ESC/P-R printer driver")
632 "This package provides a filter for the Common UNIX Printing
633 System (CUPS). It offers high-quality printing with Seiko Epson color ink jet
634 printers. It can only be used with printers that support the Epson ESC/P-R
636 (home-page "http://download.ebz.epson.net/dsc/search/01/search")
637 (license license:gpl2+)))