summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-05-06 23:17:47 +0200
committerLudovic Courtès <ludo@gnu.org>2020-05-07 10:06:15 +0200
commitff3ca7979ebf03cc79022b69fcd693221550a69f (patch)
tree1b835f7618f71db04026c4a765cddf92a558f49c
parent053b10c3ef2df7ea80556ab9b2c93d0bf88094f2 (diff)
downloadguix-ff3ca7979ebf03cc79022b69fcd693221550a69f.tar.gz
channels: Add patch for <https://bugs.gnu.org/41028>.
Without this patch, we couldn't jump from here to commits before
05e783871c2c69b402e088863d46f5be7915ac74 because the
'compute-guix-derivation' script would crash with an unbound-variable
error for 'call-with-new-thread'.

Fixes <https://bugs.gnu.org/41028>.
Reported by Christopher Baines <mail@cbaines.net>.

* guix/channels.scm (%bug-41028-patch): New variable.
(%patches): Add it.
-rw-r--r--guix/channels.scm27
1 files changed, 26 insertions, 1 deletions
diff --git a/guix/channels.scm b/guix/channels.scm
index 75b53c3a8e..0fa036446c 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -38,6 +38,7 @@
                 #:select (source-properties->location
                           &error-location
                           &fix-hint))
+  #:use-module ((guix build utils) #:select (substitute*))
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
   #:use-module (srfi srfi-9)
@@ -375,11 +376,35 @@ to '%package-module-path'."
   ;; <https://bugs.gnu.org/37506>
   `((,syscalls-reexports-local-variables? . ,guile-2.2.4)))
 
+
+(define %bug-41028-patch
+  ;; Patch for <https://bugs.gnu.org/41028>.  The faulty code is the
+  ;; 'compute-guix-derivation' body, which uses 'call-with-new-thread' without
+  ;; importing (ice-9 threads).  However, the 'call-with-new-thread' binding
+  ;; is no longer available in the default name space on Guile 3.0.
+  (let ()
+    (define (missing-ice-9-threads-import? source commit)
+      ;; Return true if %SELF-BUILD-FILE is missing an (ice-9 threads) import.
+      (define content
+        (call-with-input-file (string-append source "/" %self-build-file)
+          read-string))
+
+      (and (string-contains content "(call-with-new-thread")
+           (not (string-contains content "(ice-9 threads)"))))
+
+    (define (add-missing-ice-9-threads-import source)
+      ;; Add (ice-9 threads) import in the gexp of 'compute-guix-derivation'.
+      (substitute* (string-append source "/" %self-build-file)
+        (("^ +\\(use-modules \\(ice-9 match\\)\\)")
+         (object->string '(use-modules (ice-9 match) (ice-9 threads))))))
+
+   (patch missing-ice-9-threads-import? add-missing-ice-9-threads-import)))
+
 (define %patches
   ;; Bits of past Guix revisions can become incompatible with newer Guix and
   ;; Guile.  This variable lists <patch> records for the Guix source tree that
   ;; apply to the Guix source.
-  '())
+  (list %bug-41028-patch))
 
 (define* (guile-for-source source #:optional (quirks %quirks))
   "Return the Guile package to use when building SOURCE or #f if the default