Subject: bug#44835: gnu/ci.go: Embeds build path, breaking reproducible builds

From: Ludovic Courtès <[email-masked]>
Date: Thu, 26 Nov 2020 22:39:08 +0100

Hi!

Vagrant Cascadian <[email-masked]> skribis:

> My *wild* guess is it maybe has something to do with the use of
> canonicalize-path:
>
>   (define (find-current-checkout arguments)
>   "Find the first checkout of ARGUMENTS that provided the current file.
> Return #f if no such checkout is found."
>   (let ((current-root
>          (canonicalize-path
>           (string-append (dirname (current-filename)) "/.."))))
>     (find (lambda (argument)
>             (and=> (assq-ref argument 'file-name)
>                    (lambda (name)
>                      (string=? name current-root)))) arguments)))

‘canonicalize-path’ is called at run time, so that’s fine.  However,
‘current-filename’ is a macro that captures the source file name at
build time, so it’s the likely culprit here.

I was going to go with something like:

diff --git a/gnu/ci.scm b/gnu/ci.scm
index 5548d9560e..0bacfbe025 100644
--- a/gnu/ci.scm
+++ b/gnu/ci.scm
@@ -488,7 +488,8 @@ valid."
 Return #f if no such checkout is found."
   (let ((current-root
          (canonicalize-path
-          (string-append (dirname (current-filename)) "/.."))))
+          (string-append (dirname (search-path %load-path "gnu/ci.scm"))
+                         "/.."))))
     (find (lambda (argument)
             (and=> (assq-ref argument 'file-name)
                    (lambda (name)

… but I don’t think we can assume that the checkout is in the
‘%load-path’ when this code is executed.  WDYT, Mathieu?

Looking at f71b0a0012d46bd30ead1a14ed58fd59647415e2, which introduced
this, there might be other options too.

Thanks,
Ludo’.