build: ruby-build-system: Adjust replace-git-ls-files.

The file names returned by `find ...` instead of `git ls-files...` contains
leading './' characters, which can cause problems when the file lists is
further processed with regexps, for example, as was discovered while updating
the ruby-asciidoctor package in commit
5df1126c3a.

* guix/build/ruby-build-system.scm (replace-git-ls-files): Strip the first two
characters ("./") of the file names returned by the 'find' command.  Fix typo
in doc.  Simplify '(when (not ...' into '(unless ...'.
This commit is contained in:
Maxim Cournoyer 2020-07-11 15:03:48 -04:00
parent 15e7167405
commit a7b1cc333e
No known key found for this signature in database
GPG Key ID: 1260E46482E63562

View File

@ -2,6 +2,7 @@
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2015 Pjotr Prins <pjotr.public01@thebird.nl>
;;; Copyright © 2015, 2016 Ben Woodcroft <donttrustben@gmail.com>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@ -73,13 +74,19 @@ directory."
(define* (replace-git-ls-files #:key source #:allow-other-keys)
"Many gemspec files downloaded from outside rubygems.org use `git ls-files`
to list of the files to be included in the built gem. However, since this
to list the files to be included in the built gem. However, since this
operation is not deterministic, we replace it with `find`."
(when (not (gem-archive? source))
(unless (gem-archive? source)
(let ((gemspec (first-gemspec)))
;; Do not include the freshly built .gem itself as it causes problems.
;; Strip the first 2 characters ("./") to more exactly match the output
;; given by 'git ls-files'. This is useful to prevent breaking regexps
;; that could be used to filter the list of files.
(substitute* gemspec
(("`git ls-files`") "`find . -type f |sort`")
(("`git ls-files -z`") "`find . -type f -print0 |sort -z`"))))
(("`git ls-files`")
"`find . -type f -not -regex '.*\\.gem$' | sort | cut -c3-`")
(("`git ls-files -z`")
"`find . -type f -not -regex '.*\\.gem$' -print0 | sort -z | cut -zc3-`"))))
#t)
(define* (extract-gemspec #:key source #:allow-other-keys)