linux-initrd: Add USB kernel modules to the default initrd.
[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 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages cups)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages avahi)
26 #:use-module (gnu packages compression)
27 #:use-module (gnu packages image)
28 #:use-module (gnu packages fonts) ;font-dejavu
29 #:use-module (gnu packages fontutils)
30 #:use-module (gnu packages ghostscript)
31 #:use-module (gnu packages glib)
32 #:use-module (gnu packages gnutls)
33 #:use-module (gnu packages pdf)
34 #:use-module (gnu packages pkg-config))
35
36 (define-public cups-filters
37 (package
38 (name "cups-filters")
39 (version "1.0.61")
40 (source (origin
41 (method url-fetch)
42 (uri
43 (string-append "http://openprinting.org/download/cups-filters/"
44 "cups-filters-" version ".tar.xz"))
45 (sha256
46 (base32
47 "1bq48nnrarlbf6qc93bz1n5wlh6j420gppbck3r45sinwhz5wa7m"))
48 (modules '((guix build utils)))
49 (snippet
50 ;; install backends, banners and filters to cups-filters output
51 ;; directory, not the cups server directory
52 '(substitute* "Makefile.in"
53 (("CUPS_DATADIR = @CUPS_DATADIR@")
54 "CUPS_DATADIR = $(PREFIX)/share/cups")
55 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
56 "pkgcupsserverrootdir = $(PREFIX)")
57 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
58 "pkgbackenddir = $(PREFIX)/backend")
59 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
60 "pkgfilterdir = $(PREFIX)/filter")))))
61 (build-system gnu-build-system)
62 (arguments
63 `(#:make-flags (list (string-append "PREFIX=" %output))
64 #:configure-flags
65 `(,(string-append "--with-test-font-path="
66 (assoc-ref %build-inputs "font-dejavu")
67 "/share/fonts/truetype/DejaVuSans.ttf")
68 ,(string-append "--with-rcdir="
69 (assoc-ref %outputs "out") "/etc/rc.d"))))
70 (native-inputs
71 `(("pkg-config" ,pkg-config)))
72 (inputs
73 `(("fontconfig" ,fontconfig)
74 ("freetype" ,freetype)
75 ("font-dejavu" ,font-dejavu) ;needed by test suite
76 ("ghostscript" ,ghostscript)
77 ("ijs" ,ijs)
78 ("dbus" ,dbus)
79 ("lcms" ,lcms)
80 ("libjpeg-8" ,libjpeg-8)
81 ("libpng" ,libpng)
82 ("libtiff" ,libtiff)
83 ("glib" ,glib)
84 ("qpdf" ,qpdf)
85 ("poppler" ,poppler)
86 ("cups-minimal" ,cups-minimal)))
87 (home-page "http://www.linuxfoundation.org/collaborate/workgroups/openprinting/cups-filters")
88 (synopsis "OpenPrinting CUPS filters and backends")
89 (description
90 "Contains backends, filters, and other software that was once part of the
91 core CUPS distribution but is no longer maintained by Apple Inc. In addition
92 it contains additional filters developed independently of Apple, especially
93 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
94 ;; Different filters and backends have different licenses; see COPYING for
95 ;; details
96 (license (list license:gpl2
97 license:gpl2+
98 license:gpl3
99 license:gpl3+
100 license:lgpl2.0+
101 license:expat))))
102
103 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
104 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
105 ;; satisfy this dependency.
106 (define-public cups-minimal
107 (package
108 (name "cups-minimal")
109 (version "2.0.1")
110 (source (origin
111 (method url-fetch)
112 (uri (string-append "http://www.cups.org/software/"
113 version "/cups-" version "-source.tar.gz"))
114 (sha256
115 (base32
116 "1kbc85kwhm1vyzahblrg3qih9yypggs91d13gdrbnaac8q7jd9jr"))))
117 (build-system gnu-build-system)
118 (arguments
119 `(#:configure-flags
120 '("--disable-launchd"
121 "--disable-systemd"
122 "--disable-avahi"
123 "--disable-dnssd")
124 ;; Seven tests fail, mostly because of files that are provided by the
125 ;; cups-filters package.
126 #:tests? #f
127 #:phases
128 (alist-cons-before
129 'configure
130 'patch-makedefs
131 (lambda _
132 (substitute* "Makedefs.in"
133 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
134 (("/bin/sh") (which "sh"))))
135 (alist-cons-before
136 'build
137 'patch-tests
138 (lambda _
139 (substitute* "test/ippserver.c"
140 (("# else /\\* HAVE_AVAHI \\*/") "#elif defined(HAVE_AVAHI)")))
141 %standard-phases))))
142 (native-inputs
143 `(("pkg-config" ,pkg-config)))
144 (inputs
145 `(("zlib" ,zlib)
146 ("gnutls" ,gnutls)))
147 (home-page "http://www.cups.org")
148 (synopsis "The Common Unix Printing System")
149 (description
150 "CUPS is a printing system that uses the Internet Printing
151 Protocol (IPP). It provides System V and BSD command-line interfaces, as well
152 as a Web interface and a C programming interface to manage printers and print
153 jobs. It supports printing to both local (parallel, serial, USB) and
154 networked printers, and printers can be shared from one computer to another.
155 Internally, CUPS uses PostScript Printer Description (PPD) files to describe
156 printer capabilities and features and a wide variety of generic and
157 device-specific programs to convert and print many types of files.")
158 (license license:gpl2)))
159
160 (define-public cups
161 (package (inherit cups-minimal)
162 (name "cups")
163 (arguments
164 `(;; Three tests fail:
165 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
166 ;; Get-Jobs Operation"
167 ;; * test of number of error/warning messages, probably related to a
168 ;; missing font.
169 #:tests? #f
170 #:configure-flags
171 '("--disable-launchd"
172 "--disable-systemd")
173 #:phases
174 (alist-cons-before
175 'configure
176 'patch-makedefs
177 (lambda _
178 (substitute* "Makedefs.in"
179 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
180 (("/bin/sh") (which "sh"))))
181 (alist-cons-before
182 'check
183 'patch-tests
184 (lambda _
185 (let ((filters (assoc-ref %build-inputs "cups-filters"))
186 (catpath (string-append
187 (assoc-ref %build-inputs "coreutils") "/bin/"))
188 (testdir (string-append (getcwd) "/tmp/")))
189 (mkdir testdir)
190 (substitute* "test/run-stp-tests.sh"
191 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
192
193 ;; allow installation of filters from output dir and from
194 ;; cups-filters
195 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
196 (string-append
197 "for dir in "
198 (assoc-ref %outputs "out") "/lib/cups/filter "
199 filters "/filter"))
200
201 ;; check for charsets in cups-filters output
202 (("/usr/share/cups/charsets")
203 (string-append filters "/share/cups/charsets"))
204
205 ;; install additional required filters
206 (("instfilter texttopdf texttopdf pdf")
207 (string-append
208 "instfilter texttopdf texttopdf pdf;"
209 "instfilter imagetoraster imagetoraster raster;"
210 "instfilter gstoraster gstoraster raster;"
211 "instfilter urftopdf urftopdf pdf;"
212 "instfilter rastertopdf rastertopdf pdf;"
213 "instfilter pstopdf pstopdf pdf"))
214
215 ;; specify location of lpstat binary
216 (("description=\"`lpstat -l")
217 "description=\"`../systemv/lpstat -l")
218
219 ;; patch shebangs of embedded scripts
220 (("#!/bin/sh") (string-append "#!" (which "sh")))
221
222 ;; also link mime definitions from cups-filters
223 ;; to enable the additional filters for the test suite
224 (("ln -s \\$root/conf/mime\\.types")
225 (string-append
226 "ln -s " filters
227 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
228 "ln -s $root/conf/mime.types"))
229 (("ln -s \\$root/conf/mime\\.convs")
230 (string-append
231 "ln -s " filters
232 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
233 "ln -s $root/conf/mime.convs")))
234
235 ;; fix search path for "cat"
236 (substitute* "cups/testfile.c"
237 (("cupsFileFind\\(\"cat\", \"/bin\"")
238 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
239 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
240 (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))))
241 (alist-cons-after
242 'install
243 'install-cups-filters-symlinks
244 (lambda* (#:key inputs outputs #:allow-other-keys)
245 (let ((out (assoc-ref outputs "out"))
246 (cups-filters (assoc-ref inputs "cups-filters")))
247 ;; charsets
248 (symlink
249 (string-append cups-filters "/share/cups/charsets")
250 (string-append out "/share/charsets"))
251
252 ;; mime types, driver file, ppds
253 (for-each
254 (lambda (f)
255 (symlink (string-append cups-filters f)
256 (string-append out f)))
257 '("/share/cups/mime/cupsfilters.types"
258 "/share/cups/mime/cupsfilters.convs"
259 "/share/cups/drv/cupsfilters.drv"
260 "/share/ppd"))
261
262 ;; filters
263 (for-each
264 (lambda (f)
265 (symlink f
266 (string-append out "/lib/cups/filter" (basename f))))
267 (find-files (string-append cups-filters "/filter") ".*"))
268
269 ;; backends
270 (for-each
271 (lambda (f)
272 (symlink (string-append cups-filters f)
273 (string-append out "/lib/cups" f)))
274 '("/backend/parallel"
275 "/backend/serial"))
276
277 ;; banners
278 (let ((banners "/share/cups/banners"))
279 (delete-file-recursively (string-append out banners))
280 (symlink (string-append cups-filters banners)
281 (string-append out banners)))
282
283 ;; assorted data
284 (let ((data "/share/cups/data"))
285 (delete-file-recursively (string-append out data))
286 (symlink (string-append cups-filters data)
287 (string-append out data)))))
288 %standard-phases)))))
289 (inputs
290 `(("avahi" ,avahi)
291 ("gnutls" ,gnutls)
292 ("cups-filters" ,cups-filters)
293 ("zlib" ,zlib)))))