Subject: Re: bug#59073: [PATCH] gnu: r-minimal: Avoid referencing /gnu/store/[^-]+-glibc-[^-]+-static.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 08 Nov 2022 14:09:55 +0100

Hi,

Christopher Baines <[email-masked]> skribis:

>   → guix build --target=aarch64-linux-gnu r-minimal
>   guix build: error: path ‘/gnu/store/[^-]+-glibc-[^-]+-static’ is not valid

Interesting bug!

I pushed a fix and explanation:

--8<---------------cut here---------------start------------->8---
commit 3bd4b92f55f40119349e39902a9b800de98040d2

    build-system/gnu: Turn #:phases into a gexp when cross-compiling.
    
    Previously, we'd get this error:
    
      $ guix build --target=aarch64-linux-gnu r-minimal -d --no-grafts
      guix build: error: path ‘/gnu/store/[^-]+-glibc-[^-]+-static’ is not valid
    
    This is because the sexp would be passed as an input of the surrounding
    gexp in 'gnu-cross-build', and thus
    "/gnu/store/[^-]+-glibc-[^-]+-static" would be interpreted as a source
    file name, as in this example:
    
      scheme@(guix gexp)> #~(foo #$(list 'whatever "/gnu/store/[^-]+-glibc-[^-]+-static"))
      $11 = #<gexp (foo #<gexp-input (whatever "/gnu/store/[^-]+-glibc-[^-]+-static"):out>) 7f098badec30>
      scheme@(guix gexp)> (gexp-inputs $11)
      $12 = (#<gexp-input "/gnu/store/[^-]+-glibc-[^-]+-static":out>)
    
    Fixes <https://issues.guix.gnu.org/59073>.
    Reported by Christopher Baines <[email-masked]>.
    
    * guix/build-system/gnu.scm (gnu-cross-build): When PHASES is a pair,
    pass it through 'sexp->gexp'.
--8<---------------cut here---------------end--------------->8---

That said, this code is bogus:

  1. We should refrain from using non-literal strings as patterns in
     ‘substitute*’.

  2. We should call ‘%store-directory’ from (guix build utils) instead
     of hardcoding “/gnu/store”.

Both of these should be fixed at some point.

Thanks,
Ludo’.