2022-12-19 17:17:39 +01:00
|
|
|
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
2021-10-03 10:33:28 +02:00
|
|
|
;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
|
|
|
|
;;; Copyright © 2021 Kahka F
|
|
|
|
;;; Copyright © 2021 Jonathan Brielmaier <jonathan.brielmaier@web.de>
|
|
|
|
|
|
|
|
(define-module (nongnu packages printers)
|
|
|
|
#:use-module (gnu packages)
|
|
|
|
#:use-module (gnu packages cups)
|
2023-05-12 14:43:39 +02:00
|
|
|
#:use-module (guix gexp)
|
2021-10-03 10:33:28 +02:00
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix utils)
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
#:use-module (guix download)
|
|
|
|
#:use-module (guix build utils))
|
|
|
|
|
|
|
|
(define-public hplip-plugin
|
|
|
|
(package
|
2023-05-12 14:40:06 +02:00
|
|
|
(inherit hplip)
|
|
|
|
(name "hplip-plugin")
|
|
|
|
(description "Hewlett-Packard printer drivers with nonfree plugin.")
|
|
|
|
(source (origin
|
|
|
|
(inherit (package-source hplip))
|
|
|
|
(snippet
|
|
|
|
(delete '(for-each
|
|
|
|
delete-file
|
|
|
|
(find-files "." (lambda (file stat)
|
|
|
|
(elf-file? file))))
|
|
|
|
(origin-snippet (package-source hplip))))))
|
|
|
|
(inputs (alist-delete "python-pyqt" (package-inputs hplip)))
|
|
|
|
(native-inputs
|
|
|
|
(append
|
|
|
|
`(("hplip-plugin"
|
|
|
|
,(origin
|
|
|
|
(method url-fetch)
|
|
|
|
(uri (string-append "https://developers.hp.com/sites/default/files/hplip-"
|
|
|
|
(package-version hplip) "-plugin.run"))
|
|
|
|
(sha256
|
|
|
|
(base32
|
|
|
|
"100zyvmqlp71v8691s9wfzrllqq8aaqj9a4pki36gqs1bn4429h3")))))
|
|
|
|
(package-native-inputs hplip)))
|
|
|
|
(arguments
|
|
|
|
(substitute-keyword-arguments (package-arguments hplip)
|
|
|
|
((#:configure-flags cf)
|
2023-05-12 14:43:39 +02:00
|
|
|
#~(delete "--enable-qt5" #$cf))
|
2023-05-12 14:40:06 +02:00
|
|
|
((#:phases ph)
|
2023-05-12 14:43:39 +02:00
|
|
|
#~(modify-phases #$ph
|
2023-05-12 14:40:06 +02:00
|
|
|
(replace 'fix-hard-coded-file-names
|
|
|
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
|
|
|
(let ((out (assoc-ref outputs "out"))
|
|
|
|
;; FIXME: use merged ppds (I think actually only
|
|
|
|
;; drvs need to be merged).
|
|
|
|
(cupsdir (assoc-ref inputs "cups-minimal")))
|
|
|
|
(substitute* "base/g.py"
|
|
|
|
(("'/usr/share;[^']*'")
|
|
|
|
(string-append "'" cupsdir "/share'"))
|
|
|
|
(("'/etc/hp/hplip.conf'")
|
|
|
|
(string-append "'" out
|
|
|
|
"/etc/hp/hplip.conf" "'"))
|
|
|
|
(("/var/lib/hp")
|
|
|
|
(string-append
|
|
|
|
out
|
|
|
|
"/var/lib/hp")))
|
2021-10-03 10:33:28 +02:00
|
|
|
|
2023-05-12 14:40:06 +02:00
|
|
|
(substitute* "Makefile.in"
|
|
|
|
(("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
|
|
|
|
;; FIXME Use beginning-of-word in regexp.
|
|
|
|
(("[[:blank:]]plugin\\.py[[:blank:]]") " ")
|
|
|
|
(("/usr/include/libusb-1.0")
|
|
|
|
(string-append (assoc-ref inputs "libusb")
|
|
|
|
"/include/libusb-1.0"))
|
|
|
|
(("hplip_statedir =.*$")
|
|
|
|
;; Don't bail out while trying to create
|
|
|
|
;; /var/lib/hplip. We can safely change its value
|
|
|
|
;; here because it's hard-coded in the code anyway.
|
|
|
|
"hplip_statedir = $(prefix)/var/lib/hp\n")
|
|
|
|
(("hplip_confdir = /etc/hp")
|
|
|
|
;; This is only used for installing the default config.
|
|
|
|
(string-append "hplip_confdir = " out
|
|
|
|
"/etc/hp"))
|
|
|
|
(("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
|
|
|
|
;; We don't use hal.
|
|
|
|
(string-append "halpredir = " out
|
|
|
|
"/share/hal/fdi/preprobe/10osvendor"))
|
|
|
|
(("rulesdir = /etc/udev/rules.d")
|
|
|
|
;; udev rules will be merged by base service.
|
|
|
|
(string-append "rulesdir = " out
|
|
|
|
"/lib/udev/rules.d"))
|
|
|
|
(("rulessystemdir = /usr/lib/systemd/system")
|
|
|
|
;; We don't use systemd.
|
|
|
|
(string-append "rulessystemdir = " out
|
|
|
|
"/lib/systemd/system"))
|
|
|
|
(("/etc/sane.d")
|
|
|
|
(string-append out "/etc/sane.d")))
|
2021-10-03 10:33:28 +02:00
|
|
|
|
2023-05-12 14:40:06 +02:00
|
|
|
(substitute* "common/utils.h"
|
|
|
|
(("/var/lib/hp")
|
|
|
|
(string-append
|
|
|
|
out
|
|
|
|
"/var/lib/hp"))))))
|
|
|
|
(add-after 'install-models-dat 'install-plugins
|
|
|
|
(lambda* (#:key outputs system inputs #:allow-other-keys)
|
|
|
|
(let* ((out (assoc-ref outputs "out"))
|
|
|
|
(state-dir (string-append out "/var/lib/hp"))
|
|
|
|
(hp-arch (assoc-ref
|
|
|
|
'(("i686-linux" . "x86_32")
|
|
|
|
("x86_64-linux" . "x86_64")
|
|
|
|
("armhf-linux" . "arm32")
|
|
|
|
("aarch64-linux" . "aarch64"))
|
|
|
|
system)))
|
|
|
|
(unless hp-arch
|
|
|
|
(error (string-append
|
|
|
|
"HPLIP plugin not supported on "
|
|
|
|
system)))
|
|
|
|
(invoke "sh" (assoc-ref inputs "hplip-plugin")
|
|
|
|
"--noexec" "--keep")
|
|
|
|
(chdir "plugin_tmp")
|
|
|
|
(install-file "plugin.spec"
|
|
|
|
(string-append out "/share/hplip/"))
|
2021-10-03 10:33:28 +02:00
|
|
|
|
2023-05-12 14:40:06 +02:00
|
|
|
(for-each
|
|
|
|
(lambda (file)
|
|
|
|
(install-file
|
|
|
|
file
|
|
|
|
(string-append out "/share/hplip/data/firmware")))
|
|
|
|
(find-files "." "\\.fw.gz$"))
|
2021-10-03 10:33:28 +02:00
|
|
|
|
2023-05-12 14:40:06 +02:00
|
|
|
(install-file "license.txt"
|
|
|
|
(string-append out "/share/hplip/data/plugins"))
|
|
|
|
(mkdir-p
|
|
|
|
(string-append out "/share/hplip/prnt/plugins"))
|
|
|
|
(for-each
|
|
|
|
(lambda (type plugins)
|
|
|
|
(for-each
|
|
|
|
(lambda (plugin)
|
|
|
|
(let ((file (string-append plugin "-" hp-arch ".so"))
|
|
|
|
(dir (string-append out "/share/hplip/"
|
|
|
|
type "/plugins")))
|
|
|
|
(install-file file dir)
|
|
|
|
(chmod (string-append dir "/" file) #o755)
|
|
|
|
(symlink (string-append dir "/" file)
|
|
|
|
(string-append dir "/" plugin ".so"))))
|
|
|
|
plugins))
|
|
|
|
'("prnt" "scan")
|
|
|
|
'(("lj" "hbpl1")
|
|
|
|
("bb_soap" "bb_marvell" "bb_soapht" "bb_escl")))
|
|
|
|
(mkdir-p state-dir)
|
|
|
|
(call-with-output-file
|
|
|
|
(string-append state-dir "/hplip.state")
|
|
|
|
(lambda (port)
|
|
|
|
(simple-format port "[plugin]
|
2021-10-03 10:33:28 +02:00
|
|
|
installed=1
|
|
|
|
eula=1
|
|
|
|
version=~A
|
2023-05-12 14:43:39 +02:00
|
|
|
" #$(package-version hplip))))
|
2021-10-03 10:33:28 +02:00
|
|
|
|
2023-05-12 14:40:06 +02:00
|
|
|
(substitute* (string-append out "/etc/hp/hplip.conf")
|
|
|
|
(("/usr") out)))))))))))
|