Subject: [bug#39102] [PATCH v2 1/2] gnu: xdg-utils: Don't use propagated inputs.

From: Marius Bakke <[email-masked]>
Date: Sun, 12 Jan 2020 20:29:59 +0100

Jakub Kądziołka <[email-masked]> writes:

> Sending a revision to the first patch after feedback on IRC. Changes:
>  - Remove the `string-prefix? "PATH:"' hack, list the packages
>    explicitly.
>  - Use cute to make the code easier to read.
>
> ---
> * gnu/packages/freedesktop.scm (xdg-utils)
>   [propagated-inputs, inputs]: Add awk, coreutils, grep and sed, make
>   the dependencies not propagated.
>   [arguments](patch-hardcoded-paths): Move to after 'install to make
>   wrap-program function correctly. Wrap the installed programs.

FYI: The stray '---' here made git disregard the actual commit message,
and instead only added the four lines above.  The other way around would
be perfect.  :-)

I've applied this patch, with the changes below (leaving the original
patch-hardcoded-paths phase intact, renaming the new phase accordingly;
and added a let binding for "out").

I'll address the Qt patch in a separate message.

diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 9e1bf730d2..ed221439b4 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -122,29 +122,15 @@
     (arguments
      `(#:tests? #f   ; no check target
        #:modules ((srfi srfi-26)
-                  (guix build utils)
-                  (guix build gnu-build-system))
+                  ,@%gnu-build-system-modules)
        #:phases
        (modify-phases %standard-phases
-         (add-after 'install 'patch-hardcoded-paths
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (with-directory-excursion (string-append (assoc-ref outputs "out")
-                                                      "/bin")
-               (substitute* "xdg-mime"
-                 (("/usr/bin/file") (which "file")))
-               (substitute* "xdg-open"
-                 (("/usr/bin/printf") (which "printf")))
-               (let ((path-ext
-                       (map (cute string-append <> "/bin")
-                            (cons (assoc-ref outputs "out")
-                                  (map (cute assoc-ref inputs <>)
-                                       '("awk" "coreutils" "grep" "inetutils"
-                                         "perl-file-mimeinfo" "sed" "xprop"
-                                         "xset"))))))
-                 (for-each
-                   (cute wrap-program <>
-                        `("PATH" ":" prefix ,path-ext))
-                   (find-files "."))))
+         (add-after 'unpack 'patch-hardcoded-paths
+           (lambda _
+             (substitute* "scripts/xdg-mime.in"
+               (("/usr/bin/file") (which "file")))
+             (substitute* "scripts/xdg-open.in"
+               (("/usr/bin/printf") (which "printf")))
              #t))
          (add-before 'build 'locate-catalog-files
            (lambda* (#:key inputs #:allow-other-keys)
@@ -168,6 +154,21 @@
                                  "/manpages/docbook.xsl man")))
                (setenv "STYLESHEET"
                        (string-append xsldoc "/html/docbook.xsl"))
+               #t)))
+         (add-after 'install 'wrap-executables
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (with-directory-excursion (string-append out "/bin")
+                 (let ((path-ext
+                        (map (cute string-append <> "/bin")
+                             (cons out
+                                   (map (cute assoc-ref inputs <>)
+                                        '("awk" "coreutils" "grep" "inetutils"
+                                          "perl-file-mimeinfo" "sed" "xprop"
+                                          "xset"))))))
+                   (for-each (cute wrap-program <>
+                                   `("PATH" ":" prefix ,path-ext))
+                             (find-files "."))))
                #t))))))
     (home-page "https://www.freedesktop.org/wiki/Software/xdg-utils/")
     (synopsis "Freedesktop.org scripts for desktop integration")