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