Commit | Line | Data |
---|---|---|
51002318 RW |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net> | |
2b56dc01 | 3 | ;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org> |
fad51a18 | 4 | ;;; Copyright © 2015, 2016 Efraim Flashner <efraim@flashner.co.il> |
2b56dc01 | 5 | ;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org> |
8afabb2e | 6 | ;;; Copyright © 2017 Leo Famulari <leo@famulari.name> |
51002318 RW |
7 | ;;; |
8 | ;;; This file is part of GNU Guix. | |
9 | ;;; | |
10 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
11 | ;;; under the terms of the GNU General Public License as published by | |
12 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
13 | ;;; your option) any later version. | |
14 | ;;; | |
15 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
16 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;;; GNU General Public License for more details. | |
19 | ;;; | |
20 | ;;; You should have received a copy of the GNU General Public License | |
21 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
22 | ||
23 | (define-module (gnu packages cups) | |
24 | #:use-module ((guix licenses) #:prefix license:) | |
25 | #:use-module (guix packages) | |
26 | #:use-module (guix download) | |
27 | #:use-module (guix build-system gnu) | |
28 | #:use-module (gnu packages) | |
29 | #:use-module (gnu packages avahi) | |
30 | #:use-module (gnu packages compression) | |
2b56dc01 DM |
31 | #:use-module (gnu packages libusb) |
32 | #:use-module (gnu packages autotools) | |
33 | #:use-module (gnu packages python) | |
34 | #:use-module (gnu packages scanner) | |
51002318 RW |
35 | #:use-module (gnu packages image) |
36 | #:use-module (gnu packages fonts) ;font-dejavu | |
37 | #:use-module (gnu packages fontutils) | |
38 | #:use-module (gnu packages ghostscript) | |
39 | #:use-module (gnu packages glib) | |
51002318 | 40 | #:use-module (gnu packages pdf) |
a7fd7b68 AE |
41 | #:use-module (gnu packages pkg-config) |
42 | #:use-module (gnu packages tls)) | |
51002318 | 43 | |
95264cc6 AW |
44 | ;; Delay to avoid module circularity problems. |
45 | (define ghostscript/cups | |
46 | (delay | |
47 | (package (inherit ghostscript) | |
48 | (name "ghostscript-with-cups") | |
49 | (inputs `(("cups" ,cups-minimal) | |
50 | ,@(package-inputs ghostscript)))))) | |
51 | ||
51002318 RW |
52 | (define-public cups-filters |
53 | (package | |
54 | (name "cups-filters") | |
8afabb2e | 55 | (replacement cups-filters/fixed) |
f8489f16 | 56 | (version "1.13.1") |
4ab016e0 | 57 | (source(origin |
51002318 RW |
58 | (method url-fetch) |
59 | (uri | |
60 | (string-append "http://openprinting.org/download/cups-filters/" | |
61 | "cups-filters-" version ".tar.xz")) | |
62 | (sha256 | |
63 | (base32 | |
f8489f16 | 64 | "0s7hylp2lcvc1vrqpywpv7lspkrh4xf7cyi4nbg10cf38rshj474")) |
51002318 RW |
65 | (modules '((guix build utils))) |
66 | (snippet | |
67 | ;; install backends, banners and filters to cups-filters output | |
68 | ;; directory, not the cups server directory | |
085cca5b AW |
69 | '(begin |
70 | (substitute* "Makefile.in" | |
71 | (("CUPS_DATADIR = @CUPS_DATADIR@") | |
72 | "CUPS_DATADIR = $(PREFIX)/share/cups") | |
73 | (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)") | |
74 | "pkgcupsserverrootdir = $(PREFIX)") | |
75 | ;; Choose standard directories notably so that binaries are | |
76 | ;; stripped. | |
77 | (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend") | |
78 | "pkgbackenddir = $(PREFIX)/lib/cups/backend") | |
79 | (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter") | |
80 | "pkgfilterdir = $(PREFIX)/lib/cups/filter")) | |
81 | ;; Find bannertopdf data such as the print test page in our | |
82 | ;; output directory, not CUPS's prefix. | |
83 | (substitute* "configure" | |
84 | (("\\{CUPS_DATADIR\\}/data") | |
85 | "{prefix}/share/cups/data")))))) | |
51002318 RW |
86 | (build-system gnu-build-system) |
87 | (arguments | |
88 | `(#:make-flags (list (string-append "PREFIX=" %output)) | |
89 | #:configure-flags | |
f8489f16 EF |
90 | `("--disable-driverless" ; TODO: enable this |
91 | ,(string-append "--with-test-font-path=" | |
51002318 RW |
92 | (assoc-ref %build-inputs "font-dejavu") |
93 | "/share/fonts/truetype/DejaVuSans.ttf") | |
95264cc6 AW |
94 | ,(string-append "--with-gs-path=" |
95 | (assoc-ref %build-inputs "ghostscript") | |
96 | "/bin/gsc") | |
f8489f16 EF |
97 | ,(string-append "--with-shell=" |
98 | (assoc-ref %build-inputs "bash") | |
99 | "/bin/bash") | |
51002318 RW |
100 | ,(string-append "--with-rcdir=" |
101 | (assoc-ref %outputs "out") "/etc/rc.d")))) | |
102 | (native-inputs | |
b76b1dcb AE |
103 | `(("glib" ,glib "bin") ; for gdbus-codegen |
104 | ("pkg-config" ,pkg-config))) | |
51002318 | 105 | (inputs |
7e214019 EF |
106 | `(("avahi" ,avahi) |
107 | ("fontconfig" ,fontconfig) | |
51002318 | 108 | ("freetype" ,freetype) |
f8489f16 | 109 | ("font-dejavu" ,font-dejavu) ; also needed by test suite |
95264cc6 | 110 | ("ghostscript" ,(force ghostscript/cups)) |
51002318 RW |
111 | ("ijs" ,ijs) |
112 | ("dbus" ,dbus) | |
113 | ("lcms" ,lcms) | |
f8489f16 | 114 | ("libjpeg" ,libjpeg) |
51002318 RW |
115 | ("libpng" ,libpng) |
116 | ("libtiff" ,libtiff) | |
46076d08 | 117 | ("mupdf" ,mupdf) |
51002318 RW |
118 | ("glib" ,glib) |
119 | ("qpdf" ,qpdf) | |
120 | ("poppler" ,poppler) | |
121 | ("cups-minimal" ,cups-minimal))) | |
6c474253 | 122 | (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters") |
51002318 RW |
123 | (synopsis "OpenPrinting CUPS filters and backends") |
124 | (description | |
125 | "Contains backends, filters, and other software that was once part of the | |
126 | core CUPS distribution but is no longer maintained by Apple Inc. In addition | |
127 | it contains additional filters developed independently of Apple, especially | |
128 | filters for the PDF-centric printing workflow introduced by OpenPrinting.") | |
129 | ;; Different filters and backends have different licenses; see COPYING for | |
130 | ;; details | |
131 | (license (list license:gpl2 | |
132 | license:gpl2+ | |
133 | license:gpl3 | |
134 | license:gpl3+ | |
135 | license:lgpl2.0+ | |
136 | license:expat)))) | |
137 | ||
8afabb2e LF |
138 | (define mupdf/fixed-instead-of-mupdf |
139 | (package-input-rewriting `((,mupdf . ,(@@ (gnu packages pdf) mupdf/fixed))))) | |
140 | ||
141 | ;;; Fix CVE-2016-10132 and CVE-2016-10133. See mupdf/fixed for more information. | |
142 | (define cups-filters/fixed | |
143 | (mupdf/fixed-instead-of-mupdf cups-filters)) | |
144 | ||
51002318 RW |
145 | ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also |
146 | ;; depends on CUPS libraries and binaries, cups-minimal has been added to | |
147 | ;; satisfy this dependency. | |
148 | (define-public cups-minimal | |
149 | (package | |
150 | (name "cups-minimal") | |
88dfd8b8 TGR |
151 | (version "2.2.1") |
152 | (source | |
153 | (origin | |
154 | (method url-fetch) | |
155 | (uri (string-append "https://github.com/apple/cups/releases/download/v" | |
156 | version "/cups-" version "-source.tar.gz")) | |
157 | (sha256 | |
158 | (base32 | |
159 | "1m8rwhbk0l8n19iwm51r2569jj15d0x6mpqhfig0bk3pm4577f43")))) | |
51002318 RW |
160 | (build-system gnu-build-system) |
161 | (arguments | |
162 | `(#:configure-flags | |
163 | '("--disable-launchd" | |
164 | "--disable-systemd" | |
165 | "--disable-avahi" | |
166 | "--disable-dnssd") | |
167 | ;; Seven tests fail, mostly because of files that are provided by the | |
168 | ;; cups-filters package. | |
169 | #:tests? #f | |
170 | #:phases | |
6ea06a0e LC |
171 | (modify-phases %standard-phases |
172 | (add-before 'configure 'patch-makedefs | |
173 | (lambda _ | |
174 | (substitute* "Makedefs.in" | |
175 | (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@") | |
176 | (("/bin/sh") (which "sh"))))) | |
177 | (add-before 'build 'patch-tests | |
178 | (lambda _ | |
179 | (substitute* "test/ippserver.c" | |
180 | (("# else /\\* HAVE_AVAHI \\*/") | |
181 | "#elif defined(HAVE_AVAHI)"))))))) | |
51002318 RW |
182 | (native-inputs |
183 | `(("pkg-config" ,pkg-config))) | |
184 | (inputs | |
185 | `(("zlib" ,zlib) | |
186 | ("gnutls" ,gnutls))) | |
d2a79db4 | 187 | (home-page "https://www.cups.org") |
51002318 RW |
188 | (synopsis "The Common Unix Printing System") |
189 | (description | |
190 | "CUPS is a printing system that uses the Internet Printing | |
191 | Protocol (IPP). It provides System V and BSD command-line interfaces, as well | |
192 | as a Web interface and a C programming interface to manage printers and print | |
193 | jobs. It supports printing to both local (parallel, serial, USB) and | |
194 | networked printers, and printers can be shared from one computer to another. | |
195 | Internally, CUPS uses PostScript Printer Description (PPD) files to describe | |
196 | printer capabilities and features and a wide variety of generic and | |
197 | device-specific programs to convert and print many types of files.") | |
198 | (license license:gpl2))) | |
199 | ||
200 | (define-public cups | |
201 | (package (inherit cups-minimal) | |
202 | (name "cups") | |
203 | (arguments | |
204 | `(;; Three tests fail: | |
205 | ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6: | |
206 | ;; Get-Jobs Operation" | |
207 | ;; * test of number of error/warning messages, probably related to a | |
208 | ;; missing font. | |
209 | #:tests? #f | |
210 | #:configure-flags | |
211 | '("--disable-launchd" | |
212 | "--disable-systemd") | |
213 | #:phases | |
3064d176 EF |
214 | (modify-phases %standard-phases |
215 | (add-before 'configure 'patch-makedefs | |
216 | (lambda _ | |
217 | (substitute* "Makedefs.in" | |
218 | (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@") | |
219 | (("/bin/sh") (which "sh"))))) | |
220 | (add-before 'check 'patch-tests | |
221 | (lambda _ | |
222 | (let ((filters (assoc-ref %build-inputs "cups-filters")) | |
223 | (catpath (string-append | |
224 | (assoc-ref %build-inputs "coreutils") "/bin/")) | |
225 | (testdir (string-append (getcwd) "/tmp/"))) | |
226 | (mkdir testdir) | |
227 | (substitute* "test/run-stp-tests.sh" | |
228 | ((" *BASE=/tmp/") (string-append "BASE=" testdir)) | |
51002318 | 229 | |
3064d176 EF |
230 | ;; allow installation of filters from output dir and from |
231 | ;; cups-filters | |
232 | (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter") | |
233 | (string-append | |
234 | "for dir in " | |
235 | (assoc-ref %outputs "out") "/lib/cups/filter " | |
236 | filters "/lib/cups/filter")) | |
51002318 | 237 | |
3064d176 EF |
238 | ;; check for charsets in cups-filters output |
239 | (("/usr/share/cups/charsets") | |
240 | (string-append filters "/share/cups/charsets")) | |
51002318 | 241 | |
3064d176 EF |
242 | ;; install additional required filters |
243 | (("instfilter texttopdf texttopdf pdf") | |
244 | (string-append | |
245 | "instfilter texttopdf texttopdf pdf;" | |
246 | "instfilter imagetoraster imagetoraster raster;" | |
247 | "instfilter gstoraster gstoraster raster;" | |
248 | "instfilter urftopdf urftopdf pdf;" | |
249 | "instfilter rastertopdf rastertopdf pdf;" | |
250 | "instfilter pstopdf pstopdf pdf")) | |
51002318 | 251 | |
3064d176 EF |
252 | ;; specify location of lpstat binary |
253 | (("description=\"`lpstat -l") | |
254 | "description=\"`../systemv/lpstat -l") | |
51002318 | 255 | |
3064d176 EF |
256 | ;; patch shebangs of embedded scripts |
257 | (("#!/bin/sh") (string-append "#!" (which "sh"))) | |
51002318 | 258 | |
3064d176 EF |
259 | ;; also link mime definitions from cups-filters |
260 | ;; to enable the additional filters for the test suite | |
261 | (("ln -s \\$root/conf/mime\\.types") | |
262 | (string-append | |
263 | "ln -s " filters | |
264 | "/share/cups/mime/cupsfilters.types $BASE/share/mime; " | |
265 | "ln -s $root/conf/mime.types")) | |
266 | (("ln -s \\$root/conf/mime\\.convs") | |
267 | (string-append | |
268 | "ln -s " filters | |
269 | "/share/cups/mime/cupsfilters.convs $BASE/share/mime; " | |
270 | "ln -s $root/conf/mime.convs"))) | |
51002318 | 271 | |
3064d176 EF |
272 | ;; fix search path for "cat" |
273 | (substitute* "cups/testfile.c" | |
274 | (("cupsFileFind\\(\"cat\", \"/bin\"") | |
275 | (string-append "cupsFileFind(\"cat\", \"" catpath "\"")) | |
276 | (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"") | |
277 | (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))))) | |
278 | (add-after 'install 'install-cups-filters-symlinks | |
279 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
280 | (let ((out (assoc-ref outputs "out")) | |
281 | (cups-filters (assoc-ref inputs "cups-filters"))) | |
282 | ;; charsets | |
283 | (symlink | |
284 | (string-append cups-filters "/share/cups/charsets") | |
285 | (string-append out "/share/charsets")) | |
51002318 | 286 | |
3064d176 EF |
287 | ;; mime types, driver file, ppds |
288 | (for-each | |
289 | (lambda (f) | |
290 | (symlink (string-append cups-filters f) | |
291 | (string-append out f))) | |
292 | '("/share/cups/mime/cupsfilters.types" | |
293 | "/share/cups/mime/cupsfilters.convs" | |
294 | "/share/cups/drv/cupsfilters.drv" | |
295 | "/share/ppd")) | |
51002318 | 296 | |
3064d176 EF |
297 | ;; filters |
298 | (for-each | |
299 | (lambda (f) | |
300 | (symlink f | |
301 | (string-append out "/lib/cups/filter" (basename f)))) | |
302 | (find-files (string-append cups-filters "/lib/cups/filter"))) | |
51002318 | 303 | |
3064d176 EF |
304 | ;; backends |
305 | (for-each | |
306 | (lambda (f) | |
307 | (symlink (string-append cups-filters f) | |
308 | (string-append out "/lib/cups/backend/" | |
309 | (basename f)))) | |
310 | '("/lib/cups/backend/parallel" | |
311 | "/lib/cups/backend/serial")) | |
51002318 | 312 | |
3064d176 EF |
313 | ;; banners |
314 | (let ((banners "/share/cups/banners")) | |
315 | (delete-file-recursively (string-append out banners)) | |
316 | (symlink (string-append cups-filters banners) | |
317 | (string-append out banners))) | |
51002318 | 318 | |
3064d176 EF |
319 | ;; assorted data |
320 | (let ((data "/share/cups/data")) | |
321 | (delete-file-recursively (string-append out data)) | |
322 | (symlink (string-append cups-filters data) | |
323 | (string-append out data))))))))) | |
51002318 RW |
324 | (inputs |
325 | `(("avahi" ,avahi) | |
326 | ("gnutls" ,gnutls) | |
327 | ("cups-filters" ,cups-filters) | |
328 | ("zlib" ,zlib))))) | |
2b56dc01 DM |
329 | |
330 | (define-public hplip | |
331 | (package | |
332 | (name "hplip") | |
dead1067 | 333 | (version "3.16.11") |
2b56dc01 DM |
334 | (source (origin |
335 | (method url-fetch) | |
de67e922 LF |
336 | (uri (string-append "mirror://sourceforge/hplip/hplip/" version |
337 | "/hplip-" version ".tar.gz")) | |
2b56dc01 DM |
338 | (sha256 |
339 | (base32 | |
dead1067 | 340 | "094vkyr0rjng72m13dgr824cdl7q20x23qjxzih4w7l9njn0rqpn")))) |
2b56dc01 DM |
341 | (build-system gnu-build-system) |
342 | (home-page "http://hplipopensource.com/") | |
343 | (synopsis "HP Printer Drivers") | |
344 | (description "Hewlett-Packard Printer Drivers and PPDs.") | |
345 | ||
346 | ;; The 'COPYING' file lists directories where each of these 3 licenses | |
347 | ;; applies. | |
348 | (license (list license:gpl2+ license:bsd-3 license:expat)) | |
349 | ||
350 | ;; TODO install apparmor profile files eventually. | |
351 | (arguments | |
352 | `(#:configure-flags | |
353 | `("--disable-network-build" | |
354 | ,(string-append "--prefix=" (assoc-ref %outputs "out")) | |
355 | ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc") | |
356 | ;; Disable until mime.types merging works (FIXME). | |
357 | "--disable-fax-build" | |
358 | "--enable-hpcups-install" | |
359 | "--enable-new-hpcups" | |
360 | "--enable-cups_ppd_install" | |
361 | "--enable-cups_drv_install" | |
362 | ;; TODO add foomatic drv install eventually. | |
363 | ;; TODO --enable-policykit eventually. | |
364 | ,(string-append "--with-cupsfilterdir=" | |
365 | (assoc-ref %outputs "out") "/lib/cups/filter") | |
366 | ,(string-append "--with-cupsbackenddir=" | |
367 | (assoc-ref %outputs "out") "/lib/cups/backend") | |
368 | ,(string-append "--with-icondir=" | |
369 | (assoc-ref %outputs "out") "/share/applications") | |
370 | ,(string-append "--with-systraydir=" | |
371 | (assoc-ref %outputs "out") "/etc/xdg")) | |
372 | ||
373 | #:imported-modules ((guix build python-build-system) | |
374 | ,@%gnu-build-system-modules) | |
375 | #:modules ((guix build gnu-build-system) | |
376 | (guix build utils) | |
377 | ((guix build python-build-system) #:prefix python:)) | |
378 | ||
379 | #:phases (modify-phases %standard-phases | |
380 | (add-after 'unpack 'fix-hard-coded-file-names | |
381 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
382 | (let ((out (assoc-ref outputs "out")) | |
383 | ;; FIXME: use merged ppds (I think actually only | |
384 | ;; drvs need to be merged). | |
385 | (cupsdir (assoc-ref inputs "cups-minimal"))) | |
386 | (substitute* "base/g.py" | |
387 | (("'/usr/share;[^']*'") | |
388 | (string-append "'" cupsdir "/share'")) | |
389 | (("'/etc/hp/hplip.conf'") | |
390 | (string-append "'" out | |
391 | "/etc/hp/hplip.conf" "'"))) | |
392 | ||
393 | (substitute* "Makefile.in" | |
394 | (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ") | |
395 | ;; FIXME Use beginning-of-word in regexp. | |
396 | (("[[:blank:]]plugin\\.py[[:blank:]]") " ") | |
397 | (("/usr/include/libusb-1.0") | |
398 | (string-append (assoc-ref inputs "libusb") | |
399 | "/include/libusb-1.0")) | |
400 | (("^\tinstall-dist_hplip_stateDATA") | |
401 | ;; Remove dependencies on | |
402 | ;; 'install-dist_hplip_stateDATA' so we don't bail | |
403 | ;; out while trying to create /var/lib/hplip. | |
404 | "\t") | |
405 | (("hplip_confdir = /etc/hp") | |
406 | ;; This is only used for installing the default config. | |
407 | (string-append "hplip_confdir = " out | |
408 | "/etc/hp")) | |
409 | (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor") | |
410 | ;; Note: We don't use hal. | |
411 | (string-append "halpredir = " out | |
412 | "/share/hal/fdi/preprobe/10osvendor")) | |
413 | (("rulesdir = /etc/udev/rules.d") | |
414 | ;; udev rules will be merged by base service. | |
415 | (string-append "rulesdir = " out | |
416 | "/lib/udev/rules.d")) | |
417 | (("rulessystemdir = /usr/lib/systemd/system") | |
418 | ;; We don't use systemd. | |
419 | (string-append "rulessystemdir = " out | |
420 | "/lib/systemd/system")) | |
421 | (("/etc/sane.d") | |
422 | (string-append out "/etc/sane.d")))))) | |
423 | ||
424 | ;; Wrap bin/* so that the Python libs are found. | |
425 | (add-after 'install 'wrap-binaries | |
426 | (assoc-ref python:%standard-phases 'wrap))))) | |
427 | ||
428 | ;; Python3 support is available starting from hplip@3.15.2. | |
429 | (inputs `(("libjpeg" ,libjpeg) | |
430 | ("cups-minimal" ,cups-minimal) | |
431 | ("libusb" ,libusb) | |
32aa37a2 | 432 | ("sane-backends" ,sane-backends-minimal) |
2b56dc01 DM |
433 | ("dbus" ,dbus) |
434 | ("python-wrapper" ,python-wrapper) | |
435 | ("python" ,python) | |
436 | ;; TODO: Make hp-setup find python-dbus. | |
437 | ("python-dbus" ,python-dbus))) | |
438 | (native-inputs `(("pkg-config" ,pkg-config))))) |