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 "0qix1whz5n4ijnl6d44f1v8nzkpv99wqjyrby8vx6xnpskw5hsxk"))
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"))
84 (build-system gnu-build-system)
86 `(#:make-flags (list (string-append "PREFIX=" %output))
88 `("--disable-driverless" ; TODO: enable this
89 "--disable-mutool" ; depends on yet another PDF library (mupdf)
91 ;; Look for the "domain socket of CUPS" in /var/run/cups.
92 "--localstatedir=/var"
94 ;; Free software for the win.
95 "--with-acroread-path=evince"
97 ,(string-append "--with-test-font-path="
98 (assoc-ref %build-inputs "font-dejavu")
99 "/share/fonts/truetype/DejaVuSans.ttf")
100 ,(string-append "--with-gs-path="
101 (assoc-ref %build-inputs "ghostscript")
103 ,(string-append "--with-shell="
104 (assoc-ref %build-inputs "bash")
106 ,(string-append "--with-rcdir="
107 (assoc-ref %outputs "out") "/etc/rc.d"))
109 #:phases (modify-phases %standard-phases
110 (add-after 'unpack 'patch-foomatic-hardcoded-file-names
111 (lambda* (#:key inputs outputs #:allow-other-keys)
112 ;; Foomatic has hardcoded file names we need to fix.
113 (let ((out (assoc-ref outputs "out"))
114 (gs (assoc-ref inputs "ghostscript")))
115 (substitute* "filter/foomatic-rip/foomaticrip.c"
116 (("/usr/local/lib/cups/filter")
117 (string-append out "/lib/cups/filter")))
119 (add-after 'install 'wrap-filters
120 (lambda* (#:key inputs outputs #:allow-other-keys)
121 ;; Some filters expect to find 'gs' in $PATH. We cannot
122 ;; just hard-code its absolute file name in the source
123 ;; because foomatic-rip, for example, has tests like
124 ;; 'startswith(cmd, "gs")'.
125 (let ((out (assoc-ref outputs "out"))
126 (ghostscript (assoc-ref inputs "ghostscript")))
127 (for-each (lambda (file)
130 (,(string-append ghostscript
132 (find-files (string-append
133 out "/lib/cups/filter")))
136 `(("glib" ,glib "bin") ; for gdbus-codegen
137 ("pkg-config" ,pkg-config)))
140 ("fontconfig" ,fontconfig)
141 ("freetype" ,freetype)
142 ("font-dejavu" ,font-dejavu) ; also needed by test suite
143 ("ghostscript" ,ghostscript/cups)
153 ("cups-minimal" ,cups-minimal)))
154 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
155 (synopsis "OpenPrinting CUPS filters and backends")
157 "Contains backends, filters, and other software that was once part of the
158 core CUPS distribution but is no longer maintained by Apple Inc. In addition
159 it contains additional filters developed independently of Apple, especially
160 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
161 ;; Different filters and backends have different licenses; see COPYING for
163 (license (list license:gpl2
170 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
171 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
172 ;; satisfy this dependency.
173 (define-public cups-minimal
175 (name "cups-minimal")
180 (uri (string-append "https://github.com/apple/cups/releases/download/v"
181 version "/cups-" version "-source.tar.gz"))
184 "16qn41b84xz6khrr2pa2wdwlqxr29rrrkjfi618gbgdkq9w5ff20"))))
185 (build-system gnu-build-system)
188 '("--disable-launchd"
192 ;; Seven tests fail, mostly because of files that are provided by the
193 ;; cups-filters package.
196 (modify-phases %standard-phases
197 (add-before 'configure 'patch-makedefs
199 (substitute* "Makedefs.in"
200 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
201 (("/bin/sh") (which "sh")))
203 ;; Make the compressed manpages writable so that the
204 ;; reset-gzip-timestamps phase does not error out.
205 (add-before 'reset-gzip-timestamps 'make-manpages-writable
206 (lambda* (#:key outputs #:allow-other-keys)
207 (let* ((out (assoc-ref outputs "out"))
208 (man (string-append out "/share/man")))
209 (for-each (lambda (file) (chmod file #o644))
210 (find-files man "\\.gz"))
212 (add-before 'build 'patch-tests
214 (substitute* "test/ippserver.c"
215 (("# else /\\* HAVE_AVAHI \\*/")
216 "#elif defined(HAVE_AVAHI)"))
219 `(("pkg-config" ,pkg-config)))
223 (home-page "https://www.cups.org")
224 (synopsis "The Common Unix Printing System")
226 "CUPS is a printing system that uses the Internet Printing Protocol
227 (@dfn{IPP}). It provides System V and BSD command-line interfaces, as well
228 as a Web interface and a C programming interface to manage printers and print
229 jobs. It supports printing to both local (parallel, serial, USB) and
230 networked printers, and printers can be shared from one computer to another.
231 Internally, CUPS uses PostScript Printer Description (@dfn{PPD}) files to
232 describe printer capabilities and features, and a wide variety of generic and
233 device-specific programs to convert and print many types of files.")
234 (license license:gpl2)))
237 (package (inherit cups-minimal)
240 `(;; Three tests fail:
241 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
242 ;; Get-Jobs Operation"
243 ;; * test of number of error/warning messages, probably related to a
247 '("--disable-launchd"
250 (modify-phases %standard-phases
251 (add-before 'configure 'patch-makedefs
253 (substitute* "Makedefs.in"
254 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
255 (("/bin/sh") (which "sh")))
257 (add-before 'check 'patch-tests
259 (let ((filters (assoc-ref %build-inputs "cups-filters"))
260 (catpath (string-append
261 (assoc-ref %build-inputs "coreutils") "/bin/"))
262 (testdir (string-append (getcwd) "/tmp/")))
264 (substitute* "test/run-stp-tests.sh"
265 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
267 ;; allow installation of filters from output dir and from
269 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
272 (assoc-ref %outputs "out") "/lib/cups/filter "
273 filters "/lib/cups/filter"))
275 ;; check for charsets in cups-filters output
276 (("/usr/share/cups/charsets")
277 (string-append filters "/share/cups/charsets"))
279 ;; install additional required filters
280 (("instfilter texttopdf texttopdf pdf")
282 "instfilter texttopdf texttopdf pdf;"
283 "instfilter imagetoraster imagetoraster raster;"
284 "instfilter gstoraster gstoraster raster;"
285 "instfilter urftopdf urftopdf pdf;"
286 "instfilter rastertopdf rastertopdf pdf;"
287 "instfilter pstopdf pstopdf pdf"))
289 ;; specify location of lpstat binary
290 (("description=\"`lpstat -l")
291 "description=\"`../systemv/lpstat -l")
293 ;; patch shebangs of embedded scripts
294 (("#!/bin/sh") (string-append "#!" (which "sh")))
296 ;; also link mime definitions from cups-filters
297 ;; to enable the additional filters for the test suite
298 (("ln -s \\$root/conf/mime\\.types")
301 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
302 "ln -s $root/conf/mime.types"))
303 (("ln -s \\$root/conf/mime\\.convs")
306 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
307 "ln -s $root/conf/mime.convs")))
309 ;; fix search path for "cat"
310 (substitute* "cups/testfile.c"
311 (("cupsFileFind\\(\"cat\", \"/bin\"")
312 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
313 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
314 (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))
316 ;; Make the compressed manpages writable so that the
317 ;; reset-gzip-timestamps phase does not error out.
318 (add-before 'reset-gzip-timestamps 'make-manpages-writable
319 (lambda* (#:key outputs #:allow-other-keys)
320 (let* ((out (assoc-ref outputs "out"))
321 (man (string-append out "/share/man")))
322 (for-each (lambda (file) (chmod file #o644))
323 (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)))
376 ("cups-filters" ,cups-filters)
385 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
386 "/hplip-" version ".tar.gz"))
389 "0x5xs86v18w46rxz5whc15bl4fb7p4km6xqjpwzclp83nl7rl01y"))
390 (modules '((guix build utils)))
392 ;; Fix type mismatch.
394 (substitute* "prnt/hpcups/genPCLm.cpp"
395 (("boolean") "bool"))
397 (build-system gnu-build-system)
398 (home-page "http://hplipopensource.com/")
399 (synopsis "HP Printer Drivers")
400 (description "Hewlett-Packard Printer Drivers and PPDs.")
402 ;; The 'COPYING' file lists directories where each of these 3 licenses
404 (license (list license:gpl2+ license:bsd-3 license:expat))
406 ;; TODO install apparmor profile files eventually.
409 `("--disable-network-build"
410 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
411 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
412 ;; Disable until mime.types merging works (FIXME).
413 "--disable-fax-build"
414 "--enable-hpcups-install"
415 "--enable-new-hpcups"
416 "--enable-cups_ppd_install"
417 "--enable-cups_drv_install"
418 ;; TODO add foomatic drv install eventually.
419 ;; TODO --enable-policykit eventually.
420 ,(string-append "--with-cupsfilterdir="
421 (assoc-ref %outputs "out") "/lib/cups/filter")
422 ,(string-append "--with-cupsbackenddir="
423 (assoc-ref %outputs "out") "/lib/cups/backend")
424 ,(string-append "--with-icondir="
425 (assoc-ref %outputs "out") "/share/applications")
426 ,(string-append "--with-systraydir="
427 (assoc-ref %outputs "out") "/etc/xdg"))
429 #:imported-modules ((guix build python-build-system)
430 ,@%gnu-build-system-modules)
431 #:modules ((guix build gnu-build-system)
433 ((guix build python-build-system) #:prefix python:))
435 #:phases (modify-phases %standard-phases
436 (add-after 'unpack 'fix-hard-coded-file-names
437 (lambda* (#:key inputs outputs #:allow-other-keys)
438 (let ((out (assoc-ref outputs "out"))
439 ;; FIXME: use merged ppds (I think actually only
440 ;; drvs need to be merged).
441 (cupsdir (assoc-ref inputs "cups-minimal")))
442 (substitute* "base/g.py"
443 (("'/usr/share;[^']*'")
444 (string-append "'" cupsdir "/share'"))
445 (("'/etc/hp/hplip.conf'")
446 (string-append "'" out
447 "/etc/hp/hplip.conf" "'")))
449 (substitute* "Makefile.in"
450 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
451 ;; FIXME Use beginning-of-word in regexp.
452 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
453 (("/usr/include/libusb-1.0")
454 (string-append (assoc-ref inputs "libusb")
455 "/include/libusb-1.0"))
456 (("hplip_statedir =.*$")
457 ;; Don't bail out while trying to create
458 ;; /var/lib/hplip. We can safely change its value
459 ;; here because it's hard-coded in the code anyway.
460 "hplip_statedir = $(prefix)\n")
461 (("hplip_confdir = /etc/hp")
462 ;; This is only used for installing the default config.
463 (string-append "hplip_confdir = " out
465 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
466 ;; Note: We don't use hal.
467 (string-append "halpredir = " out
468 "/share/hal/fdi/preprobe/10osvendor"))
469 (("rulesdir = /etc/udev/rules.d")
470 ;; udev rules will be merged by base service.
471 (string-append "rulesdir = " out
472 "/lib/udev/rules.d"))
473 (("rulessystemdir = /usr/lib/systemd/system")
474 ;; We don't use systemd.
475 (string-append "rulessystemdir = " out
476 "/lib/systemd/system"))
478 (string-append out "/etc/sane.d"))))))
480 ;; Wrap bin/* so that the Python libs are found.
481 (add-after 'install 'wrap-binaries
482 (assoc-ref python:%standard-phases 'wrap)))))
484 ;; Python3 support is available starting from hplip@3.15.2.
485 (inputs `(("libjpeg" ,libjpeg)
486 ("cups-minimal" ,cups-minimal)
488 ("sane-backends" ,sane-backends-minimal)
491 ("python-wrapper" ,python-wrapper)
493 ;; TODO: Make hp-setup find python-dbus.
494 ("python-dbus" ,python-dbus)))
495 (native-inputs `(("pkg-config" ,pkg-config)
498 (define-public foomatic-filters
500 (name "foomatic-filters")
505 "http://www.openprinting.org/download/foomatic/"
506 name "-" version ".tar.gz"))
509 "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2"))
511 (search-patches "foomatic-filters-CVE-2015-8327.patch"
512 "foomatic-filters-CVE-2015-8560.patch"))))
513 (build-system gnu-build-system)
515 "https://wiki.linuxfoundation.org/openprinting/database/foomatic")
518 ("pkg-config" ,pkg-config)))
523 '( ;; Specify the installation directories.
524 #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS="
525 (assoc-ref %outputs "out")
527 (string-append "ac_cv_path_CUPS_FILTERS="
528 (assoc-ref %outputs "out")
530 (string-append "ac_cv_path_PPR_INTERFACES="
531 (assoc-ref %outputs "out")
532 "/lib/ppr/interfaces")
533 (string-append "ac_cv_path_PPR_LIB="
534 (assoc-ref %outputs "out")
537 ;; For some reason these are misdiagnosed.
538 "ac_cv_func_malloc_0_nonnull=yes"
539 "ac_cv_func_realloc_0_nonnull=yes")
540 #:test-target "tests"))
541 (synopsis "Convert PostScript to the printer's native format")
543 "This package contains filter scripts used by the printer spoolers to
544 convert the incoming PostScript data into the printer's native format using a
545 printer/driver specific, but spooler-independent PPD file.")
546 (license license:gpl2+)))
548 (define-public foo2zjs
554 ;; XXX: This is an unversioned URL!
555 (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz")
558 "10m1ksbzqsrsl4faqyl73ahfnj2hv1y3zrmr366zvjg7w3l6ag5n"))))
559 (build-system gnu-build-system)
561 '(#:phases (modify-phases %standard-phases
563 (lambda* (#:key outputs #:allow-other-keys)
564 (substitute* (find-files "." "^Makefile$")
565 ;; Set the installation directory.
566 (("^PREFIX[[:blank:]]*=.*$")
567 (string-append "PREFIX = "
568 (assoc-ref outputs "out")
570 (("^UDEVBIN[[:blank:]]*=.*$")
571 "UDEVBIN = $(PREFIX)/bin\n")
572 ;; Don't try to chown/chgrp the installed files.
577 ;; Placate the dependency checks.
578 (("/usr/include/stdio.h")
582 ;; Ensure fixed timestamps in man pages.
583 (("^MODTIME[[:blank:]]*=.*$")
584 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
586 (add-after 'install 'remove-pdf
587 (lambda* (#:key outputs #:allow-other-keys)
588 ;; Remove 'manual.pdf' which is (1) useless (it's a
589 ;; concatenation of man pages), and (2) not
590 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
591 (let ((out (assoc-ref outputs "out")))
592 (for-each delete-file
593 (find-files out "^manual\\.pdf$"))
595 #:parallel-build? #f ;broken makefile
596 #:tests? #f ;no tests
597 #:make-flags '("CC=gcc")))
599 `(("ghostscript" ,ghostscript)
600 ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip'
604 (home-page "http://foo2zjs.rkkda.com/")
605 (synopsis "Printer driver for ZjStream-based printers")
607 "foo2zjs is a printer driver for printers that use the Zenographics
608 ZjStream wire protocol for their print data, often erroneously referred to as
609 winprinters or GDI printers.
611 It supports Minolta/QMS@tie{}Magicolor, Minolta@tie{}Color@tie{}PageWorks/Pro,
612 HP@tie{}LaserJet, and possibly other printers. See @file{README} for details.")
613 (license (list license:expat ; icc2ps/*.[ch]
614 license:gpl2+)))) ; everything else
620 ;; XXX: This currently works. But it will break as soon as a newer
621 ;; version is available since the URLs for older versions are not
622 ;; preserved. An alternative source will be added as soon as
626 ;; The uri has to be chopped up in order to satisfy guix lint.
627 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/07/16/23/"
628 "804253d188a31ae6a0f2722648248ef952afedfb/"
629 "epson-inkjet-printer-escpr-1.6.20-1lsb3.2.tar.gz"))
632 "19800pl7kbbgdzbsy9ijmd7dm3ly4kr2h1dxypqpd075g6n0i770"))))
633 (build-system gnu-build-system)
636 `(,(string-append "--prefix="
637 (assoc-ref %outputs "out"))
638 ,(string-append "--with-cupsfilterdir="
639 (assoc-ref %outputs "out") "/lib/cups/filter")
640 ,(string-append "--with-cupsppddir="
641 (assoc-ref %outputs "out") "/share/ppd"))))
642 (inputs `(("cups" ,cups-minimal)))
643 (synopsis "ESC/P-R printer driver")
645 "This package provides a filter for the Common UNIX Printing
646 System (CUPS). It offers high-quality printing with Seiko Epson color ink jet
647 printers. It can only be used with printers that support the Epson ESC/P-R
649 (home-page "http://download.ebz.epson.net/dsc/search/01/search")
650 (license license:gpl2+)))