diff mbox series

[bug#40168]

Message ID 87imixr67y.fsf@cassou.me
State Accepted
Headers show
Series [bug#40168] | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job

Commit Message

Damien Cassou March 21, 2020, 5:02 p.m. UTC
Hi,

I've improved the packaging for clipmenu in
gnu/packages/xdisorg.scm. Please give feedback.

I found that my usage of wrap-script is very verbose. Is there a simpler
way?

Thank you

Damien Cassou (3):
  * gnu/packages/xdisorg.scm (clipmenu): Re-indent
  * gnu/packages/xdisorg.scm (clipnotify): Add a comment
  gnu: clipmenu: Improve the package definition

 gnu/packages/xdisorg.scm | 125 ++++++++++++++++++++++-----------------
 1 file changed, 72 insertions(+), 53 deletions(-)
diff mbox series

Patch

From 391ad6deec073b7e01984fd81a44a5cac52afc5b Mon Sep 17 00:00:00 2001
From: Damien Cassou <damien@cassou.me>
Date: Sat, 21 Mar 2020 17:33:39 +0100
Subject: [PATCH 3/3] 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.
---
 gnu/packages/xdisorg.scm | 52 +++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 17 deletions(-)

diff --git a/gnu/packages/xdisorg.scm b/gnu/packages/xdisorg.scm
index 21165f384f..f7c4668bf8 100644
--- a/gnu/packages/xdisorg.scm
+++ b/gnu/packages/xdisorg.scm
@@ -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")
+                  (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")
-- 
2.25.1