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