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") | |
45fe9736 | 49 | (replacement #f) |
95264cc6 AW |
50 | (inputs `(("cups" ,cups-minimal) |
51 | ,@(package-inputs ghostscript)))))) | |
52 | ||
51002318 RW |
53 | (define-public cups-filters |
54 | (package | |
55 | (name "cups-filters") | |
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 | 90 | `("--disable-driverless" ; TODO: enable this |
79e90f05 | 91 | "--disable-mutool" ; depends on yet another PDF library (mupdf) |
f8489f16 | 92 | ,(string-append "--with-test-font-path=" |
51002318 RW |
93 | (assoc-ref %build-inputs "font-dejavu") |
94 | "/share/fonts/truetype/DejaVuSans.ttf") | |
95264cc6 AW |
95 | ,(string-append "--with-gs-path=" |
96 | (assoc-ref %build-inputs "ghostscript") | |
97 | "/bin/gsc") | |
f8489f16 EF |
98 | ,(string-append "--with-shell=" |
99 | (assoc-ref %build-inputs "bash") | |
100 | "/bin/bash") | |
51002318 RW |
101 | ,(string-append "--with-rcdir=" |
102 | (assoc-ref %outputs "out") "/etc/rc.d")))) | |
103 | (native-inputs | |
b76b1dcb AE |
104 | `(("glib" ,glib "bin") ; for gdbus-codegen |
105 | ("pkg-config" ,pkg-config))) | |
51002318 | 106 | (inputs |
7e214019 EF |
107 | `(("avahi" ,avahi) |
108 | ("fontconfig" ,fontconfig) | |
51002318 | 109 | ("freetype" ,freetype) |
f8489f16 | 110 | ("font-dejavu" ,font-dejavu) ; also needed by test suite |
95264cc6 | 111 | ("ghostscript" ,(force ghostscript/cups)) |
51002318 RW |
112 | ("ijs" ,ijs) |
113 | ("dbus" ,dbus) | |
114 | ("lcms" ,lcms) | |
f8489f16 | 115 | ("libjpeg" ,libjpeg) |
51002318 RW |
116 | ("libpng" ,libpng) |
117 | ("libtiff" ,libtiff) | |
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 | ||
138 | ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also | |
139 | ;; depends on CUPS libraries and binaries, cups-minimal has been added to | |
140 | ;; satisfy this dependency. | |
141 | (define-public cups-minimal | |
142 | (package | |
143 | (name "cups-minimal") | |
88dfd8b8 TGR |
144 | (version "2.2.1") |
145 | (source | |
146 | (origin | |
147 | (method url-fetch) | |
148 | (uri (string-append "https://github.com/apple/cups/releases/download/v" | |
149 | version "/cups-" version "-source.tar.gz")) | |
150 | (sha256 | |
151 | (base32 | |
152 | "1m8rwhbk0l8n19iwm51r2569jj15d0x6mpqhfig0bk3pm4577f43")))) | |
51002318 RW |
153 | (build-system gnu-build-system) |
154 | (arguments | |
155 | `(#:configure-flags | |
156 | '("--disable-launchd" | |
157 | "--disable-systemd" | |
158 | "--disable-avahi" | |
159 | "--disable-dnssd") | |
160 | ;; Seven tests fail, mostly because of files that are provided by the | |
161 | ;; cups-filters package. | |
162 | #:tests? #f | |
163 | #:phases | |
6ea06a0e LC |
164 | (modify-phases %standard-phases |
165 | (add-before 'configure 'patch-makedefs | |
166 | (lambda _ | |
167 | (substitute* "Makedefs.in" | |
168 | (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@") | |
169 | (("/bin/sh") (which "sh"))))) | |
d043ceed LF |
170 | ;; Make the compressed manpages writable so that the |
171 | ;; reset-gzip-timestamps phase does not error out. | |
172 | (add-before 'reset-gzip-timestamps 'make-manpages-writable | |
173 | (lambda* (#:key outputs #:allow-other-keys) | |
174 | (let* ((out (assoc-ref outputs "out")) | |
175 | (man (string-append out "/share/man"))) | |
176 | (for-each (lambda (file) (chmod file #o644)) | |
177 | (find-files man "\\.gz"))))) | |
6ea06a0e LC |
178 | (add-before 'build 'patch-tests |
179 | (lambda _ | |
180 | (substitute* "test/ippserver.c" | |
181 | (("# else /\\* HAVE_AVAHI \\*/") | |
182 | "#elif defined(HAVE_AVAHI)"))))))) | |
51002318 RW |
183 | (native-inputs |
184 | `(("pkg-config" ,pkg-config))) | |
185 | (inputs | |
186 | `(("zlib" ,zlib) | |
187 | ("gnutls" ,gnutls))) | |
d2a79db4 | 188 | (home-page "https://www.cups.org") |
51002318 RW |
189 | (synopsis "The Common Unix Printing System") |
190 | (description | |
191 | "CUPS is a printing system that uses the Internet Printing | |
192 | Protocol (IPP). It provides System V and BSD command-line interfaces, as well | |
193 | as a Web interface and a C programming interface to manage printers and print | |
194 | jobs. It supports printing to both local (parallel, serial, USB) and | |
195 | networked printers, and printers can be shared from one computer to another. | |
196 | Internally, CUPS uses PostScript Printer Description (PPD) files to describe | |
197 | printer capabilities and features and a wide variety of generic and | |
198 | device-specific programs to convert and print many types of files.") | |
199 | (license license:gpl2))) | |
200 | ||
201 | (define-public cups | |
202 | (package (inherit cups-minimal) | |
203 | (name "cups") | |
204 | (arguments | |
205 | `(;; Three tests fail: | |
206 | ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6: | |
207 | ;; Get-Jobs Operation" | |
208 | ;; * test of number of error/warning messages, probably related to a | |
209 | ;; missing font. | |
210 | #:tests? #f | |
211 | #:configure-flags | |
212 | '("--disable-launchd" | |
213 | "--disable-systemd") | |
214 | #:phases | |
3064d176 EF |
215 | (modify-phases %standard-phases |
216 | (add-before 'configure 'patch-makedefs | |
217 | (lambda _ | |
218 | (substitute* "Makedefs.in" | |
219 | (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@") | |
220 | (("/bin/sh") (which "sh"))))) | |
221 | (add-before 'check 'patch-tests | |
222 | (lambda _ | |
223 | (let ((filters (assoc-ref %build-inputs "cups-filters")) | |
224 | (catpath (string-append | |
225 | (assoc-ref %build-inputs "coreutils") "/bin/")) | |
226 | (testdir (string-append (getcwd) "/tmp/"))) | |
227 | (mkdir testdir) | |
228 | (substitute* "test/run-stp-tests.sh" | |
229 | ((" *BASE=/tmp/") (string-append "BASE=" testdir)) | |
51002318 | 230 | |
3064d176 EF |
231 | ;; allow installation of filters from output dir and from |
232 | ;; cups-filters | |
233 | (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter") | |
234 | (string-append | |
235 | "for dir in " | |
236 | (assoc-ref %outputs "out") "/lib/cups/filter " | |
237 | filters "/lib/cups/filter")) | |
51002318 | 238 | |
3064d176 EF |
239 | ;; check for charsets in cups-filters output |
240 | (("/usr/share/cups/charsets") | |
241 | (string-append filters "/share/cups/charsets")) | |
51002318 | 242 | |
3064d176 EF |
243 | ;; install additional required filters |
244 | (("instfilter texttopdf texttopdf pdf") | |
245 | (string-append | |
246 | "instfilter texttopdf texttopdf pdf;" | |
247 | "instfilter imagetoraster imagetoraster raster;" | |
248 | "instfilter gstoraster gstoraster raster;" | |
249 | "instfilter urftopdf urftopdf pdf;" | |
250 | "instfilter rastertopdf rastertopdf pdf;" | |
251 | "instfilter pstopdf pstopdf pdf")) | |
51002318 | 252 | |
3064d176 EF |
253 | ;; specify location of lpstat binary |
254 | (("description=\"`lpstat -l") | |
255 | "description=\"`../systemv/lpstat -l") | |
51002318 | 256 | |
3064d176 EF |
257 | ;; patch shebangs of embedded scripts |
258 | (("#!/bin/sh") (string-append "#!" (which "sh"))) | |
51002318 | 259 | |
3064d176 EF |
260 | ;; also link mime definitions from cups-filters |
261 | ;; to enable the additional filters for the test suite | |
262 | (("ln -s \\$root/conf/mime\\.types") | |
263 | (string-append | |
264 | "ln -s " filters | |
265 | "/share/cups/mime/cupsfilters.types $BASE/share/mime; " | |
266 | "ln -s $root/conf/mime.types")) | |
267 | (("ln -s \\$root/conf/mime\\.convs") | |
268 | (string-append | |
269 | "ln -s " filters | |
270 | "/share/cups/mime/cupsfilters.convs $BASE/share/mime; " | |
271 | "ln -s $root/conf/mime.convs"))) | |
51002318 | 272 | |
3064d176 EF |
273 | ;; fix search path for "cat" |
274 | (substitute* "cups/testfile.c" | |
275 | (("cupsFileFind\\(\"cat\", \"/bin\"") | |
276 | (string-append "cupsFileFind(\"cat\", \"" catpath "\"")) | |
277 | (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"") | |
278 | (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))))) | |
29796b3f LF |
279 | ;; Make the compressed manpages writable so that the |
280 | ;; reset-gzip-timestamps phase does not error out. | |
281 | (add-before 'reset-gzip-timestamps 'make-manpages-writable | |
282 | (lambda* (#:key outputs #:allow-other-keys) | |
283 | (let* ((out (assoc-ref outputs "out")) | |
284 | (man (string-append out "/share/man"))) | |
285 | (for-each (lambda (file) (chmod file #o644)) | |
286 | (find-files man "\\.gz"))))) | |
3064d176 EF |
287 | (add-after 'install 'install-cups-filters-symlinks |
288 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
289 | (let ((out (assoc-ref outputs "out")) | |
290 | (cups-filters (assoc-ref inputs "cups-filters"))) | |
291 | ;; charsets | |
292 | (symlink | |
293 | (string-append cups-filters "/share/cups/charsets") | |
294 | (string-append out "/share/charsets")) | |
51002318 | 295 | |
3064d176 EF |
296 | ;; mime types, driver file, ppds |
297 | (for-each | |
298 | (lambda (f) | |
299 | (symlink (string-append cups-filters f) | |
300 | (string-append out f))) | |
301 | '("/share/cups/mime/cupsfilters.types" | |
302 | "/share/cups/mime/cupsfilters.convs" | |
303 | "/share/cups/drv/cupsfilters.drv" | |
304 | "/share/ppd")) | |
51002318 | 305 | |
3064d176 EF |
306 | ;; filters |
307 | (for-each | |
308 | (lambda (f) | |
309 | (symlink f | |
310 | (string-append out "/lib/cups/filter" (basename f)))) | |
311 | (find-files (string-append cups-filters "/lib/cups/filter"))) | |
51002318 | 312 | |
3064d176 EF |
313 | ;; backends |
314 | (for-each | |
315 | (lambda (f) | |
316 | (symlink (string-append cups-filters f) | |
317 | (string-append out "/lib/cups/backend/" | |
318 | (basename f)))) | |
319 | '("/lib/cups/backend/parallel" | |
320 | "/lib/cups/backend/serial")) | |
51002318 | 321 | |
3064d176 EF |
322 | ;; banners |
323 | (let ((banners "/share/cups/banners")) | |
324 | (delete-file-recursively (string-append out banners)) | |
325 | (symlink (string-append cups-filters banners) | |
326 | (string-append out banners))) | |
51002318 | 327 | |
3064d176 EF |
328 | ;; assorted data |
329 | (let ((data "/share/cups/data")) | |
330 | (delete-file-recursively (string-append out data)) | |
331 | (symlink (string-append cups-filters data) | |
332 | (string-append out data))))))))) | |
51002318 RW |
333 | (inputs |
334 | `(("avahi" ,avahi) | |
335 | ("gnutls" ,gnutls) | |
336 | ("cups-filters" ,cups-filters) | |
337 | ("zlib" ,zlib))))) | |
2b56dc01 DM |
338 | |
339 | (define-public hplip | |
340 | (package | |
341 | (name "hplip") | |
dead1067 | 342 | (version "3.16.11") |
2b56dc01 DM |
343 | (source (origin |
344 | (method url-fetch) | |
de67e922 LF |
345 | (uri (string-append "mirror://sourceforge/hplip/hplip/" version |
346 | "/hplip-" version ".tar.gz")) | |
2b56dc01 DM |
347 | (sha256 |
348 | (base32 | |
dead1067 | 349 | "094vkyr0rjng72m13dgr824cdl7q20x23qjxzih4w7l9njn0rqpn")))) |
2b56dc01 DM |
350 | (build-system gnu-build-system) |
351 | (home-page "http://hplipopensource.com/") | |
352 | (synopsis "HP Printer Drivers") | |
353 | (description "Hewlett-Packard Printer Drivers and PPDs.") | |
354 | ||
355 | ;; The 'COPYING' file lists directories where each of these 3 licenses | |
356 | ;; applies. | |
357 | (license (list license:gpl2+ license:bsd-3 license:expat)) | |
358 | ||
359 | ;; TODO install apparmor profile files eventually. | |
360 | (arguments | |
361 | `(#:configure-flags | |
362 | `("--disable-network-build" | |
363 | ,(string-append "--prefix=" (assoc-ref %outputs "out")) | |
364 | ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc") | |
365 | ;; Disable until mime.types merging works (FIXME). | |
366 | "--disable-fax-build" | |
367 | "--enable-hpcups-install" | |
368 | "--enable-new-hpcups" | |
369 | "--enable-cups_ppd_install" | |
370 | "--enable-cups_drv_install" | |
371 | ;; TODO add foomatic drv install eventually. | |
372 | ;; TODO --enable-policykit eventually. | |
373 | ,(string-append "--with-cupsfilterdir=" | |
374 | (assoc-ref %outputs "out") "/lib/cups/filter") | |
375 | ,(string-append "--with-cupsbackenddir=" | |
376 | (assoc-ref %outputs "out") "/lib/cups/backend") | |
377 | ,(string-append "--with-icondir=" | |
378 | (assoc-ref %outputs "out") "/share/applications") | |
379 | ,(string-append "--with-systraydir=" | |
380 | (assoc-ref %outputs "out") "/etc/xdg")) | |
381 | ||
382 | #:imported-modules ((guix build python-build-system) | |
383 | ,@%gnu-build-system-modules) | |
384 | #:modules ((guix build gnu-build-system) | |
385 | (guix build utils) | |
386 | ((guix build python-build-system) #:prefix python:)) | |
387 | ||
388 | #:phases (modify-phases %standard-phases | |
389 | (add-after 'unpack 'fix-hard-coded-file-names | |
390 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
391 | (let ((out (assoc-ref outputs "out")) | |
392 | ;; FIXME: use merged ppds (I think actually only | |
393 | ;; drvs need to be merged). | |
394 | (cupsdir (assoc-ref inputs "cups-minimal"))) | |
395 | (substitute* "base/g.py" | |
396 | (("'/usr/share;[^']*'") | |
397 | (string-append "'" cupsdir "/share'")) | |
398 | (("'/etc/hp/hplip.conf'") | |
399 | (string-append "'" out | |
400 | "/etc/hp/hplip.conf" "'"))) | |
401 | ||
402 | (substitute* "Makefile.in" | |
403 | (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ") | |
404 | ;; FIXME Use beginning-of-word in regexp. | |
405 | (("[[:blank:]]plugin\\.py[[:blank:]]") " ") | |
406 | (("/usr/include/libusb-1.0") | |
407 | (string-append (assoc-ref inputs "libusb") | |
408 | "/include/libusb-1.0")) | |
409 | (("^\tinstall-dist_hplip_stateDATA") | |
410 | ;; Remove dependencies on | |
411 | ;; 'install-dist_hplip_stateDATA' so we don't bail | |
412 | ;; out while trying to create /var/lib/hplip. | |
413 | "\t") | |
414 | (("hplip_confdir = /etc/hp") | |
415 | ;; This is only used for installing the default config. | |
416 | (string-append "hplip_confdir = " out | |
417 | "/etc/hp")) | |
418 | (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor") | |
419 | ;; Note: We don't use hal. | |
420 | (string-append "halpredir = " out | |
421 | "/share/hal/fdi/preprobe/10osvendor")) | |
422 | (("rulesdir = /etc/udev/rules.d") | |
423 | ;; udev rules will be merged by base service. | |
424 | (string-append "rulesdir = " out | |
425 | "/lib/udev/rules.d")) | |
426 | (("rulessystemdir = /usr/lib/systemd/system") | |
427 | ;; We don't use systemd. | |
428 | (string-append "rulessystemdir = " out | |
429 | "/lib/systemd/system")) | |
430 | (("/etc/sane.d") | |
431 | (string-append out "/etc/sane.d")))))) | |
432 | ||
433 | ;; Wrap bin/* so that the Python libs are found. | |
434 | (add-after 'install 'wrap-binaries | |
435 | (assoc-ref python:%standard-phases 'wrap))))) | |
436 | ||
437 | ;; Python3 support is available starting from hplip@3.15.2. | |
438 | (inputs `(("libjpeg" ,libjpeg) | |
439 | ("cups-minimal" ,cups-minimal) | |
440 | ("libusb" ,libusb) | |
32aa37a2 | 441 | ("sane-backends" ,sane-backends-minimal) |
2b56dc01 DM |
442 | ("dbus" ,dbus) |
443 | ("python-wrapper" ,python-wrapper) | |
444 | ("python" ,python) | |
445 | ;; TODO: Make hp-setup find python-dbus. | |
446 | ("python-dbus" ,python-dbus))) | |
447 | (native-inputs `(("pkg-config" ,pkg-config))))) |