[bug#76594,v2,2/5] gnu: quilt: Use gexps.

Message ID CH3PR84MB3424EFDE0BBFC36F1584133DC5B02@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
State New
Headers
Series [bug#76594,v2,1/5] gnu: quilt: Respect #:tests? key in check phase. |

Commit Message

Morgan Smith April 13, 2025, 2:57 p.m. UTC
  * gnu/packages/patchutils.scm (quilt): Use gexps.

Change-Id: I81373365d0729b90b3e31e122eaede2daa7ae5cb
---
 gnu/packages/patchutils.scm | 113 ++++++++++++++++++------------------
 1 file changed, 58 insertions(+), 55 deletions(-)
  

Patch

diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
index 8ba227a3d3..07f1d671ed 100644
--- a/gnu/packages/patchutils.scm
+++ b/gnu/packages/patchutils.scm
@@ -52,6 +52,7 @@  (define-module (gnu packages patchutils)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages groff)
   #:use-module (gnu packages gtk)
+  #:use-module (gnu packages guile)
   #:use-module (gnu packages less)
   #:use-module (gnu packages mail)
   #:use-module (gnu packages text-editors)
@@ -182,62 +183,64 @@  (define-public quilt
      (list gettext-minimal))
     (inputs
      (list bash-minimal perl less file gzip ed
-           diffutils diffstat findutils tar))
+           diffutils diffstat findutils tar
+           ;; for wrap-script
+           guile-3.0))
     (arguments
-     '(#:parallel-tests? #f
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'check)
-         (add-after 'install 'wrap-program
-           ;; quilt's configure checks for the absolute path to the utilities it
-           ;; needs, but uses only the name when invoking them, so we need to
-           ;; make sure the quilt script can find those utilities when run.
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let ((cmd-path (lambda (cmd) (dirname (which cmd))))
-                   (out      (assoc-ref outputs "out")))
-               (wrap-program (string-append out "/bin/quilt")
-                 `("PATH" ":" prefix
-                   ,(map cmd-path
-                         (list "bash" "diff" "diffstat" "ed" "file" "find" "grep"
-                               "gzip" "less" "patch" "perl" "rm" "sed" "tar"))))
-               (wrap-program (string-append out "/share/quilt/scripts/backup-files")
-                 `("PATH" ":" prefix
-                   ,(map cmd-path
-                         (list "find" "grep" "mkdir")))))))
-         (add-after 'compress-documentation 'check
-           (lambda* (#:key tests? #:allow-other-keys)
-             (when tests?
-               (substitute* '("test/run" "test/edit.test")
-                 (("/bin/sh") (which "sh"))
-                 (("rm -rf") (string-append (which "rm") " -rf")))
-               (substitute* "Makefile"
-                 (("^(PATH|QUILT_DIR).*" &)
-                  (string-append "#" &)) ; Test the installed 'quilt'
-                 (("export QUILT_DIR") "export")
-                 (("\\| sort") (string-append "| " (which "sort")))
-                 (("\\| sed") (string-append "| " (which "sed")))
-                 (("(chmod|touch)" &) (which &)))
-               ;; Tests are scripts interpreted by `test/run` and may specify
-               ;; the execution of several tools.  But PATH will be empty, so
-               ;; rewrite with the full file name:
-               (setenv "PATH" (string-append %output "/bin" ":" (getenv "PATH")))
-               (substitute* (find-files "test" "\\.test$")
-                 (("([\\$\\|] )([[:graph:]]+)([[:blank:]\n]+)"
-                   & > cmd <)
-                  (if (string=? cmd "zcat")
-                      ;; The `zcat` program is a script, and it will not be able
-                      ;; to invoke its `gzip` with PATH unset.  It's a simple
-                      ;; script though, so just translate here:
-                      (string-append > (which "gzip") " -cd " <)
-                      (or (and=> (which cmd)
-                                 (lambda (p) (string-append > p <)))
-                          &))))
-               (let ((make (which "make")))
-                 ;; Assert the installed 'quilt' can find utilities it needs.
-                 (unsetenv "PATH")
-                 ;; Used by some tests for access to internal "scripts"
-                 (setenv "QUILT_DIR" (string-append %output "/share/quilt"))
-                 (invoke make "check"))))))))
+     (list
+      #:parallel-tests? #f
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'check)
+          (add-after 'install 'wrap-script
+            ;; quilt's configure checks for the absolute path to the utilities it
+            ;; needs, but uses only the name when invoking them, so we need to
+            ;; make sure the quilt script can find those utilities when run.
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((cmd-path (lambda (cmd) (dirname (which cmd)))))
+                (wrap-script (string-append #$output "/bin/quilt")
+                  `("PATH" ":" prefix
+                    ,(map cmd-path
+                          (list "bash" "diff" "diffstat" "ed" "file" "find" "grep"
+                                "gzip" "less" "patch" "perl" "rm" "sed" "tar"))))
+                (wrap-script (string-append #$output "/share/quilt/scripts/backup-files")
+                  `("PATH" ":" prefix
+                    ,(map cmd-path
+                          (list "find" "grep" "mkdir")))))))
+          (add-after 'compress-documentation 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (substitute* '("test/run" "test/edit.test")
+                  (("/bin/sh") (which "sh"))
+                  (("rm -rf") (string-append (which "rm") " -rf")))
+                (substitute* "Makefile"
+                  (("^(PATH|QUILT_DIR).*" &)
+                   (string-append "#" &)) ; Test the installed 'quilt'
+                  (("export QUILT_DIR") "export")
+                  (("\\| sort") (string-append "| " (which "sort")))
+                  (("\\| sed") (string-append "| " (which "sed")))
+                  (("(chmod|touch)" &) (which &)))
+                ;; Tests are scripts interpreted by `test/run` and may specify
+                ;; the execution of several tools.  But PATH will be empty, so
+                ;; rewrite with the full file name:
+                (setenv "PATH" (string-append #$output "/bin" ":" (getenv "PATH")))
+                (substitute* (find-files "test" "\\.test$")
+                  (("([\\$\\|] )([[:graph:]]+)([[:blank:]\n]+)"
+                    & > cmd <)
+                   (if (string=? cmd "zcat")
+                       ;; The `zcat` program is a script, and it will not be able
+                       ;; to invoke its `gzip` with PATH unset.  It's a simple
+                       ;; script though, so just translate here:
+                       (string-append > (which "gzip") " -cd " <)
+                       (or (and=> (which cmd)
+                                  (lambda (p) (string-append > p <)))
+                           &))))
+                (let ((make (which "make")))
+                  ;; Assert the installed 'quilt' can find utilities it needs.
+                  (unsetenv "PATH")
+                  ;; Used by some tests for access to internal "scripts"
+                  (setenv "QUILT_DIR" (string-append #$output "/share/quilt"))
+                  (invoke make "check"))))))))
     (home-page "https://savannah.nongnu.org/projects/quilt/")
     (synopsis "Script for managing patches to software")
     (description