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>
7 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
43 ;; Delay to avoid module circularity problems.
44 (define ghostscript/cups
46 (package (inherit ghostscript)
47 (name "ghostscript-with-cups")
48 (inputs `(("cups" ,cups-minimal)
49 ,@(package-inputs ghostscript))))))
51 (define-public cups-filters
58 (string-append "http://openprinting.org/download/cups-filters/"
59 "cups-filters-" version ".tar.xz"))
62 "1hcp1cfx1a71aa6fyayajjh7vw1ia7zya6981gz73vsy2pdb23qf"))
63 (modules '((guix build utils)))
65 ;; install backends, banners and filters to cups-filters output
66 ;; directory, not the cups server directory
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
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)
86 `(#:make-flags (list (string-append "PREFIX=" %output))
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")
94 ,(string-append "--with-rcdir="
95 (assoc-ref %outputs "out") "/etc/rc.d"))))
97 `(("glib" ,glib "bin") ; for gdbus-codegen
98 ("pkg-config" ,pkg-config)))
101 ("fontconfig" ,fontconfig)
102 ("freetype" ,freetype)
103 ("font-dejavu" ,font-dejavu) ;needed by test suite
104 ("ghostscript" ,(force ghostscript/cups))
108 ("libjpeg-8" ,libjpeg-8)
115 ("cups-minimal" ,cups-minimal)))
116 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
117 (synopsis "OpenPrinting CUPS filters and backends")
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
125 (license (list license:gpl2
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
137 (name "cups-minimal")
142 (uri (string-append "https://github.com/apple/cups/releases/download/v"
143 version "/cups-" version "-source.tar.gz"))
146 "1m8rwhbk0l8n19iwm51r2569jj15d0x6mpqhfig0bk3pm4577f43"))))
147 (build-system gnu-build-system)
150 '("--disable-launchd"
154 ;; Seven tests fail, mostly because of files that are provided by the
155 ;; cups-filters package.
158 (modify-phases %standard-phases
159 (add-before 'configure 'patch-makedefs
161 (substitute* "Makedefs.in"
162 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
163 (("/bin/sh") (which "sh")))))
164 (add-before 'build 'patch-tests
166 (substitute* "test/ippserver.c"
167 (("# else /\\* HAVE_AVAHI \\*/")
168 "#elif defined(HAVE_AVAHI)")))))))
170 `(("pkg-config" ,pkg-config)))
174 (home-page "https://www.cups.org")
175 (synopsis "The Common Unix Printing System")
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)))
188 (package (inherit cups-minimal)
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
198 '("--disable-launchd"
201 (modify-phases %standard-phases
202 (add-before 'configure 'patch-makedefs
204 (substitute* "Makedefs.in"
205 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
206 (("/bin/sh") (which "sh")))))
207 (add-before 'check 'patch-tests
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/")))
214 (substitute* "test/run-stp-tests.sh"
215 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
217 ;; allow installation of filters from output dir and from
219 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
222 (assoc-ref %outputs "out") "/lib/cups/filter "
223 filters "/lib/cups/filter"))
225 ;; check for charsets in cups-filters output
226 (("/usr/share/cups/charsets")
227 (string-append filters "/share/cups/charsets"))
229 ;; install additional required filters
230 (("instfilter texttopdf texttopdf pdf")
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"))
239 ;; specify location of lpstat binary
240 (("description=\"`lpstat -l")
241 "description=\"`../systemv/lpstat -l")
243 ;; patch shebangs of embedded scripts
244 (("#!/bin/sh") (string-append "#!" (which "sh")))
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")
251 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
252 "ln -s $root/conf/mime.types"))
253 (("ln -s \\$root/conf/mime\\.convs")
256 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
257 "ln -s $root/conf/mime.convs")))
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")))
271 (string-append cups-filters "/share/cups/charsets")
272 (string-append out "/share/charsets"))
274 ;; mime types, driver file, ppds
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"
288 (string-append out "/lib/cups/filter" (basename f))))
289 (find-files (string-append cups-filters "/lib/cups/filter")))
294 (symlink (string-append cups-filters f)
295 (string-append out "/lib/cups/backend/"
297 '("/lib/cups/backend/parallel"
298 "/lib/cups/backend/serial"))
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)))
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)))))))))
314 ("cups-filters" ,cups-filters)
323 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
324 "/hplip-" version ".tar.gz"))
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.")
333 ;; The 'COPYING' file lists directories where each of these 3 licenses
335 (license (list license:gpl2+ license:bsd-3 license:expat))
337 ;; TODO install apparmor profile files eventually.
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"))
360 #:imported-modules ((guix build python-build-system)
361 ,@%gnu-build-system-modules)
362 #:modules ((guix build gnu-build-system)
364 ((guix build python-build-system) #:prefix python:))
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" "'")))
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.
392 (("hplip_confdir = /etc/hp")
393 ;; This is only used for installing the default config.
394 (string-append "hplip_confdir = " out
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"))
409 (string-append out "/etc/sane.d"))))))
411 ;; Wrap bin/* so that the Python libs are found.
412 (add-after 'install 'wrap-binaries
413 (assoc-ref python:%standard-phases 'wrap)))))
415 ;; Python3 support is available starting from hplip@3.15.2.
416 (inputs `(("libjpeg" ,libjpeg)
417 ("cups-minimal" ,cups-minimal)
419 ("sane-backends" ,sane-backends)
421 ("python-wrapper" ,python-wrapper)
423 ;; TODO: Make hp-setup find python-dbus.
424 ("python-dbus" ,python-dbus)))
425 (native-inputs `(("pkg-config" ,pkg-config)))))