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