mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
gnu: hplip: Actually wrap binaries.
* gnu/packages/cups.scm (hplip)[arguments]: Reduce indentation. Replace ‘wrap-binaries’ phase with a custom implementation.
This commit is contained in:
parent
119d6ff6a9
commit
fbaa66ac2d
1 changed files with 76 additions and 47 deletions
|
@ -491,54 +491,83 @@ (define-public hplip
|
||||||
(guix build utils)
|
(guix build utils)
|
||||||
((guix build python-build-system) #:prefix python:))
|
((guix build python-build-system) #:prefix python:))
|
||||||
|
|
||||||
#:phases (modify-phases %standard-phases
|
#:phases
|
||||||
(add-after 'unpack 'fix-hard-coded-file-names
|
(modify-phases %standard-phases
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
(add-after 'unpack 'fix-hard-coded-file-names
|
||||||
(let ((out (assoc-ref outputs "out"))
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
;; FIXME: use merged ppds (I think actually only
|
(let ((out (assoc-ref outputs "out"))
|
||||||
;; drvs need to be merged).
|
;; FIXME: use merged ppds (I think actually only
|
||||||
(cupsdir (assoc-ref inputs "cups-minimal")))
|
;; drvs need to be merged).
|
||||||
(substitute* "base/g.py"
|
(cupsdir (assoc-ref inputs "cups-minimal")))
|
||||||
(("'/usr/share;[^']*'")
|
(substitute* "base/g.py"
|
||||||
(string-append "'" cupsdir "/share'"))
|
(("'/usr/share;[^']*'")
|
||||||
(("'/etc/hp/hplip.conf'")
|
(string-append "'" cupsdir "/share'"))
|
||||||
(string-append "'" out
|
(("'/etc/hp/hplip.conf'")
|
||||||
"/etc/hp/hplip.conf" "'")))
|
(string-append "'" out
|
||||||
|
"/etc/hp/hplip.conf" "'")))
|
||||||
|
|
||||||
(substitute* "Makefile.in"
|
(substitute* "Makefile.in"
|
||||||
(("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
|
(("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
|
||||||
;; FIXME Use beginning-of-word in regexp.
|
;; FIXME Use beginning-of-word in regexp.
|
||||||
(("[[:blank:]]plugin\\.py[[:blank:]]") " ")
|
(("[[:blank:]]plugin\\.py[[:blank:]]") " ")
|
||||||
(("/usr/include/libusb-1.0")
|
(("/usr/include/libusb-1.0")
|
||||||
(string-append (assoc-ref inputs "libusb")
|
(string-append (assoc-ref inputs "libusb")
|
||||||
"/include/libusb-1.0"))
|
"/include/libusb-1.0"))
|
||||||
(("hplip_statedir =.*$")
|
(("hplip_statedir =.*$")
|
||||||
;; Don't bail out while trying to create
|
;; Don't bail out while trying to create
|
||||||
;; /var/lib/hplip. We can safely change its value
|
;; /var/lib/hplip. We can safely change its value
|
||||||
;; here because it's hard-coded in the code anyway.
|
;; here because it's hard-coded in the code anyway.
|
||||||
"hplip_statedir = $(prefix)\n")
|
"hplip_statedir = $(prefix)\n")
|
||||||
(("hplip_confdir = /etc/hp")
|
(("hplip_confdir = /etc/hp")
|
||||||
;; This is only used for installing the default config.
|
;; This is only used for installing the default config.
|
||||||
(string-append "hplip_confdir = " out
|
(string-append "hplip_confdir = " out
|
||||||
"/etc/hp"))
|
"/etc/hp"))
|
||||||
(("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
|
(("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
|
||||||
;; We don't use hal.
|
;; We don't use hal.
|
||||||
(string-append "halpredir = " out
|
(string-append "halpredir = " out
|
||||||
"/share/hal/fdi/preprobe/10osvendor"))
|
"/share/hal/fdi/preprobe/10osvendor"))
|
||||||
(("rulesdir = /etc/udev/rules.d")
|
(("rulesdir = /etc/udev/rules.d")
|
||||||
;; udev rules will be merged by base service.
|
;; udev rules will be merged by base service.
|
||||||
(string-append "rulesdir = " out
|
(string-append "rulesdir = " out
|
||||||
"/lib/udev/rules.d"))
|
"/lib/udev/rules.d"))
|
||||||
(("rulessystemdir = /usr/lib/systemd/system")
|
(("rulessystemdir = /usr/lib/systemd/system")
|
||||||
;; We don't use systemd.
|
;; We don't use systemd.
|
||||||
(string-append "rulessystemdir = " out
|
(string-append "rulessystemdir = " out
|
||||||
"/lib/systemd/system"))
|
"/lib/systemd/system"))
|
||||||
(("/etc/sane.d")
|
(("/etc/sane.d")
|
||||||
(string-append out "/etc/sane.d"))))))
|
(string-append out "/etc/sane.d"))))))
|
||||||
|
(add-after 'install 'wrap-binaries
|
||||||
;; Wrap bin/* so that the Python libraries are found.
|
;; Scripts in /bin are all symlinks to .py files in /share/hplip.
|
||||||
(add-after 'install 'wrap-binaries
|
;; Symlinks are immune to the Python build system's 'WRAP phase,
|
||||||
(assoc-ref python:%standard-phases 'wrap)))))
|
;; and the .py files can't be wrapped because they are reused as
|
||||||
|
;; modules. Replacing the symlinks in /bin with copies and
|
||||||
|
;; wrapping them also doesn't work (“ModuleNotFoundError:
|
||||||
|
;; No module named 'base'”). Behold: a custom WRAP-PROGRAM.
|
||||||
|
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||||
|
(let* ((out (assoc-ref outputs "out"))
|
||||||
|
(bin (string-append out "/bin"))
|
||||||
|
(python (assoc-ref inputs "python")))
|
||||||
|
(with-directory-excursion bin
|
||||||
|
(for-each (lambda (file)
|
||||||
|
(let ((target (readlink file)))
|
||||||
|
(delete-file file)
|
||||||
|
(with-output-to-file file
|
||||||
|
(lambda _
|
||||||
|
(format #t
|
||||||
|
"#!~a~@
|
||||||
|
export PYTHONPATH=\"~a:~a\"~@
|
||||||
|
exec -a \"$0\" \"~a/~a\" \"$@\"~%"
|
||||||
|
(which "bash")
|
||||||
|
(string-append
|
||||||
|
out "/lib/python"
|
||||||
|
(python:python-version python)
|
||||||
|
"/site-packages")
|
||||||
|
(getenv "PYTHONPATH")
|
||||||
|
bin target)))
|
||||||
|
(chmod file #o755)))
|
||||||
|
(find-files "." (lambda (file stat)
|
||||||
|
(eq? 'symlink (stat:type stat)))))
|
||||||
|
#t)))))))
|
||||||
|
|
||||||
;; Note that the error messages printed by the tools in the case of
|
;; Note that the error messages printed by the tools in the case of
|
||||||
;; missing dependencies are often downright misleading.
|
;; missing dependencies are often downright misleading.
|
||||||
|
|
Loading…
Reference in a new issue