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