Subject: Re: [bug#28974] [PATCH 1/1] gnu: syslinux: Propagate mtools as syslinux needs it at runtime.

From: [email-masked] (Ludovic Courtès)
Date: Wed, 25 Oct 2017 22:09:22 -0700

Hi Adam,

Adam Van Ymeren <[email-masked]> skribis:

> When trying to install syslinux to a FAT partition, it requires the
> mtools (particularly mcopy) to be available at runtime in PATH.

[...]

> +      (propagated-inputs
> +         `(("mtools" ,mtools)))

A quick inspection showed uses of “mcopy” and “mattrib”.  To avoid
propagating mtools, I propose the patch below.

Could you check if it works for you?

Thank you,
Ludo’.

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 613537a5d..b4372748c 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -236,7 +236,8 @@ menu to select one of the installed operating systems.")
          ("perl" ,perl)
          ("python-2" ,python-2)))
       (inputs
-       `(("libuuid" ,util-linux)))
+       `(("libuuid" ,util-linux)
+         ("mtools" ,mtools)))
       (arguments
        `(#:parallel-build? #f
          #:make-flags
@@ -251,11 +252,17 @@ menu to select one of the installed operating systems.")
          #:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'patch-files
-             (lambda _
+             (lambda* (#:key inputs #:allow-other-keys)
                (substitute* (find-files "." "Makefile.*|ppmtolss16")
                  (("/bin/pwd") (which "pwd"))
                  (("/bin/echo") (which "echo"))
                  (("/usr/bin/perl") (which "perl")))
+               (let ((mtools (assoc-ref inputs "mtools")))
+                 (substitute* (find-files "." "\\.c$")
+                   (("mcopy")
+                    (string-append mtools "/bin/mcopy"))
+                   (("mattrib")
+                    (string-append mtools "/bin/mattrib"))))
                #t))
            (delete 'configure)
            (add-before 'build 'set-permissions