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