diff mbox series

[bug#47336] Disarchive as a fallback for downloads

Message ID 874kfpo7is.fsf@gnu.org
State Accepted
Headers show
Series [bug#47336] Disarchive as a fallback for downloads | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès April 29, 2021, 7:48 a.m. UTC
Hi!

Timothy Sample <samplet@ngyro.com> skribis:

> And broke “guix pull”!!  (I somehow fooled myself into thinking that I
> had already tested with “guix pull --url=...” locally.)  I reverted the
> offending commit.

You can test with ‘guix pull’ (you need to make sure to specify the
right file:// URL *and* branch), or you can run “make as-derivation”.

> It turns out that adding a reference from “(guix build download)” to
> “(guix swh)” breaks “compute-guix-derivation” in
> “build-aux/build-self.scm”.  This is because “(guix swh)” references
> “(json)”, which is not available in the “compute-guix-derivation”
> environment.  I tried mimicking the “fake-git” trick, but it didn’t work
> (I guess it needs the “define-json-mapping” macro at compile time).
>
> Everything works if I remove the #:autoload for “(guix swh)” and put
>
>   ;; If we import (guix swh) directly, we introduce a compile-time
>   ;; dependency on Guile-JSON.  This breaks the "build-self" code, which
>   ;; needs to build this module without Guile-JSON.  Hence, we track
>   ;; down the following procedure at runtime.
>   (define swh-download-directory
>     (module-ref (resolve-module '(guix swh)) 'swh-download-directory))
>
> inside of “disarchive-fetch/any” (just before it’s needed).  Does this
> approach look okay?

That’s one possibility.

The patch below takes another approach.  I think it aesthetically
slightly more pleasant because we don’t have to play ‘resolve-module’
tricks for obscure reasons.  WDYT?

(It also fixes a format string argument mismatch.)

Thanks!

Ludo’.

Comments

Timothy Sample April 29, 2021, 5:24 p.m. UTC | #1
Hello,

Ludovic Courtès <ludo@gnu.org> writes:

> Timothy Sample <samplet@ngyro.com> skribis:
>
>> And broke “guix pull”!!  (I somehow fooled myself into thinking that I
>> had already tested with “guix pull --url=...” locally.)  I reverted the
>> offending commit.
>
> You can test with ‘guix pull’ (you need to make sure to specify the
> right file:// URL *and* branch), or you can run “make as-derivation”.

I will definitely be more careful with this in the future.

>> [...]  Does this approach look okay?
>
> That’s one possibility.
>
> The patch below takes another approach.  I think it aesthetically
> slightly more pleasant because we don’t have to play ‘resolve-module’
> tricks for obscure reasons.  WDYT?

This is exactly what I was hoping for, but I couldn’t quite connect all
the dots in “build-self.scm”.  Thanks!

> (It also fixes a format string argument mismatch.)

Good catch!

I’ve pushed the updated patch and am closing the issue.  :)


-- Tim
diff mbox series

Patch

diff --git a/build-aux/build-self.scm b/build-aux/build-self.scm
index 853a2f328f..f100ff4aae 100644
--- a/build-aux/build-self.scm
+++ b/build-aux/build-self.scm
@@ -250,6 +250,7 @@  interface (FFI) of Guile.")
     (match-lambda
       (('guix 'config) #f)
       (('guix 'channels) #f)
+      (('guix 'build 'download) #f)             ;autoloaded by (guix download)
       (('guix _ ...)   #t)
       (('gnu _ ...)    #t)
       (_               #f)))
diff --git a/guix/build/download.scm b/guix/build/download.scm
index 5431d7c682..ce31038b05 100644
--- a/guix/build/download.scm
+++ b/guix/build/download.scm
@@ -650,7 +650,7 @@  and write the output to FILE."
            (('swhid swhid)
             (match (string-split swhid #\:)
               (("swh" "1" "dir" id)
-               (format #t "Downloading from Software Heritage...~%" file)
+               (format #t "Downloading ~a from Software Heritage...~%" file)
                (false-if-exception*
                 (swh-download-directory id output)))
               (_ #f)))
diff --git a/guix/self.scm b/guix/self.scm
index 3154d180ac..7181205610 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -878,7 +878,8 @@  itself."
                    ("guix/store/schema.sql"
                     ,(local-file "../guix/store/schema.sql")))
 
-                 #:extensions (list guile-gcrypt)
+                 #:extensions (list guile-gcrypt
+                                    guile-json)   ;for (guix swh)
                  #:guile-for-build guile-for-build))
 
   (define *extra-modules*