From a7b1cc333eedcfb8630fe98bfac43bf8ad86b962 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sat, 11 Jul 2020 15:03:48 -0400 Subject: [PATCH] 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 5df1126c3adf557f3a5b386e391e7cb56b9c1d63. * 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 ...'. --- guix/build/ruby-build-system.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm index c957a61115..8a421c1e15 100644 --- a/guix/build/ruby-build-system.scm +++ b/guix/build/ruby-build-system.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015 David Thompson ;;; Copyright © 2015 Pjotr Prins ;;; Copyright © 2015, 2016 Ben Woodcroft +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -73,13 +74,19 @@ (define (first-gemspec) (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)