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