Subject: [bug#42146] [PATCH 5/?] build-system/gnu: Allow lack of matches in substitution phases.

From: Jakub Kądziołka <[email-masked]>
Date: Wed, 1 Jul 2020 02:42:42 +0200

* guix/build/utils.scm (patch-makefile-SHELL, patch-/usr/bin/file),
  guix/build/gnu-build-system.scm (patch-dot-desktop-files):
  Allow lack of matches in substitute*.
---
 guix/build/gnu-build-system.scm | 3 ++-
 guix/build/utils.scm            | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 2e7dff2034..4b96761233 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2018 Mark H Weaver <[email-masked]>
 ;;; Copyright © 2020 Brendan Tildesley <[email-masked]>
+;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -724,7 +725,7 @@ which cannot be found~%"
                      ;; '.desktop' files contain translations and are always
                      ;; UTF-8-encoded.
                      (with-fluids ((%default-port-encoding "UTF-8"))
-                       (substitute* files
+                       (substitute* files #:require-matches? #f
                          (("^Exec=([^/[:blank:]\r\n]*)(.*)$" _ binary rest)
                           (string-append "Exec=" (which binary) rest))
                          (("^TryExec=([^/[:blank:]\r\n]*)(.*)$" _ binary rest)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 1bfb774c60..a8218a7743 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -1005,7 +1005,7 @@ When KEEP-MTIME? is true, the atime/mtime of FILE are kept unchanged."
   (let ((st (stat file)))
     ;; Consider FILE is using an 8-bit encoding to avoid errors.
     (with-fluids ((%default-port-encoding #f))
-      (substitute* file
+      (substitute* file #:require-matches? #f
         (("^ *SHELL[[:blank:]]*:?=[[:blank:]]*([[:graph:]]*/)([[:graph:]]+)(.*)$"
           _ dir shell args)
          (let* ((old (string-append dir shell))
@@ -1033,7 +1033,7 @@ no replacement 'file' command, doing nothing~%")
       (let ((st (stat file)))
         ;; Consider FILE is using an 8-bit encoding to avoid errors.
         (with-fluids ((%default-port-encoding #f))
-          (substitute* file
+          (substitute* file #:require-matches? #f
             (("/usr/bin/file")
              (begin
                (format (current-error-port)
-- 
2.26.2