gnu: clipmenu: Improve the package definition

* gnu/packages/xdisorg.scm (clipmenu): Add the package's unit-tests to the
check phase.  Wrap the program so the PATH contains all dependencies. The
previous approach to patch the script was incomplete and more complex.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Damien Cassou 2020-03-21 17:33:39 +01:00 committed by Ludovic Courtès
parent fb2709ef98
commit f5e0634431
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -74,6 +74,7 @@ (define-module (gnu packages xdisorg)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages flex)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gawk)
#:use-module (gnu packages gettext)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
@ -2188,21 +2189,6 @@ (define-public clipmenu
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'fix-hardcoded-paths
(lambda _
(substitute* "clipmenud"
(("has_clipnotify=0")
"has_clipnotify=1")
(("command -v clipnotify >/dev/null 2>&1 && has_clipnotify=1")
"")
(("clipnotify \\|\\| .*")
(string-append (which "clipnotify") "\n"))
(("xsel --logfile")
(string-append (which "xsel") " --logfile")))
(substitute* "clipmenu"
(("xsel --logfile")
(string-append (which "xsel") " --logfile")))
#t))
(delete 'configure)
(delete 'build)
(replace 'install
@ -2215,10 +2201,42 @@ (define-public clipmenu
(install-file "clipmenu" bin)
(install-file "clipmenud" bin)
(install-file "README.md" doc)
#t))))
#:tests? #f))
#t)))
(add-after 'install 'wrap-script
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(clipnotify (assoc-ref inputs "clipnotify"))
(coreutils-minimal (assoc-ref inputs "coreutils-minimal"))
(gawk (assoc-ref inputs "gawk"))
(util-linux (assoc-ref inputs "util-linux"))
(xdotool (assoc-ref inputs "xdotool"))
(xsel (assoc-ref inputs "xsel")))
(for-each
(lambda (prog)
(wrap-script (string-append out "/bin/" prog)
`("PATH" ":" prefix
,(map (lambda (dir)
(string-append dir "/bin"))
(list clipnotify coreutils-minimal
gawk util-linux xdotool xsel)))))
'("clipmenu" "clipmenud" "clipdel")))
#t))
(replace 'check
(lambda* (#:key inputs outputs #:allow-other-keys)
;; substitute a shebang appearing inside a string (the test
;; file writes this string to a temporary file):
(substitute* "tests/test-clipmenu"
(("#!/usr/bin/env bash")
(string-append "#!" (which "bash"))))
(invoke "tests/test-clipmenu")
#t)))))
(inputs
`(("clipnotify" ,clipnotify)
("coreutils-minimal" ,coreutils-minimal)
("gawk" ,gawk)
("guile" ,guile-3.0) ; for wrap-script
("util-linux" ,util-linux)
("xdotool" ,xdotool)
("xsel" ,xsel)))
(home-page "https://github.com/cdown/clipmenu")
(synopsis "Simple clipboard manager using dmenu or rofi and xsel")