Archived
1
0
Fork 0

gnu: quilt: Fix wrapping and improve testing.

* gnu/packages/patchutils.scm (quilt)[native-inputs]: Use new style; fixes
lint warning.
[inputs]: Add bash-minimal, gzip, diffutils, findutils, and tar.
[arguments]: Move check phase after other install.  Simplify wrapping and wrap
one utility script.  Run tests with PATH unset and test scripts patched to
detect insufficient wrapping.
This commit is contained in:
Eric Bavier 2023-05-02 10:56:55 -05:00
parent 4082bdf98e
commit 83f4640fdf
No known key found for this signature in database
GPG key ID: BC45CA67E2F8D007

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2018 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014, 2018, 2023 Eric Bavier <bavier@posteo.net>
;;; Copyright © 2015, 2018 Leo Famulari <leo@famulari.name> ;;; Copyright © 2015, 2018 Leo Famulari <leo@famulari.name>
;;; Copyright © 20182022 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 20182022 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Christopher Baines <mail@cbaines.net> ;;; Copyright © 2019 Christopher Baines <mail@cbaines.net>
@ -39,6 +39,7 @@
#:use-module (gnu packages base) #:use-module (gnu packages base)
#:use-module (gnu packages bash) #:use-module (gnu packages bash)
#:use-module (gnu packages check) #:use-module (gnu packages check)
#:use-module (gnu packages compression)
#:use-module (gnu packages databases) #:use-module (gnu packages databases)
#:use-module (gnu packages django) #:use-module (gnu packages django)
#:use-module (gnu packages freedesktop) #:use-module (gnu packages freedesktop)
@ -122,43 +123,64 @@ listing the files modified by a patch.")
(patches (search-patches "quilt-grep-compat.patch")))) (patches (search-patches "quilt-grep-compat.patch"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(native-inputs (native-inputs
`(("gettext" ,gettext-minimal))) (list gettext-minimal))
(inputs (list perl less file ed diffstat)) (inputs
(list bash-minimal perl less file gzip ed
diffutils diffstat findutils tar))
(arguments (arguments
'(#:parallel-tests? #f '(#:parallel-tests? #f
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-before 'check 'patch-tests (delete 'check)
(lambda _
(substitute*
'("test/run"
"test/edit.test")
(("/bin/sh") (which "sh")))
#t))
(add-after 'install 'wrap-program (add-after 'install 'wrap-program
;; quilt's configure checks for the absolute path to the utilities it ;; 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 ;; needs, but uses only the name when invoking them, so we need to
;; make sure the quilt script can find those utilities when run. ;; make sure the quilt script can find those utilities when run.
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let ((cmd-path (lambda (cmd) (dirname (which cmd))))
(coreutils (assoc-ref inputs "coreutils")) (out (assoc-ref outputs "out")))
(diffutils (assoc-ref inputs "diffutils"))
(findutils (assoc-ref inputs "findutils"))
(diffstat (assoc-ref inputs "diffstat"))
(less (assoc-ref inputs "less"))
(file (assoc-ref inputs "file"))
(ed (assoc-ref inputs "ed"))
(sed (assoc-ref inputs "sed"))
(bash (assoc-ref inputs "bash"))
(grep (assoc-ref inputs "grep")))
(wrap-program (string-append out "/bin/quilt") (wrap-program (string-append out "/bin/quilt")
`("PATH" ":" prefix `("PATH" ":" prefix
,(map (lambda (dir) ,(map cmd-path
(string-append dir "/bin")) (list "bash" "diff" "diffstat" "ed" "file" "find" "grep"
(list coreutils diffutils findutils "gzip" "less" "patch" "perl" "rm" "sed" "tar"))))
less file ed sed bash grep (wrap-program (string-append out "/share/quilt/scripts/backup-files")
diffstat))))) `("PATH" ":" prefix
#t))))) ,(map cmd-path
(list "find" "grep" "mkdir")))))))
(add-after 'compress-documentation 'check
(lambda _
(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/") (home-page "https://savannah.nongnu.org/projects/quilt/")
(synopsis "Script for managing patches to software") (synopsis "Script for managing patches to software")
(description (description