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