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