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