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