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