summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-03-25 22:41:05 +0100
committerLudovic Courtès <ludo@gnu.org>2021-03-26 00:04:04 +0100
commit96aa98b6ca78ffb798e309acac3c3e5068422f30 (patch)
tree2ace70e6285c4736daeab76fe89d1d54a7dcd13c
parent4ac3e010c9cbd9c09d41dbf472e45d57505a73ce (diff)
downloadguix-96aa98b6ca78ffb798e309acac3c3e5068422f30.tar.gz
import: print: Improve origin method name guesswork.
Fixes <https://bugs.gnu.org/47375>.
Reported by Léo Le Bouter <lle-bout@zaclys.net>.

* guix/import/print.scm (package->code): For METHOD, use 'variable-name'
preferably, and call 'procedure-name' as a last resort.
-rw-r--r--guix/import/print.scm11
1 files changed, 10 insertions, 1 deletions
diff --git a/guix/import/print.scm b/guix/import/print.scm
index a2ab810a5c..dcc38abc70 100644
--- a/guix/import/print.scm
+++ b/guix/import/print.scm
@@ -79,7 +79,16 @@ when evaluated."
           (file-name (origin-file-name source))
           (patches   (origin-patches source)))
       `(origin
-         (method ,(procedure-name method))
+         ;; Since 'procedure-name' returns the procedure name within the
+         ;; module where it's defined, not its public name.  Thus, try hard to
+         ;; find its public name and use 'procedure-name' as a last resort.
+         (method ,(or (any (lambda (module)
+                             (variable-name method module))
+                           '((guix download)
+                             (guix git-download)
+                             (guix hg-download)
+                             (guix svn-download)))
+                      (procedure-name method)))
          (uri (string-append ,@(match (factorize-uri uri version)
                                  ((? string? uri) (list uri))
                                  (factorized factorized))))