Subject: Re: [bug#56119] [PATCH] gnu: Add phoronix-test-suite.
From: Maxim Cournoyer <[email-masked]>
To: Maxime Devos <[email-masked]>
Cc: [email-masked]
Date: Wed, 22 Jun 2022 10:46:23 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Maxime.

Maxime Devos <[email-masked]> writes:

> Maxim Cournoyer schreef op di 21-06-2022 om 01:20 [-0400]:
>> +                (wrap-program pts
>> +                  (list "PATH" 'prefix
>> +                        (list (string-append #$(this-package-input "bash")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "coreutils")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "gzip")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "make")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "php")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "sed")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "tar")
>> +                                             "/bin")
>> +                              (string-append #$(this-package-input "which")
>> +                                             "/bin"))))))))))
>
> Can be simplified and delabelified (untested):
>
> (list "PATH" 'prefix
>       (map (lambda (binary)
>              (search-input-file inputs (string-append "bin/" binary)))
>            '("bash" "tar" "which" "cat" "gzip" [...])))
>
> (Only looked at the phases)

Thanks.  That's indeed better.  I added the 'dirname' call to get the
bin directory and not the binaries themselves, as this is for PATH:

--8<---------------cut here---------------start------------->8---
modified   gnu/packages/benchmark.scm
@@ -294,26 +294,15 @@ (define-public phoronix-test-suite
             (lambda _
               (invoke "./install-sh" #$output "--free-software-only")))
           (add-after 'install 'wrap-binary
-            (lambda _
+            (lambda* (#:key inputs #:allow-other-keys)
               (let ((pts (string-append #$output "/bin/phoronix-test-suite")))
                 (wrap-program pts
                   (list "PATH" 'prefix
-                        (list (string-append #$(this-package-input "bash")
-                                             "/bin")
-                              (string-append #$(this-package-input "coreutils")
-                                             "/bin")
-                              (string-append #$(this-package-input "gzip")
-                                             "/bin")
-                              (string-append #$(this-package-input "make")
-                                             "/bin")
-                              (string-append #$(this-package-input "php")
-                                             "/bin")
-                              (string-append #$(this-package-input "sed")
-                                             "/bin")
-                              (string-append #$(this-package-input "tar")
-                                             "/bin")
-                              (string-append #$(this-package-input "which")
-                                             "/bin"))))))))))
+                        (map (lambda (binary)
+                               (dirname (search-input-file
+                                         inputs (string-append "bin/" binary))))
+                             '("bash" "cat" ;coreutils
+                               "gzip" "make" "php" "sed" "tar" "which"))))))))))
     (build-system gnu-build-system)
     (native-inputs (list python which))
     ;; Wrap the most basic build tools needed by Phoronix Test Suite to
     build
--8<---------------cut here---------------end--------------->8---

I've now gone ahead and pushed it with the above change.  With more
usage, I expect we'll probably want to capture a few more tools in the
wrap phase, such as de-compressors; we'll see.

Thanks for the comments!

Maxim