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, 2017 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
6 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2017 Mark H Weaver <mhw@netris.org>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages cups)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages avahi)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages libusb)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages python)
35 #:use-module (gnu packages scanner)
36 #:use-module (gnu packages image)
37 #:use-module (gnu packages fonts) ;font-dejavu
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages ghostscript)
40 #:use-module (gnu packages glib)
41 #:use-module (gnu packages pdf)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages tls))
45 ;; Delay to avoid module circularity problems.
46 (define ghostscript/cups
48 (package/inherit ghostscript
49 (name "ghostscript-with-cups")
50 (inputs `(("cups" ,cups-minimal)
51 ,@(package-inputs ghostscript))))))
53 (define-public cups-filters
60 (string-append "http://openprinting.org/download/cups-filters/"
61 "cups-filters-" version ".tar.xz"))
64 "0175jhqpsyn7bkh7w43ydhyws5zsdak05hr1fsadvzslvwqkffgi"))
65 (modules '((guix build utils)))
67 ;; install backends, banners and filters to cups-filters output
68 ;; directory, not the cups server directory
70 (substitute* "Makefile.in"
71 (("CUPS_DATADIR = @CUPS_DATADIR@")
72 "CUPS_DATADIR = $(PREFIX)/share/cups")
73 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
74 "pkgcupsserverrootdir = $(PREFIX)")
75 ;; Choose standard directories notably so that binaries are
77 (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend")
78 "pkgbackenddir = $(PREFIX)/lib/cups/backend")
79 (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter")
80 "pkgfilterdir = $(PREFIX)/lib/cups/filter"))
81 ;; Find bannertopdf data such as the print test page in our
82 ;; output directory, not CUPS's prefix.
83 (substitute* "configure"
84 (("\\{CUPS_DATADIR\\}/data")
85 "{prefix}/share/cups/data"))))))
86 (build-system gnu-build-system)
88 `(#:make-flags (list (string-append "PREFIX=" %output))
90 `("--disable-driverless" ; TODO: enable this
91 "--disable-mutool" ; depends on yet another PDF library (mupdf)
92 ,(string-append "--with-test-font-path="
93 (assoc-ref %build-inputs "font-dejavu")
94 "/share/fonts/truetype/DejaVuSans.ttf")
95 ,(string-append "--with-gs-path="
96 (assoc-ref %build-inputs "ghostscript")
98 ,(string-append "--with-shell="
99 (assoc-ref %build-inputs "bash")
101 ,(string-append "--with-rcdir="
102 (assoc-ref %outputs "out") "/etc/rc.d"))))
104 `(("glib" ,glib "bin") ; for gdbus-codegen
105 ("pkg-config" ,pkg-config)))
108 ("fontconfig" ,fontconfig)
109 ("freetype" ,freetype)
110 ("font-dejavu" ,font-dejavu) ; also needed by test suite
111 ("ghostscript" ,(force ghostscript/cups))
121 ("cups-minimal" ,cups-minimal)))
122 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
123 (synopsis "OpenPrinting CUPS filters and backends")
125 "Contains backends, filters, and other software that was once part of the
126 core CUPS distribution but is no longer maintained by Apple Inc. In addition
127 it contains additional filters developed independently of Apple, especially
128 filters for the PDF-centric printing workflow introduced by OpenPrinting.")
129 ;; Different filters and backends have different licenses; see COPYING for
131 (license (list license:gpl2
138 ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
139 ;; depends on CUPS libraries and binaries, cups-minimal has been added to
140 ;; satisfy this dependency.
141 (define-public cups-minimal
143 (name "cups-minimal")
148 (uri (string-append "https://github.com/apple/cups/releases/download/v"
149 version "/cups-" version "-source.tar.gz"))
152 "1k4qxafmapq6hzbkh273fdyzkj9alw6ppwz5k933bhsi4svlsvar"))))
153 (build-system gnu-build-system)
156 '("--disable-launchd"
160 ;; Seven tests fail, mostly because of files that are provided by the
161 ;; cups-filters package.
164 (modify-phases %standard-phases
165 (add-before 'configure 'patch-makedefs
167 (substitute* "Makedefs.in"
168 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
169 (("/bin/sh") (which "sh")))))
170 ;; Make the compressed manpages writable so that the
171 ;; reset-gzip-timestamps phase does not error out.
172 (add-before 'reset-gzip-timestamps 'make-manpages-writable
173 (lambda* (#:key outputs #:allow-other-keys)
174 (let* ((out (assoc-ref outputs "out"))
175 (man (string-append out "/share/man")))
176 (for-each (lambda (file) (chmod file #o644))
177 (find-files man "\\.gz")))))
178 (add-before 'build 'patch-tests
180 (substitute* "test/ippserver.c"
181 (("# else /\\* HAVE_AVAHI \\*/")
182 "#elif defined(HAVE_AVAHI)")))))))
184 `(("pkg-config" ,pkg-config)))
188 (home-page "https://www.cups.org")
189 (synopsis "The Common Unix Printing System")
191 "CUPS is a printing system that uses the Internet Printing
192 Protocol (IPP). It provides System V and BSD command-line interfaces, as well
193 as a Web interface and a C programming interface to manage printers and print
194 jobs. It supports printing to both local (parallel, serial, USB) and
195 networked printers, and printers can be shared from one computer to another.
196 Internally, CUPS uses PostScript Printer Description (PPD) files to describe
197 printer capabilities and features and a wide variety of generic and
198 device-specific programs to convert and print many types of files.")
199 (license license:gpl2)))
202 (package (inherit cups-minimal)
205 `(;; Three tests fail:
206 ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6:
207 ;; Get-Jobs Operation"
208 ;; * test of number of error/warning messages, probably related to a
212 '("--disable-launchd"
215 (modify-phases %standard-phases
216 (add-before 'configure 'patch-makedefs
218 (substitute* "Makedefs.in"
219 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
220 (("/bin/sh") (which "sh")))))
221 (add-before 'check 'patch-tests
223 (let ((filters (assoc-ref %build-inputs "cups-filters"))
224 (catpath (string-append
225 (assoc-ref %build-inputs "coreutils") "/bin/"))
226 (testdir (string-append (getcwd) "/tmp/")))
228 (substitute* "test/run-stp-tests.sh"
229 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
231 ;; allow installation of filters from output dir and from
233 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
236 (assoc-ref %outputs "out") "/lib/cups/filter "
237 filters "/lib/cups/filter"))
239 ;; check for charsets in cups-filters output
240 (("/usr/share/cups/charsets")
241 (string-append filters "/share/cups/charsets"))
243 ;; install additional required filters
244 (("instfilter texttopdf texttopdf pdf")
246 "instfilter texttopdf texttopdf pdf;"
247 "instfilter imagetoraster imagetoraster raster;"
248 "instfilter gstoraster gstoraster raster;"
249 "instfilter urftopdf urftopdf pdf;"
250 "instfilter rastertopdf rastertopdf pdf;"
251 "instfilter pstopdf pstopdf pdf"))
253 ;; specify location of lpstat binary
254 (("description=\"`lpstat -l")
255 "description=\"`../systemv/lpstat -l")
257 ;; patch shebangs of embedded scripts
258 (("#!/bin/sh") (string-append "#!" (which "sh")))
260 ;; also link mime definitions from cups-filters
261 ;; to enable the additional filters for the test suite
262 (("ln -s \\$root/conf/mime\\.types")
265 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
266 "ln -s $root/conf/mime.types"))
267 (("ln -s \\$root/conf/mime\\.convs")
270 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
271 "ln -s $root/conf/mime.convs")))
273 ;; fix search path for "cat"
274 (substitute* "cups/testfile.c"
275 (("cupsFileFind\\(\"cat\", \"/bin\"")
276 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
277 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
278 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))))))
279 ;; Make the compressed manpages writable so that the
280 ;; reset-gzip-timestamps phase does not error out.
281 (add-before 'reset-gzip-timestamps 'make-manpages-writable
282 (lambda* (#:key outputs #:allow-other-keys)
283 (let* ((out (assoc-ref outputs "out"))
284 (man (string-append out "/share/man")))
285 (for-each (lambda (file) (chmod file #o644))
286 (find-files man "\\.gz")))))
287 (add-after 'install 'install-cups-filters-symlinks
288 (lambda* (#:key inputs outputs #:allow-other-keys)
289 (let ((out (assoc-ref outputs "out"))
290 (cups-filters (assoc-ref inputs "cups-filters")))
293 (string-append cups-filters "/share/cups/charsets")
294 (string-append out "/share/charsets"))
296 ;; mime types, driver file, ppds
299 (symlink (string-append cups-filters f)
300 (string-append out f)))
301 '("/share/cups/mime/cupsfilters.types"
302 "/share/cups/mime/cupsfilters.convs"
303 "/share/cups/drv/cupsfilters.drv"
310 (string-append out "/lib/cups/filter" (basename f))))
311 (find-files (string-append cups-filters "/lib/cups/filter")))
316 (symlink (string-append cups-filters f)
317 (string-append out "/lib/cups/backend/"
319 '("/lib/cups/backend/parallel"
320 "/lib/cups/backend/serial"))
323 (let ((banners "/share/cups/banners"))
324 (delete-file-recursively (string-append out banners))
325 (symlink (string-append cups-filters banners)
326 (string-append out banners)))
329 (let ((data "/share/cups/data"))
330 (delete-file-recursively (string-append out data))
331 (symlink (string-append cups-filters data)
332 (string-append out data)))))))))
336 ("cups-filters" ,cups-filters)
345 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
346 "/hplip-" version ".tar.gz"))
349 "0zhhnp3ksd9i2maaqrsjn4p3y7im3llgylp2y8qgmqypm8s7ha40"))))
350 (build-system gnu-build-system)
351 (home-page "http://hplipopensource.com/")
352 (synopsis "HP Printer Drivers")
353 (description "Hewlett-Packard Printer Drivers and PPDs.")
355 ;; The 'COPYING' file lists directories where each of these 3 licenses
357 (license (list license:gpl2+ license:bsd-3 license:expat))
359 ;; TODO install apparmor profile files eventually.
362 `("--disable-network-build"
363 ,(string-append "--prefix=" (assoc-ref %outputs "out"))
364 ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
365 ;; Disable until mime.types merging works (FIXME).
366 "--disable-fax-build"
367 "--enable-hpcups-install"
368 "--enable-new-hpcups"
369 "--enable-cups_ppd_install"
370 "--enable-cups_drv_install"
371 ;; TODO add foomatic drv install eventually.
372 ;; TODO --enable-policykit eventually.
373 ,(string-append "--with-cupsfilterdir="
374 (assoc-ref %outputs "out") "/lib/cups/filter")
375 ,(string-append "--with-cupsbackenddir="
376 (assoc-ref %outputs "out") "/lib/cups/backend")
377 ,(string-append "--with-icondir="
378 (assoc-ref %outputs "out") "/share/applications")
379 ,(string-append "--with-systraydir="
380 (assoc-ref %outputs "out") "/etc/xdg"))
382 #:imported-modules ((guix build python-build-system)
383 ,@%gnu-build-system-modules)
384 #:modules ((guix build gnu-build-system)
386 ((guix build python-build-system) #:prefix python:))
388 #:phases (modify-phases %standard-phases
389 (add-after 'unpack 'fix-hard-coded-file-names
390 (lambda* (#:key inputs outputs #:allow-other-keys)
391 (let ((out (assoc-ref outputs "out"))
392 ;; FIXME: use merged ppds (I think actually only
393 ;; drvs need to be merged).
394 (cupsdir (assoc-ref inputs "cups-minimal")))
395 (substitute* "base/g.py"
396 (("'/usr/share;[^']*'")
397 (string-append "'" cupsdir "/share'"))
398 (("'/etc/hp/hplip.conf'")
399 (string-append "'" out
400 "/etc/hp/hplip.conf" "'")))
402 (substitute* "Makefile.in"
403 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
404 ;; FIXME Use beginning-of-word in regexp.
405 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
406 (("/usr/include/libusb-1.0")
407 (string-append (assoc-ref inputs "libusb")
408 "/include/libusb-1.0"))
409 (("^\tinstall-dist_hplip_stateDATA")
410 ;; Remove dependencies on
411 ;; 'install-dist_hplip_stateDATA' so we don't bail
412 ;; out while trying to create /var/lib/hplip.
414 (("hplip_confdir = /etc/hp")
415 ;; This is only used for installing the default config.
416 (string-append "hplip_confdir = " out
418 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
419 ;; Note: We don't use hal.
420 (string-append "halpredir = " out
421 "/share/hal/fdi/preprobe/10osvendor"))
422 (("rulesdir = /etc/udev/rules.d")
423 ;; udev rules will be merged by base service.
424 (string-append "rulesdir = " out
425 "/lib/udev/rules.d"))
426 (("rulessystemdir = /usr/lib/systemd/system")
427 ;; We don't use systemd.
428 (string-append "rulessystemdir = " out
429 "/lib/systemd/system"))
431 (string-append out "/etc/sane.d"))))))
433 ;; Wrap bin/* so that the Python libs are found.
434 (add-after 'install 'wrap-binaries
435 (assoc-ref python:%standard-phases 'wrap)))))
437 ;; Python3 support is available starting from hplip@3.15.2.
438 (inputs `(("libjpeg" ,libjpeg)
439 ("cups-minimal" ,cups-minimal)
441 ("sane-backends" ,sane-backends-minimal)
443 ("python-wrapper" ,python-wrapper)
445 ;; TODO: Make hp-setup find python-dbus.
446 ("python-dbus" ,python-dbus)))
447 (native-inputs `(("pkg-config" ,pkg-config)))))