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 (define-public cups-filters
50 (string-append "http://openprinting.org/download/cups-filters/"
51 "cups-filters-" version ".tar.xz"))
54 "16jpqqlixlv2dxqv8gak5qg4qnsnw4p745xr6rhw9dgylf13z9ha"))
55 (modules '((guix build utils)))
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)")
64 ;; Choose standard directories notably so that binaries are
66 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
67 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
68 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
69 "pkgfilterdir = $(PREFIX)/lib/cups/filter")))))
70 (build-system gnu-build-system)
72 `(#:make-flags (list (string-append "PREFIX=" %output))
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"))))
80 `(("glib" ,glib "bin") ; for gdbus-codegen
81 ("pkg-config" ,pkg-config)))
83 `(("fontconfig" ,fontconfig)
84 ("freetype" ,freetype)
85 ("font-dejavu" ,font-dejavu) ;needed by test suite
86 ("ghostscript" ,ghostscript)
90 ("libjpeg-8" ,libjpeg-8)
96 ("cups-minimal" ,cups-minimal)))
97 (home-page "http://www.linuxfoundation.org/collaborate/workgroups/openprinting/cups-filters")
98 (synopsis "OpenPrinting CUPS filters and backends")
100 "Contains backends, filters, and other software that was once part of the
101 core CUPS distribution but is no longer maintained by Apple Inc. In addition
102 it contains additional filters developed independently of Apple, especially
103 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
104 ;; Different filters and backends have different licenses; see COPYING for
106 (license (list license:gpl2
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
118 (name "cups-minimal")
122 (uri (string-append "http://www.cups.org/software/"
123 version "/cups-" version "-source.tar.bz2"))
126 "1jfjqsw9l7jbn5kb9i96k0wj12kjdbgx0rd8157dif22hi0kh0ms"))))
127 (build-system gnu-build-system)
130 '("--disable-launchd"
134 ;; Seven tests fail, mostly because of files that are provided by the
135 ;; cups-filters package.
138 (modify-phases %standard-phases
139 (add-before 'configure 'patch-makedefs
141 (substitute* "Makedefs.in"
142 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
143 (("/bin/sh") (which "sh")))))
144 (add-before 'build 'patch-tests
146 (substitute* "test/ippserver.c"
147 (("# else /\\* HAVE_AVAHI \\*/")
148 "#elif defined(HAVE_AVAHI)")))))))
150 `(("pkg-config" ,pkg-config)))
154 (home-page "http://www.cups.org")
155 (synopsis "The Common Unix Printing System")
157 "CUPS is a printing system that uses the Internet Printing
158 Protocol (IPP). It provides System V and BSD command-line interfaces, as well
159 as a Web interface and a C programming interface to manage printers and print
160 jobs. It supports printing to both local (parallel, serial, USB) and
161 networked printers, and printers can be shared from one computer to another.
162 Internally, CUPS uses PostScript Printer Description (PPD) files to describe
163 printer capabilities and features and a wide variety of generic and
164 device-specific programs to convert and print many types of files.")
165 (license license:gpl2)))
168 (package (inherit cups-minimal)
171 `(;; Three tests fail:
172 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
173 ;; Get-Jobs Operation"
174 ;; * test of number of error/warning messages, probably related to a
178 '("--disable-launchd"
185 (substitute* "Makedefs.in"
186 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
187 (("/bin/sh") (which "sh"))))
192 (let ((filters (assoc-ref %build-inputs "cups-filters"))
193 (catpath (string-append
194 (assoc-ref %build-inputs "coreutils") "/bin/"))
195 (testdir (string-append (getcwd) "/tmp/")))
197 (substitute* "test/run-stp-tests.sh"
198 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
200 ;; allow installation of filters from output dir and from
202 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
205 (assoc-ref %outputs "out") "/lib/cups/filter "
206 filters "/lib/cups/filter"))
208 ;; check for charsets in cups-filters output
209 (("/usr/share/cups/charsets")
210 (string-append filters "/share/cups/charsets"))
212 ;; install additional required filters
213 (("instfilter texttopdf texttopdf pdf")
215 "instfilter texttopdf texttopdf pdf;"
216 "instfilter imagetoraster imagetoraster raster;"
217 "instfilter gstoraster gstoraster raster;"
218 "instfilter urftopdf urftopdf pdf;"
219 "instfilter rastertopdf rastertopdf pdf;"
220 "instfilter pstopdf pstopdf pdf"))
222 ;; specify location of lpstat binary
223 (("description=\"`lpstat -l")
224 "description=\"`../systemv/lpstat -l")
226 ;; patch shebangs of embedded scripts
227 (("#!/bin/sh") (string-append "#!" (which "sh")))
229 ;; also link mime definitions from cups-filters
230 ;; to enable the additional filters for the test suite
231 (("ln -s \\$root/conf/mime\\.types")
234 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
235 "ln -s $root/conf/mime.types"))
236 (("ln -s \\$root/conf/mime\\.convs")
239 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
240 "ln -s $root/conf/mime.convs")))
242 ;; fix search path for "cat"
243 (substitute* "cups/testfile.c"
244 (("cupsFileFind\\(\"cat\", \"/bin\"")
245 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
246 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
247 (string-append "cupsFileFind(\"cat\", \"" catpath "\"")))))
250 'install-cups-filters-symlinks
251 (lambda* (#:key inputs outputs #:allow-other-keys)
252 (let ((out (assoc-ref outputs "out"))
253 (cups-filters (assoc-ref inputs "cups-filters")))
256 (string-append cups-filters "/share/cups/charsets")
257 (string-append out "/share/charsets"))
259 ;; mime types, driver file, ppds
262 (symlink (string-append cups-filters f)
263 (string-append out f)))
264 '("/share/cups/mime/cupsfilters.types"
265 "/share/cups/mime/cupsfilters.convs"
266 "/share/cups/drv/cupsfilters.drv"
273 (string-append out "/lib/cups/filter" (basename f))))
274 (find-files (string-append cups-filters "/lib/cups/filter")))
279 (symlink (string-append cups-filters f)
280 (string-append out "/lib/cups/backend/"
282 '("/lib/cups/backend/parallel"
283 "/lib/cups/backend/serial"))
286 (let ((banners "/share/cups/banners"))
287 (delete-file-recursively (string-append out banners))
288 (symlink (string-append cups-filters banners)
289 (string-append out banners)))
292 (let ((data "/share/cups/data"))
293 (delete-file-recursively (string-append out data))
294 (symlink (string-append cups-filters data)
295 (string-append out data)))))
296 %standard-phases)))))
300 ("cups-filters" ,cups-filters)
309 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
310 "/hplip-" version ".tar.gz"))
313 "1svcalf2nc7mvxndp9zz3xp43w66z45rrsr5syl8fx61a6p6gnm9"))))
314 (build-system gnu-build-system)
315 (home-page "http://hplipopensource.com/")
316 (synopsis "HP Printer Drivers")
317 (description "Hewlett-Packard Printer Drivers and PPDs.")
319 ;; The 'COPYING' file lists directories where each of these 3 licenses
321 (license (list license:gpl2+ license:bsd-3 license:expat))
323 ;; TODO install apparmor profile files eventually.
326 `("--disable-network-build"
327 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
328 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
329 ;; Disable until mime.types merging works (FIXME).
330 "--disable-fax-build"
331 "--enable-hpcups-install"
332 "--enable-new-hpcups"
333 "--enable-cups_ppd_install"
334 "--enable-cups_drv_install"
335 ;; TODO add foomatic drv install eventually.
336 ;; TODO --enable-policykit eventually.
337 ,(string-append "--with-cupsfilterdir="
338 (assoc-ref %outputs "out") "/lib/cups/filter")
339 ,(string-append "--with-cupsbackenddir="
340 (assoc-ref %outputs "out") "/lib/cups/backend")
341 ,(string-append "--with-icondir="
342 (assoc-ref %outputs "out") "/share/applications")
343 ,(string-append "--with-systraydir="
344 (assoc-ref %outputs "out") "/etc/xdg"))
346 #:imported-modules ((guix build python-build-system)
347 ,@%gnu-build-system-modules)
348 #:modules ((guix build gnu-build-system)
350 ((guix build python-build-system) #:prefix python:))
352 #:phases (modify-phases %standard-phases
353 (add-after 'unpack 'fix-hard-coded-file-names
354 (lambda* (#:key inputs outputs #:allow-other-keys)
355 (let ((out (assoc-ref outputs "out"))
356 ;; FIXME: use merged ppds (I think actually only
357 ;; drvs need to be merged).
358 (cupsdir (assoc-ref inputs "cups-minimal")))
359 (substitute* "base/g.py"
360 (("'/usr/share;[^']*'")
361 (string-append "'" cupsdir "/share'"))
362 (("'/etc/hp/hplip.conf'")
363 (string-append "'" out
364 "/etc/hp/hplip.conf" "'")))
366 (substitute* "Makefile.in"
367 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
368 ;; FIXME Use beginning-of-word in regexp.
369 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
370 (("/usr/include/libusb-1.0")
371 (string-append (assoc-ref inputs "libusb")
372 "/include/libusb-1.0"))
373 (("^\tinstall-dist_hplip_stateDATA")
374 ;; Remove dependencies on
375 ;; 'install-dist_hplip_stateDATA' so we don't bail
376 ;; out while trying to create /var/lib/hplip.
378 (("hplip_confdir = /etc/hp")
379 ;; This is only used for installing the default config.
380 (string-append "hplip_confdir = " out
382 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
383 ;; Note: We don't use hal.
384 (string-append "halpredir = " out
385 "/share/hal/fdi/preprobe/10osvendor"))
386 (("rulesdir = /etc/udev/rules.d")
387 ;; udev rules will be merged by base service.
388 (string-append "rulesdir = " out
389 "/lib/udev/rules.d"))
390 (("rulessystemdir = /usr/lib/systemd/system")
391 ;; We don't use systemd.
392 (string-append "rulessystemdir = " out
393 "/lib/systemd/system"))
395 (string-append out "/etc/sane.d"))))))
397 ;; Wrap bin/* so that the Python libs are found.
398 (add-after 'install 'wrap-binaries
399 (assoc-ref python:%standard-phases 'wrap)))))
401 ;; Python3 support is available starting from hplip@3.15.2.
402 (inputs `(("libjpeg" ,libjpeg)
403 ("cups-minimal" ,cups-minimal)
405 ("sane-backends" ,sane-backends)
407 ("python-wrapper" ,python-wrapper)
409 ;; TODO: Make hp-setup find python-dbus.
410 ("python-dbus" ,python-dbus)))
411 (native-inputs `(("pkg-config" ,pkg-config)))))