gnu: escpr: Omit static library.
[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)
21c51ebd 449 (home-page "https://developers.hp.com/hp-linux-imaging-and-printing")
6a163a3f
TGR
450 (synopsis "HP printer drivers")
451 (description
452 "Hewlett-Packard printer drivers and PostScript Printer Descriptions
453(@dfn{PPD}s).")
2b56dc01
DM
454
455 ;; The 'COPYING' file lists directories where each of these 3 licenses
456 ;; applies.
457 (license (list license:gpl2+ license:bsd-3 license:expat))
458
459 ;; TODO install apparmor profile files eventually.
460 (arguments
461 `(#:configure-flags
462 `("--disable-network-build"
463 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
464 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
b17004f9
TGR
465 ,(string-append "LDFLAGS=-Wl,-rpath="
466 (assoc-ref %outputs "out") "/lib")
2b56dc01
DM
467 ;; Disable until mime.types merging works (FIXME).
468 "--disable-fax-build"
2b56dc01 469 "--enable-new-hpcups"
2b56dc01
DM
470 ;; TODO add foomatic drv install eventually.
471 ;; TODO --enable-policykit eventually.
472 ,(string-append "--with-cupsfilterdir="
473 (assoc-ref %outputs "out") "/lib/cups/filter")
474 ,(string-append "--with-cupsbackenddir="
475 (assoc-ref %outputs "out") "/lib/cups/backend")
476 ,(string-append "--with-icondir="
477 (assoc-ref %outputs "out") "/share/applications")
478 ,(string-append "--with-systraydir="
407ef4b3
TGR
479 (assoc-ref %outputs "out") "/etc/xdg")
480 "--enable-qt5" "--disable-qt4")
2b56dc01
DM
481
482 #:imported-modules ((guix build python-build-system)
483 ,@%gnu-build-system-modules)
484 #:modules ((guix build gnu-build-system)
485 (guix build utils)
486 ((guix build python-build-system) #:prefix python:))
487
fbaa66ac
TGR
488 #:phases
489 (modify-phases %standard-phases
490 (add-after 'unpack 'fix-hard-coded-file-names
491 (lambda* (#:key inputs outputs #:allow-other-keys)
492 (let ((out (assoc-ref outputs "out"))
493 ;; FIXME: use merged ppds (I think actually only
494 ;; drvs need to be merged).
495 (cupsdir (assoc-ref inputs "cups-minimal")))
496 (substitute* "base/g.py"
497 (("'/usr/share;[^']*'")
498 (string-append "'" cupsdir "/share'"))
499 (("'/etc/hp/hplip.conf'")
500 (string-append "'" out
501 "/etc/hp/hplip.conf" "'")))
502
503 (substitute* "Makefile.in"
504 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
505 ;; FIXME Use beginning-of-word in regexp.
506 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
507 (("/usr/include/libusb-1.0")
508 (string-append (assoc-ref inputs "libusb")
509 "/include/libusb-1.0"))
510 (("hplip_statedir =.*$")
511 ;; Don't bail out while trying to create
512 ;; /var/lib/hplip. We can safely change its value
513 ;; here because it's hard-coded in the code anyway.
514 "hplip_statedir = $(prefix)\n")
515 (("hplip_confdir = /etc/hp")
516 ;; This is only used for installing the default config.
517 (string-append "hplip_confdir = " out
518 "/etc/hp"))
519 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
520 ;; We don't use hal.
521 (string-append "halpredir = " out
522 "/share/hal/fdi/preprobe/10osvendor"))
523 (("rulesdir = /etc/udev/rules.d")
524 ;; udev rules will be merged by base service.
525 (string-append "rulesdir = " out
526 "/lib/udev/rules.d"))
527 (("rulessystemdir = /usr/lib/systemd/system")
528 ;; We don't use systemd.
529 (string-append "rulessystemdir = " out
530 "/lib/systemd/system"))
531 (("/etc/sane.d")
68c7f577
MB
532 (string-append out "/etc/sane.d")))
533 #t)))
534 (add-before 'configure 'fix-build-with-python-3.8
535 (lambda* (#:key inputs #:allow-other-keys)
536 (let ((python (assoc-ref inputs "python")))
537 ;; XXX: The configure script of looks for Python headers in the
538 ;; wrong places as of version 3.20.3. Help it by adding the
539 ;; include directory on C_INCLUDE_PATH.
540 (when python
541 (setenv "C_INCLUDE_PATH"
542 (string-append python "/include/python"
543 (python:python-version python)
544 ":" (getenv "C_INCLUDE_PATH"))))
545 #t)))
afc7882f
DM
546 (add-after 'install 'install-models-dat
547 (lambda* (#:key outputs #:allow-other-keys)
548 (let* ((out (assoc-ref outputs "out"))
549 (models-dir (string-append out
550 "/share/hplip/data/models")))
551 (install-file "data/models/models.dat" models-dir))
552 #t))
fbaa66ac
TGR
553 (add-after 'install 'wrap-binaries
554 ;; Scripts in /bin are all symlinks to .py files in /share/hplip.
555 ;; Symlinks are immune to the Python build system's 'WRAP phase,
556 ;; and the .py files can't be wrapped because they are reused as
557 ;; modules. Replacing the symlinks in /bin with copies and
558 ;; wrapping them also doesn't work (“ModuleNotFoundError:
559 ;; No module named 'base'”). Behold: a custom WRAP-PROGRAM.
560 (lambda* (#:key inputs outputs #:allow-other-keys)
561 (let* ((out (assoc-ref outputs "out"))
562 (bin (string-append out "/bin"))
563 (python (assoc-ref inputs "python")))
564 (with-directory-excursion bin
565 (for-each (lambda (file)
566 (let ((target (readlink file)))
567 (delete-file file)
568 (with-output-to-file file
569 (lambda _
570 (format #t
571 "#!~a~@
572 export PYTHONPATH=\"~a:~a\"~@
573 exec -a \"$0\" \"~a/~a\" \"$@\"~%"
574 (which "bash")
575 (string-append
576 out "/lib/python"
577 (python:python-version python)
578 "/site-packages")
579 (getenv "PYTHONPATH")
580 bin target)))
581 (chmod file #o755)))
582 (find-files "." (lambda (file stat)
583 (eq? 'symlink (stat:type stat)))))
584 #t)))))))
2b56dc01 585
407ef4b3
TGR
586 ;; Note that the error messages printed by the tools in the case of
587 ;; missing dependencies are often downright misleading.
588 ;; TODO: hp-toolbox still fails to start with:
589 ;; from dbus.mainloop.pyqt5 import DBusQtMainLoop
590 ;; ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
591 (inputs
592 `(("cups-minimal" ,cups-minimal)
593 ("dbus" ,dbus)
4bd428a7 594 ("libjpeg" ,libjpeg-turbo)
407ef4b3
TGR
595 ("libusb" ,libusb)
596 ("python" ,python)
597 ("python-dbus" ,python-dbus)
598 ("python-pygobject" ,python-pygobject)
599 ("python-pyqt" ,python-pyqt)
600 ("python-wrapper" ,python-wrapper)
601 ("sane-backends" ,sane-backends-minimal)
602 ("zlib" ,zlib)))
603 (native-inputs
604 `(("perl" ,perl)
605 ("pkg-config" ,pkg-config)))))
d02aabaf 606
8e189596
EF
607(define-public hplip-minimal
608 (package
609 (inherit hplip)
610 (name "hplip-minimal")
611 (arguments
612 (substitute-keyword-arguments (package-arguments hplip)
613 ((#:configure-flags cf)
c9b3a72b
LC
614 ;; Produce a "light build", meaning that only the printer (CUPS) and
615 ;; scanner (SANE) support gets built, without all the 'hp-*'
616 ;; command-line tools.
617 `(cons "--enable-lite-build"
618 (delete "--enable-qt5" ,cf)))
619 ((#:phases phases)
620 ;; The 'wrap-binaries' is not needed here since the 'hp-*' programs
621 ;; are not installed.
622 `(alist-delete 'wrap-binaries ,phases))))
623 (inputs (remove (match-lambda
624 ((label . _)
625 (string-prefix? "python" label)))
626 (package-inputs hplip)))
8e189596
EF
627 (synopsis "GUI-less version of hplip")))
628
d02aabaf
LC
629(define-public foomatic-filters
630 (package
631 (name "foomatic-filters")
4bd05a21 632 (version "4.0.17")
d02aabaf
LC
633 (source (origin
634 (method url-fetch)
635 (uri (string-append
636 "http://www.openprinting.org/download/foomatic/"
8d515ce6 637 "foomatic-filters-" version ".tar.gz"))
d02aabaf
LC
638 (sha256
639 (base32
4bd05a21 640 "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2"))
d02aabaf
LC
641 (patches
642 (search-patches "foomatic-filters-CVE-2015-8327.patch"
643 "foomatic-filters-CVE-2015-8560.patch"))))
644 (build-system gnu-build-system)
645 (home-page
646 "https://wiki.linuxfoundation.org/openprinting/database/foomatic")
647 (native-inputs
648 `(("perl" ,perl)
649 ("pkg-config" ,pkg-config)))
650 (inputs
651 `(("dbus" ,dbus)
652 ("a2ps" ,a2ps)))
653 (arguments
654 '( ;; Specify the installation directories.
655 #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS="
656 (assoc-ref %outputs "out")
657 "/lib/cups/backend")
658 (string-append "ac_cv_path_CUPS_FILTERS="
659 (assoc-ref %outputs "out")
660 "/lib/cups/filter")
661 (string-append "ac_cv_path_PPR_INTERFACES="
662 (assoc-ref %outputs "out")
663 "/lib/ppr/interfaces")
664 (string-append "ac_cv_path_PPR_LIB="
665 (assoc-ref %outputs "out")
666 "/lib/ppr/lib")
667
668 ;; For some reason these are misdiagnosed.
669 "ac_cv_func_malloc_0_nonnull=yes"
670 "ac_cv_func_realloc_0_nonnull=yes")
671 #:test-target "tests"))
672 (synopsis "Convert PostScript to the printer's native format")
673 (description
674 "This package contains filter scripts used by the printer spoolers to
675convert the incoming PostScript data into the printer's native format using a
676printer/driver specific, but spooler-independent PPD file.")
677 (license license:gpl2+)))
5db0a1cd
LC
678
679(define-public foo2zjs
680 (package
5db0a1cd 681 (name "foo2zjs")
32d531ee 682 (version "20200610")
5db0a1cd
LC
683 (source (origin
684 (method url-fetch)
685 ;; XXX: This is an unversioned URL!
686 (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz")
687 (sha256
688 (base32
32d531ee 689 "11ddx6wf8b5ksl4fqw6fnyz9m3y470lryyrskkya2bsch2bvj9lg"))))
5db0a1cd
LC
690 (build-system gnu-build-system)
691 (arguments
692 '(#:phases (modify-phases %standard-phases
693 (replace 'configure
694 (lambda* (#:key outputs #:allow-other-keys)
695 (substitute* (find-files "." "^Makefile$")
696 ;; Set the installation directory.
697 (("^PREFIX[[:blank:]]*=.*$")
698 (string-append "PREFIX = "
699 (assoc-ref outputs "out")
700 "\n"))
701 (("^UDEVBIN[[:blank:]]*=.*$")
702 "UDEVBIN = $(PREFIX)/bin\n")
703 ;; Don't try to chown/chgrp the installed files.
704 (("-oroot")
705 "")
706 (("-glp")
707 "")
708 ;; Placate the dependency checks.
709 (("/usr/include/stdio.h")
710 "/etc/passwd")
711 (("/usr/")
712 "$(PREFIX)/")
713 ;; Ensure fixed timestamps in man pages.
714 (("^MODTIME[[:blank:]]*=.*$")
715 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
716 #t))
717 (add-after 'install 'remove-pdf
718 (lambda* (#:key outputs #:allow-other-keys)
719 ;; Remove 'manual.pdf' which is (1) useless (it's a
720 ;; concatenation of man pages), and (2) not
721 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
722 (let ((out (assoc-ref outputs "out")))
723 (for-each delete-file
724 (find-files out "^manual\\.pdf$"))
725 #t))))
726 #:parallel-build? #f ;broken makefile
727 #:tests? #f ;no tests
728 #:make-flags '("CC=gcc")))
729 (inputs
730 `(("ghostscript" ,ghostscript)
731 ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip'
732 (native-inputs
733 `(("bc" ,bc)
734 ("groff" ,groff)))
0a7d3e1e
TGR
735 (home-page "http://foo2zjs.rkkda.com/")
736 (synopsis "Printer driver for ZjStream-based printers")
5db0a1cd 737 (description
0a7d3e1e
TGR
738 "foo2zjs is a printer driver for printers that use the Zenographics
739ZjStream wire protocol for their print data, often erroneously referred to as
740winprinters or GDI printers.
741
742It supports Minolta/QMS@tie{}Magicolor, Minolta@tie{}Color@tie{}PageWorks/Pro,
743HP@tie{}LaserJet, and possibly other printers. See @file{README} for details.")
744 (license (list license:expat ; icc2ps/*.[ch]
745 license:gpl2+)))) ; everything else
011f5769
DNB
746
747(define-public escpr
748 (package
749 (name "escpr")
12abf24c 750 (version "1.7.8")
011f5769
DNB
751 ;; XXX: This currently works. But it will break as soon as a newer
752 ;; version is available since the URLs for older versions are not
753 ;; preserved. An alternative source will be added as soon as
754 ;; available.
7158dc2d
TGR
755 (source
756 (origin
757 (method url-fetch)
12abf24c
TGR
758 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/12/04/32/"
759 "1a455ef8618def65700ca4e446311c2fb43cd839/"
760 "epson-inkjet-printer-escpr-1.7.8-1lsb3.2.tar.gz"))
7158dc2d 761 (sha256
12abf24c 762 (base32 "1pygg2bd2gh27dc65h3dzwrpvi6bq5c87wl0ldchqlc2b3blsx6p"))))
011f5769
DNB
763 (build-system gnu-build-system)
764 (arguments
aa954ec3
TGR
765 `(#:modules
766 ((srfi srfi-26)
767 ,@%gnu-build-system-modules)
768 #:configure-flags
3b2a2621
TGR
769 `("--disable-static"
770 ,(string-append "--prefix="
011f5769
DNB
771 (assoc-ref %outputs "out"))
772 ,(string-append "--with-cupsfilterdir="
773 (assoc-ref %outputs "out") "/lib/cups/filter")
774 ,(string-append "--with-cupsppddir="
7158dc2d
TGR
775 (assoc-ref %outputs "out") "/share/cups/model"))
776 #:phases
777 (modify-phases %standard-phases
778 (add-after 'unpack 'patch-autotools-version-requirement
779 (lambda _
780 (substitute* "aclocal.m4"
781 (("1\\.15")
782 ,(package-version automake)))
783 (substitute* "configure"
784 (("^(ACLOCAL=).*" _ match)
785 (string-append match "aclocal"))
786 (("^(AUTOMAKE=).*" _ match)
787 (string-append match "automake")))
aa954ec3
TGR
788 #t))
789 (add-after 'install 'compress-PPDs
790 (lambda* (#:key outputs #:allow-other-keys)
791 (let ((out (assoc-ref outputs "out")))
792 (with-directory-excursion out
793 (for-each (cut invoke "gzip" "-9" <>)
794 (find-files "share/cups" "\\.ppd$")))))))))
7158dc2d
TGR
795 (native-inputs
796 `(("autoconf" ,autoconf)
797 ("automake" ,automake)))
798 (inputs
799 `(("cups" ,cups-minimal)))
011f5769
DNB
800 (synopsis "ESC/P-R printer driver")
801 (description
0b66a8bb
TGR
802 "This package provides a filter for @acronym{CUPS, the Common UNIX Printing
803System} that offers high-quality printing with Seiko@tie{}Epson color ink jet
804printers. It can be used only with printers that support the Epson@tie{}ESC/P-R
011f5769 805language.")
61eba727 806 (home-page "http://download.ebz.epson.net/dsc/search/01/search/?OSC=LX")
011f5769 807 (license license:gpl2+)))
dd6f309d 808
390f3e9e 809(define-public splix
a25362a5
TGR
810 ;; Last released in 2009 <https://sourceforge.net/projects/splix/files/>.
811 ;; Last SVN commit was 2013 <https://svn.code.sf.net/p/splix/code/splix/>.
812 ;; Use a more maintained fork with several bug fixes and support for newer
813 ;; printer models.
814 (let ((commit "76268c4dd7dbc8218ea7426401104c3b40cc707a")
815 (revision "315"))
390f3e9e
TGR
816 (package
817 (name "splix")
a25362a5 818 (version (git-version "2.0.0" revision commit))
390f3e9e
TGR
819 (source
820 (origin
a25362a5
TGR
821 (method git-fetch)
822 (uri (git-reference
823 (url "https://gitlab.com/ScumCoder/splix")
824 (commit commit)))
825 (file-name (git-file-name name version))
390f3e9e 826 (sha256
a25362a5 827 (base32 "1mxsvllwwr1v8sgrax0b7gkajjhnm0l06s67spmaxz47lyll1qab"))))
390f3e9e 828 (build-system gnu-build-system)
a25362a5 829 ;; PPDs have been obsolete since CUPS 1.2 and make up 90% of total size.
390f3e9e
TGR
830 (outputs (list "out" "ppd"))
831 (arguments
359a195e
TGR
832 `(#:modules
833 ((srfi srfi-26)
834 ,@%gnu-build-system-modules)
835 #:make-flags
390f3e9e
TGR
836 (list (string-append "CUPSDRV="
837 (assoc-ref %outputs "out") "/share/cups/drv")
838 (string-append "CUPSFILTER="
839 (assoc-ref %outputs "out") "/lib/cups/filter")
840 (string-append "CUPSPPD="
841 (assoc-ref %outputs "ppd") "/share/cups/model")
842 "CACHESIZE=100" ; pages in RAM, ±300 KiB each
843 "THREADS=4") ; compress and print faster
844 #:phases
845 (modify-phases %standard-phases
a25362a5
TGR
846 (add-after 'unpack 'enter-subdirectory
847 ;; The git repository replicates the top-level SVN layout.
848 (lambda _
849 (chdir "splix")
850 #t))
390f3e9e
TGR
851 (delete 'configure) ; no configure script
852 (add-before 'build 'build-.drv-files
853 (lambda* (#:key make-flags #:allow-other-keys)
854 (apply invoke "make" "drv" make-flags)))
855 (add-after 'install 'install-.drv-files
856 (lambda* (#:key make-flags #:allow-other-keys)
359a195e
TGR
857 (apply invoke "make" "install" "DRV_ONLY=1" make-flags)))
858 (add-after 'install 'compress-PPDs
859 (lambda* (#:key outputs #:allow-other-keys)
860 (let ((ppd (assoc-ref outputs "ppd")))
861 (for-each (cut invoke "gzip" "-9" <>)
862 (find-files ppd "\\.ppd$"))))))
390f3e9e
TGR
863 #:tests? #f)) ; no test suite
864 (inputs
865 `(("cups" ,cups-minimal)
a25362a5
TGR
866 ("jbigkit" ,jbigkit)
867 ("zlib" ,zlib)))
390f3e9e
TGR
868 (synopsis "QPDL (SPL2) printer driver")
869 (description
870 "SpliX is a set of CUPS drivers for printers that speak @acronym{QPDL,
871Quick Page Description Language}, also called @acronym{SPL2, Samsung Printer
872Language version 2}. These include many laser printers sold by Samsung,
873Xerox, Lexmark, Toshiba, and Dell.
874
875Colour printers need colour profile files to get better results. These
876@file{cms} files are provided by the printer's manufacturer and must be
877obtained and installed separately.")
878 (home-page "http://splix.ap2c.org/")
879 (license license:gpl2))))
880
dd6f309d
CB
881(define-public python-pycups
882 (package
883 (name "python-pycups")
884 (version "1.9.74")
885 (source
886 (origin
887 (method url-fetch)
888 (uri (pypi-uri "pycups" version ".tar.bz2"))
889 (sha256
890 (base32
891 "1ffp7sswhdsfpy88zg0cc8kl04wygkjs01rlm9f0spbwk8jhy2c6"))))
892 (build-system python-build-system)
893 (arguments
894 '(;; Tests require CUPS to be running
895 #:tests? #f))
896 (inputs
897 `(("cups" ,cups)))
898 (home-page "https://github.com/zdohnal/pycups")
899 (synopsis "Python bindings for libcups")
900 (description
901 "This package provides Python bindings for libcups, wrapping the CUPS
902API.")
903 (license license:gpl2+)))