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