Subject: [bug#37654] [PATCH] gnu-build-system: Don't try executing directories in bootstrap phase.

From: Brendan Tildesley <[email-masked]>
Date: Tue, 8 Oct 2019 14:39:05 +1100

I just made this after discovering a source repo with a bootstrap
directory. Naturally it results in just about everything being rebuilt,
so it would a long time to fully test it, and I'm no experienced schemer
so I can't be sure this is the right way to add in this change. Feel
free to rewrite it a better way.
>From 3a602cccbd8711f40f6b981e5616289a5fdd0b56 Mon Sep 17 00:00:00 2001
From: Brendan Tildesley <[email-masked]>
Date: Tue, 8 Oct 2019 02:55:03 +1100
Subject: [PATCH] gnu-build-system: Don't try executing directories in
 bootstrap phase.

* guix/build/gnu-build-system.scm: (bootstrap): Change the file-exists?
procedure to one that excludes directories, so that we do not mistake it for a
script. For example if the source includes a bootstrap/ directory.
---
 guix/build/gnu-build-system.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index e5f3197b0a..6b4e74721b 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -177,12 +177,16 @@ working directory."
 \"autoreconf\".  Otherwise do nothing."
   ;; Note: Run that right after 'unpack' so that the generated files are
   ;; visible when the 'patch-source-shebangs' phase runs.
-  (if (not (file-exists? "configure"))
+  (define (script-exists? file)
+    (and (file-exists? file)
+         (not (file-is-directory? file))))
+
+  (if (not (script-exists? "configure"))
 
       ;; First try one of the BOOTSTRAP-SCRIPTS.  If none exists, and it's
       ;; clearly an Autoconf-based project, run 'autoreconf'.  Otherwise, do
       ;; nothing (perhaps the user removed or overrode the 'configure' phase.)
-      (let ((script (find file-exists? bootstrap-scripts)))
+      (let ((script (find script-exists? bootstrap-scripts)))
         ;; GNU packages often invoke the 'git-version-gen' script from
         ;; 'configure.ac' so make sure it has a valid shebang.
         (false-if-file-not-found
-- 
2.23.0