gnu: Update URLs for sourceforge.net.
[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>
4d6b8da7 4;;; Copyright © 2015 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
RW
42
43(define-public cups-filters
44 (package
45 (name "cups-filters")
4d6b8da7 46 (version "1.4.0")
51002318
RW
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
4d6b8da7 54 "16jpqqlixlv2dxqv8gak5qg4qnsnw4p745xr6rhw9dgylf13z9ha"))
51002318
RW
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)")
ef2f51a4
LC
64 ;; Choose standard directories notably so that binaries are
65 ;; stripped.
51002318 66 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
ef2f51a4 67 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
51002318 68 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
ef2f51a4 69 "pkgfilterdir = $(PREFIX)/lib/cups/filter")))))
51002318
RW
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
b76b1dcb
AE
80 `(("glib" ,glib "bin") ; for gdbus-codegen
81 ("pkg-config" ,pkg-config)))
51002318
RW
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
101core CUPS distribution but is no longer maintained by Apple Inc. In addition
102it contains additional filters developed independently of Apple, especially
103filters 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")
e5fe08e4 119 (version "2.1.0")
51002318
RW
120 (source (origin
121 (method url-fetch)
122 (uri (string-append "http://www.cups.org/software/"
e5fe08e4 123 version "/cups-" version "-source.tar.bz2"))
51002318
RW
124 (sha256
125 (base32
e5fe08e4 126 "1jfjqsw9l7jbn5kb9i96k0wj12kjdbgx0rd8157dif22hi0kh0ms"))))
51002318
RW
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 (alist-cons-before
139 'configure
140 'patch-makedefs
141 (lambda _
142 (substitute* "Makedefs.in"
143 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
144 (("/bin/sh") (which "sh"))))
145 (alist-cons-before
146 'build
147 'patch-tests
148 (lambda _
149 (substitute* "test/ippserver.c"
150 (("# else /\\* HAVE_AVAHI \\*/") "#elif defined(HAVE_AVAHI)")))
151 %standard-phases))))
152 (native-inputs
153 `(("pkg-config" ,pkg-config)))
154 (inputs
155 `(("zlib" ,zlib)
156 ("gnutls" ,gnutls)))
157 (home-page "http://www.cups.org")
158 (synopsis "The Common Unix Printing System")
159 (description
160 "CUPS is a printing system that uses the Internet Printing
161Protocol (IPP). It provides System V and BSD command-line interfaces, as well
162as a Web interface and a C programming interface to manage printers and print
163jobs. It supports printing to both local (parallel, serial, USB) and
164networked printers, and printers can be shared from one computer to another.
165Internally, CUPS uses PostScript Printer Description (PPD) files to describe
166printer capabilities and features and a wide variety of generic and
167device-specific programs to convert and print many types of files.")
168 (license license:gpl2)))
169
170(define-public cups
171 (package (inherit cups-minimal)
172 (name "cups")
173 (arguments
174 `(;; Three tests fail:
175 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
176 ;; Get-Jobs Operation"
177 ;; * test of number of error/warning messages, probably related to a
178 ;; missing font.
179 #:tests? #f
180 #:configure-flags
181 '("--disable-launchd"
182 "--disable-systemd")
183 #:phases
184 (alist-cons-before
185 'configure
186 'patch-makedefs
187 (lambda _
188 (substitute* "Makedefs.in"
189 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
190 (("/bin/sh") (which "sh"))))
191 (alist-cons-before
192 'check
193 'patch-tests
194 (lambda _
195 (let ((filters (assoc-ref %build-inputs "cups-filters"))
196 (catpath (string-append
197 (assoc-ref %build-inputs "coreutils") "/bin/"))
198 (testdir (string-append (getcwd) "/tmp/")))
199 (mkdir testdir)
200 (substitute* "test/run-stp-tests.sh"
201 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
202
203 ;; allow installation of filters from output dir and from
204 ;; cups-filters
205 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
206 (string-append
207 "for dir in "
208 (assoc-ref %outputs "out") "/lib/cups/filter "
ef2f51a4 209 filters "/lib/cups/filter"))
51002318
RW
210
211 ;; check for charsets in cups-filters output
212 (("/usr/share/cups/charsets")
213 (string-append filters "/share/cups/charsets"))
214
215 ;; install additional required filters
216 (("instfilter texttopdf texttopdf pdf")
217 (string-append
218 "instfilter texttopdf texttopdf pdf;"
219 "instfilter imagetoraster imagetoraster raster;"
220 "instfilter gstoraster gstoraster raster;"
221 "instfilter urftopdf urftopdf pdf;"
222 "instfilter rastertopdf rastertopdf pdf;"
223 "instfilter pstopdf pstopdf pdf"))
224
225 ;; specify location of lpstat binary
226 (("description=\"`lpstat -l")
227 "description=\"`../systemv/lpstat -l")
228
229 ;; patch shebangs of embedded scripts
230 (("#!/bin/sh") (string-append "#!" (which "sh")))
231
232 ;; also link mime definitions from cups-filters
233 ;; to enable the additional filters for the test suite
234 (("ln -s \\$root/conf/mime\\.types")
235 (string-append
236 "ln -s " filters
237 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
238 "ln -s $root/conf/mime.types"))
239 (("ln -s \\$root/conf/mime\\.convs")
240 (string-append
241 "ln -s " filters
242 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
243 "ln -s $root/conf/mime.convs")))
244
245 ;; fix search path for "cat"
246 (substitute* "cups/testfile.c"
247 (("cupsFileFind\\(\"cat\", \"/bin\"")
248 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
249 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
250 (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))))
251 (alist-cons-after
252 'install
253 'install-cups-filters-symlinks
254 (lambda* (#:key inputs outputs #:allow-other-keys)
255 (let ((out (assoc-ref outputs "out"))
256 (cups-filters (assoc-ref inputs "cups-filters")))
257 ;; charsets
258 (symlink
259 (string-append cups-filters "/share/cups/charsets")
260 (string-append out "/share/charsets"))
261
262 ;; mime types, driver file, ppds
263 (for-each
264 (lambda (f)
265 (symlink (string-append cups-filters f)
266 (string-append out f)))
267 '("/share/cups/mime/cupsfilters.types"
268 "/share/cups/mime/cupsfilters.convs"
269 "/share/cups/drv/cupsfilters.drv"
270 "/share/ppd"))
271
272 ;; filters
273 (for-each
274 (lambda (f)
275 (symlink f
276 (string-append out "/lib/cups/filter" (basename f))))
ef2f51a4 277 (find-files (string-append cups-filters "/lib/cups/filter")))
51002318
RW
278
279 ;; backends
280 (for-each
281 (lambda (f)
282 (symlink (string-append cups-filters f)
ef2f51a4
LC
283 (string-append out "/lib/cups/backend/"
284 (basename f))))
285 '("/lib/cups/backend/parallel"
286 "/lib/cups/backend/serial"))
51002318
RW
287
288 ;; banners
289 (let ((banners "/share/cups/banners"))
290 (delete-file-recursively (string-append out banners))
291 (symlink (string-append cups-filters banners)
292 (string-append out banners)))
293
294 ;; assorted data
295 (let ((data "/share/cups/data"))
296 (delete-file-recursively (string-append out data))
297 (symlink (string-append cups-filters data)
298 (string-append out data)))))
299 %standard-phases)))))
300 (inputs
301 `(("avahi" ,avahi)
302 ("gnutls" ,gnutls)
303 ("cups-filters" ,cups-filters)
304 ("zlib" ,zlib)))))
2b56dc01
DM
305
306(define-public hplip
307 (package
308 (name "hplip")
309 (version "3.16.3")
310 (source (origin
311 (method url-fetch)
de67e922
LF
312 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
313 "/hplip-" version ".tar.gz"))
2b56dc01
DM
314 (sha256
315 (base32
316 "1501qdnkjp1ybgagy5188fmf6cgmj5555ygjl3543nlbwcp31lj2"))))
317 (build-system gnu-build-system)
318 (home-page "http://hplipopensource.com/")
319 (synopsis "HP Printer Drivers")
320 (description "Hewlett-Packard Printer Drivers and PPDs.")
321
322 ;; The 'COPYING' file lists directories where each of these 3 licenses
323 ;; applies.
324 (license (list license:gpl2+ license:bsd-3 license:expat))
325
326 ;; TODO install apparmor profile files eventually.
327 (arguments
328 `(#:configure-flags
329 `("--disable-network-build"
330 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
331 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
332 ;; Disable until mime.types merging works (FIXME).
333 "--disable-fax-build"
334 "--enable-hpcups-install"
335 "--enable-new-hpcups"
336 "--enable-cups_ppd_install"
337 "--enable-cups_drv_install"
338 ;; TODO add foomatic drv install eventually.
339 ;; TODO --enable-policykit eventually.
340 ,(string-append "--with-cupsfilterdir="
341 (assoc-ref %outputs "out") "/lib/cups/filter")
342 ,(string-append "--with-cupsbackenddir="
343 (assoc-ref %outputs "out") "/lib/cups/backend")
344 ,(string-append "--with-icondir="
345 (assoc-ref %outputs "out") "/share/applications")
346 ,(string-append "--with-systraydir="
347 (assoc-ref %outputs "out") "/etc/xdg"))
348
349 #:imported-modules ((guix build python-build-system)
350 ,@%gnu-build-system-modules)
351 #:modules ((guix build gnu-build-system)
352 (guix build utils)
353 ((guix build python-build-system) #:prefix python:))
354
355 #:phases (modify-phases %standard-phases
356 (add-after 'unpack 'fix-hard-coded-file-names
357 (lambda* (#:key inputs outputs #:allow-other-keys)
358 (let ((out (assoc-ref outputs "out"))
359 ;; FIXME: use merged ppds (I think actually only
360 ;; drvs need to be merged).
361 (cupsdir (assoc-ref inputs "cups-minimal")))
362 (substitute* "base/g.py"
363 (("'/usr/share;[^']*'")
364 (string-append "'" cupsdir "/share'"))
365 (("'/etc/hp/hplip.conf'")
366 (string-append "'" out
367 "/etc/hp/hplip.conf" "'")))
368
369 (substitute* "Makefile.in"
370 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
371 ;; FIXME Use beginning-of-word in regexp.
372 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
373 (("/usr/include/libusb-1.0")
374 (string-append (assoc-ref inputs "libusb")
375 "/include/libusb-1.0"))
376 (("^\tinstall-dist_hplip_stateDATA")
377 ;; Remove dependencies on
378 ;; 'install-dist_hplip_stateDATA' so we don't bail
379 ;; out while trying to create /var/lib/hplip.
380 "\t")
381 (("hplip_confdir = /etc/hp")
382 ;; This is only used for installing the default config.
383 (string-append "hplip_confdir = " out
384 "/etc/hp"))
385 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
386 ;; Note: We don't use hal.
387 (string-append "halpredir = " out
388 "/share/hal/fdi/preprobe/10osvendor"))
389 (("rulesdir = /etc/udev/rules.d")
390 ;; udev rules will be merged by base service.
391 (string-append "rulesdir = " out
392 "/lib/udev/rules.d"))
393 (("rulessystemdir = /usr/lib/systemd/system")
394 ;; We don't use systemd.
395 (string-append "rulessystemdir = " out
396 "/lib/systemd/system"))
397 (("/etc/sane.d")
398 (string-append out "/etc/sane.d"))))))
399
400 ;; Wrap bin/* so that the Python libs are found.
401 (add-after 'install 'wrap-binaries
402 (assoc-ref python:%standard-phases 'wrap)))))
403
404 ;; Python3 support is available starting from hplip@3.15.2.
405 (inputs `(("libjpeg" ,libjpeg)
406 ("cups-minimal" ,cups-minimal)
407 ("libusb" ,libusb)
408 ("sane-backends" ,sane-backends)
409 ("dbus" ,dbus)
410 ("python-wrapper" ,python-wrapper)
411 ("python" ,python)
412 ;; TODO: Make hp-setup find python-dbus.
413 ("python-dbus" ,python-dbus)))
414 (native-inputs `(("pkg-config" ,pkg-config)))))