| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net> |
| 3 | ;;; Copyright © 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org> |
| 4 | ;;; Copyright © 2015, 2016, 2017, 2018 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> |
| 8 | ;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
| 9 | ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com> |
| 10 | ;;; |
| 11 | ;;; This file is part of GNU Guix. |
| 12 | ;;; |
| 13 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
| 14 | ;;; under the terms of the GNU General Public License as published by |
| 15 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
| 16 | ;;; your option) any later version. |
| 17 | ;;; |
| 18 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
| 19 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | ;;; GNU General Public License for more details. |
| 22 | ;;; |
| 23 | ;;; You should have received a copy of the GNU General Public License |
| 24 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 25 | |
| 26 | (define-module (gnu packages cups) |
| 27 | #:use-module (gnu packages) |
| 28 | #:use-module (gnu packages algebra) |
| 29 | #:use-module (gnu packages autotools) |
| 30 | #:use-module (gnu packages avahi) |
| 31 | #:use-module (gnu packages compression) |
| 32 | #:use-module (gnu packages fonts) ; font-dejavu |
| 33 | #:use-module (gnu packages fontutils) |
| 34 | #:use-module (gnu packages ghostscript) |
| 35 | #:use-module (gnu packages glib) |
| 36 | #:use-module (gnu packages groff) |
| 37 | #:use-module (gnu packages image) |
| 38 | #:use-module (gnu packages libusb) |
| 39 | #:use-module (gnu packages pdf) |
| 40 | #:use-module (gnu packages perl) |
| 41 | #:use-module (gnu packages pkg-config) |
| 42 | #:use-module (gnu packages polkit) |
| 43 | #:use-module (gnu packages pretty-print) |
| 44 | #:use-module (gnu packages python) |
| 45 | #:use-module (gnu packages python-xyz) |
| 46 | #:use-module (gnu packages qt) |
| 47 | #:use-module (gnu packages scanner) |
| 48 | #:use-module (gnu packages tls) |
| 49 | #:use-module (guix build-system gnu) |
| 50 | #:use-module (guix build-system python) |
| 51 | #:use-module (guix download) |
| 52 | #:use-module (guix svn-download) |
| 53 | #:use-module ((guix licenses) #:prefix license:) |
| 54 | #:use-module (guix packages) |
| 55 | #:use-module (guix utils) |
| 56 | #:use-module (srfi srfi-1) |
| 57 | #:use-module (ice-9 match)) |
| 58 | |
| 59 | (define-public cups-filters |
| 60 | (package |
| 61 | (name "cups-filters") |
| 62 | (version "1.27.4") |
| 63 | (source(origin |
| 64 | (method url-fetch) |
| 65 | (uri |
| 66 | (string-append "https://openprinting.org/download/cups-filters/" |
| 67 | "cups-filters-" version ".tar.xz")) |
| 68 | (sha256 |
| 69 | (base32 |
| 70 | "110b1xhb5vfpcx0zq9kkas7pj281skx5dpnnr22idx509jfdzj8b")) |
| 71 | (modules '((guix build utils))) |
| 72 | (snippet |
| 73 | ;; install backends, banners and filters to cups-filters output |
| 74 | ;; directory, not the cups server directory |
| 75 | '(begin |
| 76 | (substitute* "Makefile.in" |
| 77 | (("CUPS_DATADIR = @CUPS_DATADIR@") |
| 78 | "CUPS_DATADIR = $(PREFIX)/share/cups") |
| 79 | (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)") |
| 80 | "pkgcupsserverrootdir = $(PREFIX)") |
| 81 | ;; Choose standard directories notably so that binaries are |
| 82 | ;; stripped. |
| 83 | (("pkgbackenddir = \\$\\(CUPS_SERVERBIN\\)/backend") |
| 84 | "pkgbackenddir = $(PREFIX)/lib/cups/backend") |
| 85 | (("pkgfilterdir = \\$\\(CUPS_SERVERBIN\\)/filter") |
| 86 | "pkgfilterdir = $(PREFIX)/lib/cups/filter")) |
| 87 | ;; Find bannertopdf data such as the print test page in our |
| 88 | ;; output directory, not CUPS's prefix. |
| 89 | (substitute* "configure" |
| 90 | (("\\{CUPS_DATADIR\\}/data") |
| 91 | "{prefix}/share/cups/data")) |
| 92 | #t)))) |
| 93 | (build-system gnu-build-system) |
| 94 | (arguments |
| 95 | `(#:make-flags (list (string-append "PREFIX=" %output)) |
| 96 | #:configure-flags |
| 97 | `("--disable-driverless" ; TODO: enable this |
| 98 | "--disable-mutool" ; depends on yet another PDF library (mupdf) |
| 99 | |
| 100 | ;; Look for the "domain socket of CUPS" in /var/run/cups. |
| 101 | "--localstatedir=/var" |
| 102 | |
| 103 | ;; Free software for the win. |
| 104 | "--with-acroread-path=evince" |
| 105 | |
| 106 | ,(string-append "--with-test-font-path=" |
| 107 | (assoc-ref %build-inputs "font-dejavu") |
| 108 | "/share/fonts/truetype/DejaVuSans.ttf") |
| 109 | ,(string-append "--with-gs-path=" |
| 110 | (assoc-ref %build-inputs "ghostscript") |
| 111 | "/bin/gsc") |
| 112 | ,(string-append "--with-shell=" |
| 113 | (assoc-ref %build-inputs "bash") |
| 114 | "/bin/bash") |
| 115 | ,(string-append "--with-rcdir=" |
| 116 | (assoc-ref %outputs "out") "/etc/rc.d")) |
| 117 | |
| 118 | #:phases (modify-phases %standard-phases |
| 119 | (add-after 'unpack 'patch-foomatic-hardcoded-file-names |
| 120 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 121 | ;; Foomatic has hardcoded file names we need to fix. |
| 122 | (let ((out (assoc-ref outputs "out")) |
| 123 | (gs (assoc-ref inputs "ghostscript"))) |
| 124 | (substitute* "filter/foomatic-rip/foomaticrip.c" |
| 125 | (("/usr/local/lib/cups/filter") |
| 126 | (string-append out "/lib/cups/filter"))) |
| 127 | #t))) |
| 128 | (add-after 'install 'wrap-filters |
| 129 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 130 | ;; Some filters expect to find 'gs' in $PATH. We cannot |
| 131 | ;; just hard-code its absolute file name in the source |
| 132 | ;; because foomatic-rip, for example, has tests like |
| 133 | ;; 'startswith(cmd, "gs")'. |
| 134 | (let ((out (assoc-ref outputs "out")) |
| 135 | (ghostscript (assoc-ref inputs "ghostscript"))) |
| 136 | (for-each (lambda (file) |
| 137 | (wrap-program file |
| 138 | `("PATH" ":" prefix |
| 139 | (,(string-append ghostscript |
| 140 | "/bin"))))) |
| 141 | (find-files (string-append |
| 142 | out "/lib/cups/filter"))) |
| 143 | #t)))))) |
| 144 | (native-inputs |
| 145 | `(("glib" ,glib "bin") ; for gdbus-codegen |
| 146 | ("pkg-config" ,pkg-config))) |
| 147 | (inputs |
| 148 | `(("avahi" ,avahi) |
| 149 | ("fontconfig" ,fontconfig) |
| 150 | ("freetype" ,freetype) |
| 151 | ("font-dejavu" ,font-dejavu) ; also needed by test suite |
| 152 | ("ghostscript" ,ghostscript/cups) |
| 153 | ("ijs" ,ijs) |
| 154 | ("dbus" ,dbus) |
| 155 | ("lcms" ,lcms) |
| 156 | ("libjpeg" ,libjpeg-turbo) |
| 157 | ("libpng" ,libpng) |
| 158 | ("libtiff" ,libtiff) |
| 159 | ("glib" ,glib) |
| 160 | ("qpdf" ,qpdf) |
| 161 | ("poppler" ,poppler) |
| 162 | ("cups-minimal" ,cups-minimal))) |
| 163 | (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters") |
| 164 | (synopsis "OpenPrinting CUPS filters and backends") |
| 165 | (description |
| 166 | "Contains backends, filters, and other software that was once part of the |
| 167 | core CUPS distribution but is no longer maintained by Apple Inc. In addition |
| 168 | it contains additional filters developed independently of Apple, especially |
| 169 | filters for the PDF-centric printing workflow introduced by OpenPrinting.") |
| 170 | ;; Different filters and backends have different licenses; see COPYING for |
| 171 | ;; details |
| 172 | (license (list license:gpl2 |
| 173 | license:gpl2+ |
| 174 | license:gpl3 |
| 175 | license:gpl3+ |
| 176 | license:lgpl2.0+ |
| 177 | license:expat)))) |
| 178 | |
| 179 | ;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also |
| 180 | ;; depends on CUPS libraries and binaries, cups-minimal has been added to |
| 181 | ;; satisfy this dependency. |
| 182 | (define-public cups-minimal |
| 183 | (package |
| 184 | (name "cups-minimal") |
| 185 | (version "2.3.3") |
| 186 | (source |
| 187 | (origin |
| 188 | (method url-fetch) |
| 189 | (uri (string-append "https://github.com/apple/cups/releases/download/v" |
| 190 | version "/cups-" version "-source.tar.gz")) |
| 191 | (sha256 |
| 192 | (base32 |
| 193 | "1vpk0b2vq830f8fvf9z8qjsm5k141i7pi8djbinpnr78pi4dj7r6")))) |
| 194 | (build-system gnu-build-system) |
| 195 | (arguments |
| 196 | `(#:configure-flags |
| 197 | '("--disable-launchd" |
| 198 | "--disable-systemd" |
| 199 | "--disable-avahi" |
| 200 | "--disable-dnssd") |
| 201 | ;; Seven tests fail, mostly because of files that are provided by the |
| 202 | ;; cups-filters package. |
| 203 | #:tests? #f |
| 204 | #:phases |
| 205 | (modify-phases %standard-phases |
| 206 | (add-before 'configure 'patch-makedefs |
| 207 | (lambda _ |
| 208 | (substitute* "Makedefs.in" |
| 209 | (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@") |
| 210 | (("/bin/sh") (which "sh"))) |
| 211 | #t)) |
| 212 | ;; Make the compressed manpages writable so that the |
| 213 | ;; reset-gzip-timestamps phase does not error out. |
| 214 | (add-before 'reset-gzip-timestamps 'make-manpages-writable |
| 215 | (lambda* (#:key outputs #:allow-other-keys) |
| 216 | (let* ((out (assoc-ref outputs "out")) |
| 217 | (man (string-append out "/share/man"))) |
| 218 | (for-each (lambda (file) (chmod file #o644)) |
| 219 | (find-files man "\\.gz")) |
| 220 | #t))) |
| 221 | (add-before 'build 'patch-tests |
| 222 | (lambda _ |
| 223 | (substitute* "tools/ippeveprinter.c" |
| 224 | (("# else /\\* HAVE_AVAHI \\*/") |
| 225 | "#elif defined(HAVE_AVAHI)")) |
| 226 | #t))))) |
| 227 | (native-inputs |
| 228 | `(("pkg-config" ,pkg-config))) |
| 229 | (inputs |
| 230 | `(("zlib" ,zlib) |
| 231 | ("gnutls" ,gnutls))) |
| 232 | (home-page "https://www.cups.org") |
| 233 | (synopsis "The Common Unix Printing System") |
| 234 | (description |
| 235 | "CUPS is a printing system that uses the Internet Printing Protocol |
| 236 | (@dfn{IPP}). It provides System V and BSD command-line interfaces, as well |
| 237 | as a Web interface and a C programming interface to manage printers and print |
| 238 | jobs. It supports printing to both local (parallel, serial, USB) and |
| 239 | networked printers, and printers can be shared from one computer to another. |
| 240 | Internally, CUPS uses PostScript Printer Description (@dfn{PPD}) files to |
| 241 | describe printer capabilities and features, and a wide variety of generic and |
| 242 | device-specific programs to convert and print many types of files.") |
| 243 | ;; CUPS is Apache 2.0 with exceptions, see the NOTICE file. |
| 244 | (license license:asl2.0))) |
| 245 | |
| 246 | (define-public cups |
| 247 | (package/inherit cups-minimal |
| 248 | (name "cups") |
| 249 | (arguments |
| 250 | `(;; Three tests fail: |
| 251 | ;; * two tests in ipp-1.1.test related to "RFC 2911 section 3.2.6: |
| 252 | ;; Get-Jobs Operation" |
| 253 | ;; * test of number of error/warning messages, probably related to a |
| 254 | ;; missing font. |
| 255 | #:tests? #f |
| 256 | #:configure-flags |
| 257 | '("--disable-launchd" |
| 258 | "--disable-systemd") |
| 259 | #:phases |
| 260 | (modify-phases %standard-phases |
| 261 | (add-before 'configure 'patch-makedefs |
| 262 | (lambda _ |
| 263 | (substitute* "Makedefs.in" |
| 264 | (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@") |
| 265 | (("/bin/sh") (which "sh"))) |
| 266 | #t)) |
| 267 | (add-before 'check 'patch-tests |
| 268 | (lambda _ |
| 269 | (let ((filters (assoc-ref %build-inputs "cups-filters")) |
| 270 | (catpath (string-append |
| 271 | (assoc-ref %build-inputs "coreutils") "/bin/")) |
| 272 | (testdir (string-append (getcwd) "/tmp/"))) |
| 273 | (mkdir testdir) |
| 274 | (substitute* "test/run-stp-tests.sh" |
| 275 | ((" *BASE=/tmp/") (string-append "BASE=" testdir)) |
| 276 | |
| 277 | ;; allow installation of filters from output dir and from |
| 278 | ;; cups-filters |
| 279 | (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter") |
| 280 | (string-append |
| 281 | "for dir in " |
| 282 | (assoc-ref %outputs "out") "/lib/cups/filter " |
| 283 | filters "/lib/cups/filter")) |
| 284 | |
| 285 | ;; check for charsets in cups-filters output |
| 286 | (("/usr/share/cups/charsets") |
| 287 | (string-append filters "/share/cups/charsets")) |
| 288 | |
| 289 | ;; install additional required filters |
| 290 | (("instfilter texttopdf texttopdf pdf") |
| 291 | (string-append |
| 292 | "instfilter texttopdf texttopdf pdf;" |
| 293 | "instfilter imagetoraster imagetoraster raster;" |
| 294 | "instfilter gstoraster gstoraster raster;" |
| 295 | "instfilter urftopdf urftopdf pdf;" |
| 296 | "instfilter rastertopdf rastertopdf pdf;" |
| 297 | "instfilter pstopdf pstopdf pdf")) |
| 298 | |
| 299 | ;; specify location of lpstat binary |
| 300 | (("description=\"`lpstat -l") |
| 301 | "description=\"`../systemv/lpstat -l") |
| 302 | |
| 303 | ;; patch shebangs of embedded scripts |
| 304 | (("#!/bin/sh") (string-append "#!" (which "sh"))) |
| 305 | |
| 306 | ;; also link mime definitions from cups-filters |
| 307 | ;; to enable the additional filters for the test suite |
| 308 | (("ln -s \\$root/conf/mime\\.types") |
| 309 | (string-append |
| 310 | "ln -s " filters |
| 311 | "/share/cups/mime/cupsfilters.types $BASE/share/mime; " |
| 312 | "ln -s $root/conf/mime.types")) |
| 313 | (("ln -s \\$root/conf/mime\\.convs") |
| 314 | (string-append |
| 315 | "ln -s " filters |
| 316 | "/share/cups/mime/cupsfilters.convs $BASE/share/mime; " |
| 317 | "ln -s $root/conf/mime.convs"))) |
| 318 | |
| 319 | ;; fix search path for "cat" |
| 320 | (substitute* "cups/testfile.c" |
| 321 | (("cupsFileFind\\(\"cat\", \"/bin\"") |
| 322 | (string-append "cupsFileFind(\"cat\", \"" catpath "\"")) |
| 323 | (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"") |
| 324 | (string-append "cupsFileFind(\"cat\", \"" catpath "\""))) |
| 325 | #t))) |
| 326 | ;; Make the compressed manpages writable so that the |
| 327 | ;; reset-gzip-timestamps phase does not error out. |
| 328 | (add-before 'reset-gzip-timestamps 'make-manpages-writable |
| 329 | (lambda* (#:key outputs #:allow-other-keys) |
| 330 | (let* ((out (assoc-ref outputs "out")) |
| 331 | (man (string-append out "/share/man"))) |
| 332 | (for-each (lambda (file) (chmod file #o644)) |
| 333 | (find-files man "\\.gz")) |
| 334 | #t))) |
| 335 | (add-after 'install 'install-cups-filters-symlinks |
| 336 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 337 | (let ((out (assoc-ref outputs "out")) |
| 338 | (cups-filters (assoc-ref inputs "cups-filters"))) |
| 339 | ;; charsets |
| 340 | (symlink |
| 341 | (string-append cups-filters "/share/cups/charsets") |
| 342 | (string-append out "/share/charsets")) |
| 343 | |
| 344 | ;; mime types, driver file, ppds |
| 345 | (for-each |
| 346 | (lambda (f) |
| 347 | (symlink (string-append cups-filters f) |
| 348 | (string-append out f))) |
| 349 | '("/share/cups/mime/cupsfilters.types" |
| 350 | "/share/cups/mime/cupsfilters.convs" |
| 351 | "/share/cups/drv/cupsfilters.drv" |
| 352 | "/share/ppd")) |
| 353 | |
| 354 | ;; filters |
| 355 | (for-each |
| 356 | (lambda (f) |
| 357 | (symlink f |
| 358 | (string-append out "/lib/cups/filter" (basename f)))) |
| 359 | (find-files (string-append cups-filters "/lib/cups/filter"))) |
| 360 | |
| 361 | ;; backends |
| 362 | (for-each |
| 363 | (lambda (f) |
| 364 | (symlink (string-append cups-filters f) |
| 365 | (string-append out "/lib/cups/backend/" |
| 366 | (basename f)))) |
| 367 | '("/lib/cups/backend/parallel" |
| 368 | "/lib/cups/backend/serial")) |
| 369 | |
| 370 | ;; banners |
| 371 | (let ((banners "/share/cups/banners")) |
| 372 | (delete-file-recursively (string-append out banners)) |
| 373 | (symlink (string-append cups-filters banners) |
| 374 | (string-append out banners))) |
| 375 | |
| 376 | ;; assorted data |
| 377 | (let ((data "/share/cups/data")) |
| 378 | (delete-file-recursively (string-append out data)) |
| 379 | (symlink (string-append cups-filters data) |
| 380 | (string-append out data))) |
| 381 | |
| 382 | #t)))))) |
| 383 | (inputs |
| 384 | `(("avahi" ,avahi) |
| 385 | ("gnutls" ,gnutls) |
| 386 | ("cups-filters" ,cups-filters) |
| 387 | ("zlib" ,zlib))))) |
| 388 | |
| 389 | (define-public cups-pk-helper |
| 390 | (package |
| 391 | (name "cups-pk-helper") |
| 392 | (version "0.2.6") |
| 393 | (source (origin |
| 394 | (method url-fetch) |
| 395 | (uri (string-append "https://freedesktop.org/software/" |
| 396 | name "/releases/" name "-" version ".tar.xz")) |
| 397 | (sha256 |
| 398 | (base32 |
| 399 | "0a52jw6rm7lr5nbyksiia0rn7sasyb5cjqcb95z1wxm2yprgi6lm")))) |
| 400 | (build-system gnu-build-system) |
| 401 | (native-inputs |
| 402 | `(("intltool" ,intltool) |
| 403 | ("pkg-config" ,pkg-config) |
| 404 | ("glib" ,glib) |
| 405 | ("polkit" ,polkit) |
| 406 | ("cups" ,cups))) |
| 407 | (home-page "https://www.freedesktop.org/wiki/Software/cups-pk-helper/") |
| 408 | (synopsis "PolicyKit helper to configure CUPS with fine-grained privileges") |
| 409 | (description |
| 410 | "This package provides the org.opensuse.CupsPkHelper.Mechanism DBus |
| 411 | system service which uses @file{cups-pk-helper-mechanism}. This package |
| 412 | should only be used as part of the Guix cups-pk-helper service.") |
| 413 | (license license:gpl2+))) |
| 414 | |
| 415 | (define-public hplip |
| 416 | (package |
| 417 | (name "hplip") |
| 418 | (version "3.20.6") |
| 419 | (source (origin |
| 420 | (method url-fetch) |
| 421 | (uri (string-append "mirror://sourceforge/hplip/hplip/" version |
| 422 | "/hplip-" version ".tar.gz")) |
| 423 | (sha256 |
| 424 | (base32 |
| 425 | "083w58wpvvm6sir6rf5dwx3r0rman9sv1zpl26chl0a88crjsjy6")) |
| 426 | (modules '((guix build utils))) |
| 427 | (patches (search-patches "hplip-remove-imageprocessor.patch")) |
| 428 | (snippet |
| 429 | '(begin |
| 430 | ;; Delete non-free blobs: .so files, pre-compiled |
| 431 | ;; 'locatedriver' executable, etc. |
| 432 | (for-each delete-file |
| 433 | (find-files "." |
| 434 | (lambda (file stat) |
| 435 | (elf-file? file)))) |
| 436 | (delete-file "prnt/hpcups/ImageProcessor.h") |
| 437 | |
| 438 | ;; Install binaries under libexec/hplip instead of |
| 439 | ;; share/hplip; that'll at least ensure they get stripped. |
| 440 | ;; It's not even clear that they're of any use though... |
| 441 | (substitute* "Makefile.in" |
| 442 | (("^dat2drvdir =.*") |
| 443 | "dat2drvdir = $(pkglibexecdir)\n") |
| 444 | (("^locatedriverdir =.*") |
| 445 | "locatedriverdir = $(pkglibexecdir)\n")) |
| 446 | #t)))) |
| 447 | (build-system gnu-build-system) |
| 448 | (home-page "https://developers.hp.com/hp-linux-imaging-and-printing") |
| 449 | (synopsis "HP printer drivers") |
| 450 | (description |
| 451 | "Hewlett-Packard printer drivers and PostScript Printer Descriptions |
| 452 | (@dfn{PPD}s).") |
| 453 | |
| 454 | ;; The 'COPYING' file lists directories where each of these 3 licenses |
| 455 | ;; applies. |
| 456 | (license (list license:gpl2+ license:bsd-3 license:expat)) |
| 457 | |
| 458 | ;; TODO install apparmor profile files eventually. |
| 459 | (arguments |
| 460 | `(#:configure-flags |
| 461 | `("--disable-network-build" |
| 462 | ,(string-append "--prefix=" (assoc-ref %outputs "out")) |
| 463 | ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc") |
| 464 | ,(string-append "LDFLAGS=-Wl,-rpath=" |
| 465 | (assoc-ref %outputs "out") "/lib") |
| 466 | ;; Disable until mime.types merging works (FIXME). |
| 467 | "--disable-fax-build" |
| 468 | "--enable-hpcups-install" |
| 469 | "--enable-new-hpcups" |
| 470 | "--enable-cups_ppd_install" |
| 471 | "--enable-cups_drv_install" |
| 472 | ;; TODO add foomatic drv install eventually. |
| 473 | ;; TODO --enable-policykit eventually. |
| 474 | ,(string-append "--with-cupsfilterdir=" |
| 475 | (assoc-ref %outputs "out") "/lib/cups/filter") |
| 476 | ,(string-append "--with-cupsbackenddir=" |
| 477 | (assoc-ref %outputs "out") "/lib/cups/backend") |
| 478 | ,(string-append "--with-icondir=" |
| 479 | (assoc-ref %outputs "out") "/share/applications") |
| 480 | ,(string-append "--with-systraydir=" |
| 481 | (assoc-ref %outputs "out") "/etc/xdg") |
| 482 | "--enable-qt5" "--disable-qt4") |
| 483 | |
| 484 | #:imported-modules ((guix build python-build-system) |
| 485 | ,@%gnu-build-system-modules) |
| 486 | #:modules ((guix build gnu-build-system) |
| 487 | (guix build utils) |
| 488 | ((guix build python-build-system) #:prefix python:)) |
| 489 | |
| 490 | #:phases |
| 491 | (modify-phases %standard-phases |
| 492 | (add-after 'unpack 'fix-hard-coded-file-names |
| 493 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 494 | (let ((out (assoc-ref outputs "out")) |
| 495 | ;; FIXME: use merged ppds (I think actually only |
| 496 | ;; drvs need to be merged). |
| 497 | (cupsdir (assoc-ref inputs "cups-minimal"))) |
| 498 | (substitute* "base/g.py" |
| 499 | (("'/usr/share;[^']*'") |
| 500 | (string-append "'" cupsdir "/share'")) |
| 501 | (("'/etc/hp/hplip.conf'") |
| 502 | (string-append "'" out |
| 503 | "/etc/hp/hplip.conf" "'"))) |
| 504 | |
| 505 | (substitute* "Makefile.in" |
| 506 | (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ") |
| 507 | ;; FIXME Use beginning-of-word in regexp. |
| 508 | (("[[:blank:]]plugin\\.py[[:blank:]]") " ") |
| 509 | (("/usr/include/libusb-1.0") |
| 510 | (string-append (assoc-ref inputs "libusb") |
| 511 | "/include/libusb-1.0")) |
| 512 | (("hplip_statedir =.*$") |
| 513 | ;; Don't bail out while trying to create |
| 514 | ;; /var/lib/hplip. We can safely change its value |
| 515 | ;; here because it's hard-coded in the code anyway. |
| 516 | "hplip_statedir = $(prefix)\n") |
| 517 | (("hplip_confdir = /etc/hp") |
| 518 | ;; This is only used for installing the default config. |
| 519 | (string-append "hplip_confdir = " out |
| 520 | "/etc/hp")) |
| 521 | (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor") |
| 522 | ;; We don't use hal. |
| 523 | (string-append "halpredir = " out |
| 524 | "/share/hal/fdi/preprobe/10osvendor")) |
| 525 | (("rulesdir = /etc/udev/rules.d") |
| 526 | ;; udev rules will be merged by base service. |
| 527 | (string-append "rulesdir = " out |
| 528 | "/lib/udev/rules.d")) |
| 529 | (("rulessystemdir = /usr/lib/systemd/system") |
| 530 | ;; We don't use systemd. |
| 531 | (string-append "rulessystemdir = " out |
| 532 | "/lib/systemd/system")) |
| 533 | (("/etc/sane.d") |
| 534 | (string-append out "/etc/sane.d"))) |
| 535 | #t))) |
| 536 | (add-before 'configure 'fix-build-with-python-3.8 |
| 537 | (lambda* (#:key inputs #:allow-other-keys) |
| 538 | (let ((python (assoc-ref inputs "python"))) |
| 539 | ;; XXX: The configure script of looks for Python headers in the |
| 540 | ;; wrong places as of version 3.20.3. Help it by adding the |
| 541 | ;; include directory on C_INCLUDE_PATH. |
| 542 | (when python |
| 543 | (setenv "C_INCLUDE_PATH" |
| 544 | (string-append python "/include/python" |
| 545 | (python:python-version python) |
| 546 | ":" (getenv "C_INCLUDE_PATH")))) |
| 547 | #t))) |
| 548 | (add-after 'install 'install-models-dat |
| 549 | (lambda* (#:key outputs #:allow-other-keys) |
| 550 | (let* ((out (assoc-ref outputs "out")) |
| 551 | (models-dir (string-append out |
| 552 | "/share/hplip/data/models"))) |
| 553 | (install-file "data/models/models.dat" models-dir)) |
| 554 | #t)) |
| 555 | (add-after 'install 'wrap-binaries |
| 556 | ;; Scripts in /bin are all symlinks to .py files in /share/hplip. |
| 557 | ;; Symlinks are immune to the Python build system's 'WRAP phase, |
| 558 | ;; and the .py files can't be wrapped because they are reused as |
| 559 | ;; modules. Replacing the symlinks in /bin with copies and |
| 560 | ;; wrapping them also doesn't work (“ModuleNotFoundError: |
| 561 | ;; No module named 'base'”). Behold: a custom WRAP-PROGRAM. |
| 562 | (lambda* (#:key inputs outputs #:allow-other-keys) |
| 563 | (let* ((out (assoc-ref outputs "out")) |
| 564 | (bin (string-append out "/bin")) |
| 565 | (python (assoc-ref inputs "python"))) |
| 566 | (with-directory-excursion bin |
| 567 | (for-each (lambda (file) |
| 568 | (let ((target (readlink file))) |
| 569 | (delete-file file) |
| 570 | (with-output-to-file file |
| 571 | (lambda _ |
| 572 | (format #t |
| 573 | "#!~a~@ |
| 574 | export PYTHONPATH=\"~a:~a\"~@ |
| 575 | exec -a \"$0\" \"~a/~a\" \"$@\"~%" |
| 576 | (which "bash") |
| 577 | (string-append |
| 578 | out "/lib/python" |
| 579 | (python:python-version python) |
| 580 | "/site-packages") |
| 581 | (getenv "PYTHONPATH") |
| 582 | bin target))) |
| 583 | (chmod file #o755))) |
| 584 | (find-files "." (lambda (file stat) |
| 585 | (eq? 'symlink (stat:type stat))))) |
| 586 | #t))))))) |
| 587 | |
| 588 | ;; Note that the error messages printed by the tools in the case of |
| 589 | ;; missing dependencies are often downright misleading. |
| 590 | ;; TODO: hp-toolbox still fails to start with: |
| 591 | ;; from dbus.mainloop.pyqt5 import DBusQtMainLoop |
| 592 | ;; ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5' |
| 593 | (inputs |
| 594 | `(("cups-minimal" ,cups-minimal) |
| 595 | ("dbus" ,dbus) |
| 596 | ("libjpeg" ,libjpeg-turbo) |
| 597 | ("libusb" ,libusb) |
| 598 | ("python" ,python) |
| 599 | ("python-dbus" ,python-dbus) |
| 600 | ("python-pygobject" ,python-pygobject) |
| 601 | ("python-pyqt" ,python-pyqt) |
| 602 | ("python-wrapper" ,python-wrapper) |
| 603 | ("sane-backends" ,sane-backends-minimal) |
| 604 | ("zlib" ,zlib))) |
| 605 | (native-inputs |
| 606 | `(("perl" ,perl) |
| 607 | ("pkg-config" ,pkg-config))))) |
| 608 | |
| 609 | (define-public hplip-minimal |
| 610 | (package |
| 611 | (inherit hplip) |
| 612 | (name "hplip-minimal") |
| 613 | (arguments |
| 614 | (substitute-keyword-arguments (package-arguments hplip) |
| 615 | ((#:configure-flags cf) |
| 616 | ;; Produce a "light build", meaning that only the printer (CUPS) and |
| 617 | ;; scanner (SANE) support gets built, without all the 'hp-*' |
| 618 | ;; command-line tools. |
| 619 | `(cons "--enable-lite-build" |
| 620 | (delete "--enable-qt5" ,cf))) |
| 621 | ((#:phases phases) |
| 622 | ;; The 'wrap-binaries' is not needed here since the 'hp-*' programs |
| 623 | ;; are not installed. |
| 624 | `(alist-delete 'wrap-binaries ,phases)))) |
| 625 | (inputs (remove (match-lambda |
| 626 | ((label . _) |
| 627 | (string-prefix? "python" label))) |
| 628 | (package-inputs hplip))) |
| 629 | (synopsis "GUI-less version of hplip"))) |
| 630 | |
| 631 | (define-public foomatic-filters |
| 632 | (package |
| 633 | (name "foomatic-filters") |
| 634 | (version "4.0.17") |
| 635 | (source (origin |
| 636 | (method url-fetch) |
| 637 | (uri (string-append |
| 638 | "http://www.openprinting.org/download/foomatic/" |
| 639 | "foomatic-filters-" version ".tar.gz")) |
| 640 | (sha256 |
| 641 | (base32 |
| 642 | "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2")) |
| 643 | (patches |
| 644 | (search-patches "foomatic-filters-CVE-2015-8327.patch" |
| 645 | "foomatic-filters-CVE-2015-8560.patch")))) |
| 646 | (build-system gnu-build-system) |
| 647 | (home-page |
| 648 | "https://wiki.linuxfoundation.org/openprinting/database/foomatic") |
| 649 | (native-inputs |
| 650 | `(("perl" ,perl) |
| 651 | ("pkg-config" ,pkg-config))) |
| 652 | (inputs |
| 653 | `(("dbus" ,dbus) |
| 654 | ("a2ps" ,a2ps))) |
| 655 | (arguments |
| 656 | '( ;; Specify the installation directories. |
| 657 | #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS=" |
| 658 | (assoc-ref %outputs "out") |
| 659 | "/lib/cups/backend") |
| 660 | (string-append "ac_cv_path_CUPS_FILTERS=" |
| 661 | (assoc-ref %outputs "out") |
| 662 | "/lib/cups/filter") |
| 663 | (string-append "ac_cv_path_PPR_INTERFACES=" |
| 664 | (assoc-ref %outputs "out") |
| 665 | "/lib/ppr/interfaces") |
| 666 | (string-append "ac_cv_path_PPR_LIB=" |
| 667 | (assoc-ref %outputs "out") |
| 668 | "/lib/ppr/lib") |
| 669 | |
| 670 | ;; For some reason these are misdiagnosed. |
| 671 | "ac_cv_func_malloc_0_nonnull=yes" |
| 672 | "ac_cv_func_realloc_0_nonnull=yes") |
| 673 | #:test-target "tests")) |
| 674 | (synopsis "Convert PostScript to the printer's native format") |
| 675 | (description |
| 676 | "This package contains filter scripts used by the printer spoolers to |
| 677 | convert the incoming PostScript data into the printer's native format using a |
| 678 | printer/driver specific, but spooler-independent PPD file.") |
| 679 | (license license:gpl2+))) |
| 680 | |
| 681 | (define-public foo2zjs |
| 682 | (package |
| 683 | (name "foo2zjs") |
| 684 | (version "20200610") |
| 685 | (source (origin |
| 686 | (method url-fetch) |
| 687 | ;; XXX: This is an unversioned URL! |
| 688 | (uri "http://foo2zjs.rkkda.com/foo2zjs.tar.gz") |
| 689 | (sha256 |
| 690 | (base32 |
| 691 | "11ddx6wf8b5ksl4fqw6fnyz9m3y470lryyrskkya2bsch2bvj9lg")))) |
| 692 | (build-system gnu-build-system) |
| 693 | (arguments |
| 694 | '(#:phases (modify-phases %standard-phases |
| 695 | (replace 'configure |
| 696 | (lambda* (#:key outputs #:allow-other-keys) |
| 697 | (substitute* (find-files "." "^Makefile$") |
| 698 | ;; Set the installation directory. |
| 699 | (("^PREFIX[[:blank:]]*=.*$") |
| 700 | (string-append "PREFIX = " |
| 701 | (assoc-ref outputs "out") |
| 702 | "\n")) |
| 703 | (("^UDEVBIN[[:blank:]]*=.*$") |
| 704 | "UDEVBIN = $(PREFIX)/bin\n") |
| 705 | ;; Don't try to chown/chgrp the installed files. |
| 706 | (("-oroot") |
| 707 | "") |
| 708 | (("-glp") |
| 709 | "") |
| 710 | ;; Placate the dependency checks. |
| 711 | (("/usr/include/stdio.h") |
| 712 | "/etc/passwd") |
| 713 | (("/usr/") |
| 714 | "$(PREFIX)/") |
| 715 | ;; Ensure fixed timestamps in man pages. |
| 716 | (("^MODTIME[[:blank:]]*=.*$") |
| 717 | "MODTIME = echo Thu Jan 01 01:00:00 1970\n")) |
| 718 | #t)) |
| 719 | (add-after 'install 'remove-pdf |
| 720 | (lambda* (#:key outputs #:allow-other-keys) |
| 721 | ;; Remove 'manual.pdf' which is (1) useless (it's a |
| 722 | ;; concatenation of man pages), and (2) not |
| 723 | ;; bit-reproducible due to <https://bugs.gnu.org/27593>. |
| 724 | (let ((out (assoc-ref outputs "out"))) |
| 725 | (for-each delete-file |
| 726 | (find-files out "^manual\\.pdf$")) |
| 727 | #t)))) |
| 728 | #:parallel-build? #f ;broken makefile |
| 729 | #:tests? #f ;no tests |
| 730 | #:make-flags '("CC=gcc"))) |
| 731 | (inputs |
| 732 | `(("ghostscript" ,ghostscript) |
| 733 | ("foomatic-filters" ,foomatic-filters))) ;for 'foomatic-rip' |
| 734 | (native-inputs |
| 735 | `(("bc" ,bc) |
| 736 | ("groff" ,groff))) |
| 737 | (home-page "http://foo2zjs.rkkda.com/") |
| 738 | (synopsis "Printer driver for ZjStream-based printers") |
| 739 | (description |
| 740 | "foo2zjs is a printer driver for printers that use the Zenographics |
| 741 | ZjStream wire protocol for their print data, often erroneously referred to as |
| 742 | winprinters or GDI printers. |
| 743 | |
| 744 | It supports Minolta/QMS@tie{}Magicolor, Minolta@tie{}Color@tie{}PageWorks/Pro, |
| 745 | HP@tie{}LaserJet, and possibly other printers. See @file{README} for details.") |
| 746 | (license (list license:expat ; icc2ps/*.[ch] |
| 747 | license:gpl2+)))) ; everything else |
| 748 | |
| 749 | (define-public escpr |
| 750 | (package |
| 751 | (name "escpr") |
| 752 | (version "1.6.30") |
| 753 | ;; XXX: This currently works. But it will break as soon as a newer |
| 754 | ;; version is available since the URLs for older versions are not |
| 755 | ;; preserved. An alternative source will be added as soon as |
| 756 | ;; available. |
| 757 | (source (origin |
| 758 | (method url-fetch) |
| 759 | ;; The uri has to be chopped up in order to satisfy guix lint. |
| 760 | (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/08/18/20/" |
| 761 | "e94de600e28e510c1cfa158929d8b2c0aadc8aa0/" |
| 762 | "epson-inkjet-printer-escpr-1.6.30-1lsb3.2.tar.gz")) |
| 763 | (sha256 |
| 764 | (base32 |
| 765 | "0m8pyfkixisp0vclwxj340isn15zzisal0v2xvv66kxfd68dzf12")))) |
| 766 | (build-system gnu-build-system) |
| 767 | (arguments |
| 768 | `(#:configure-flags |
| 769 | `(,(string-append "--prefix=" |
| 770 | (assoc-ref %outputs "out")) |
| 771 | ,(string-append "--with-cupsfilterdir=" |
| 772 | (assoc-ref %outputs "out") "/lib/cups/filter") |
| 773 | ,(string-append "--with-cupsppddir=" |
| 774 | (assoc-ref %outputs "out") "/share/ppd")))) |
| 775 | (inputs `(("cups" ,cups-minimal))) |
| 776 | (synopsis "ESC/P-R printer driver") |
| 777 | (description |
| 778 | "This package provides a filter for the Common UNIX Printing |
| 779 | System (CUPS). It offers high-quality printing with Seiko Epson color ink jet |
| 780 | printers. It can only be used with printers that support the Epson ESC/P-R |
| 781 | language.") |
| 782 | (home-page "http://download.ebz.epson.net/dsc/search/01/search") |
| 783 | (license license:gpl2+))) |
| 784 | |
| 785 | (define-public splix |
| 786 | ;; The last release was in 2009. The SVN repository contains 5 years of |
| 787 | ;; unreleased bug fixes and support for newer printer models. |
| 788 | (let ((revision 315)) |
| 789 | (package |
| 790 | (name "splix") |
| 791 | (version (string-append "2.0.0-" (number->string revision))) |
| 792 | (source |
| 793 | (origin |
| 794 | (method svn-fetch) |
| 795 | (uri (svn-reference |
| 796 | (url "https://svn.code.sf.net/p/splix/code/splix/") |
| 797 | (revision revision))) |
| 798 | (file-name (string-append name "-" version "-checkout")) |
| 799 | (sha256 |
| 800 | (base32 "16wbm4xnz35ca3mw2iggf5f4jaxpyna718ia190ka6y4ah932jxl")))) |
| 801 | (build-system gnu-build-system) |
| 802 | ;; 90% (3.8 MiB) of output are .ppd files. Don't install them by default: |
| 803 | ;; CUPS has been able to read the .drv sources directly since version 1.2. |
| 804 | (outputs (list "out" "ppd")) |
| 805 | (arguments |
| 806 | '(#:make-flags |
| 807 | (list (string-append "CUPSDRV=" |
| 808 | (assoc-ref %outputs "out") "/share/cups/drv") |
| 809 | (string-append "CUPSFILTER=" |
| 810 | (assoc-ref %outputs "out") "/lib/cups/filter") |
| 811 | (string-append "CUPSPPD=" |
| 812 | (assoc-ref %outputs "ppd") "/share/cups/model") |
| 813 | "CACHESIZE=100" ; pages in RAM, ±300 KiB each |
| 814 | "THREADS=4") ; compress and print faster |
| 815 | #:phases |
| 816 | (modify-phases %standard-phases |
| 817 | (delete 'configure) ; no configure script |
| 818 | (add-before 'build 'build-.drv-files |
| 819 | (lambda* (#:key make-flags #:allow-other-keys) |
| 820 | (apply invoke "make" "drv" make-flags))) |
| 821 | (add-after 'install 'install-.drv-files |
| 822 | (lambda* (#:key make-flags #:allow-other-keys) |
| 823 | (apply invoke "make" "install" "DRV_ONLY=1" make-flags)))) |
| 824 | #:tests? #f)) ; no test suite |
| 825 | (inputs |
| 826 | `(("cups" ,cups-minimal) |
| 827 | ("zlib" ,zlib) |
| 828 | |
| 829 | ;; This dependency can be dropped by setting DISABLE_JBIG=1, but the |
| 830 | ;; result will not support some printers like the Samsung CLP-600. |
| 831 | ("jbigkit" ,jbigkit))) |
| 832 | (synopsis "QPDL (SPL2) printer driver") |
| 833 | (description |
| 834 | "SpliX is a set of CUPS drivers for printers that speak @acronym{QPDL, |
| 835 | Quick Page Description Language}, also called @acronym{SPL2, Samsung Printer |
| 836 | Language version 2}. These include many laser printers sold by Samsung, |
| 837 | Xerox, Lexmark, Toshiba, and Dell. |
| 838 | |
| 839 | Colour printers need colour profile files to get better results. These |
| 840 | @file{cms} files are provided by the printer's manufacturer and must be |
| 841 | obtained and installed separately.") |
| 842 | (home-page "http://splix.ap2c.org/") |
| 843 | (license license:gpl2)))) |
| 844 | |
| 845 | (define-public python-pycups |
| 846 | (package |
| 847 | (name "python-pycups") |
| 848 | (version "1.9.74") |
| 849 | (source |
| 850 | (origin |
| 851 | (method url-fetch) |
| 852 | (uri (pypi-uri "pycups" version ".tar.bz2")) |
| 853 | (sha256 |
| 854 | (base32 |
| 855 | "1ffp7sswhdsfpy88zg0cc8kl04wygkjs01rlm9f0spbwk8jhy2c6")))) |
| 856 | (build-system python-build-system) |
| 857 | (arguments |
| 858 | '(;; Tests require CUPS to be running |
| 859 | #:tests? #f)) |
| 860 | (inputs |
| 861 | `(("cups" ,cups))) |
| 862 | (home-page "https://github.com/zdohnal/pycups") |
| 863 | (synopsis "Python bindings for libcups") |
| 864 | (description |
| 865 | "This package provides Python bindings for libcups, wrapping the CUPS |
| 866 | API.") |
| 867 | (license license:gpl2+))) |