GNU bug report logs -
#58250
guix import json: GUIX_PACKAGE_PATH -- no code for module
Previous Next
Full log
Message #8 received at 58250 <at> debbugs.gnu.org (full text, mbox):
* guix/modules.scm (file-name->module-name): Ignore load path prefix
when building module name.
---
It was mentioned on IRC, that (guix modules)'s file-name->module-name
might be function to be used by the JSON importer (and fixed if needed).
This patch attempts to implement the idea from the bug report.
guix/modules.scm | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/guix/modules.scm b/guix/modules.scm
index 61bc8e1978..269d52ae1e 100644
--- a/guix/modules.scm
+++ b/guix/modules.scm
@@ -100,11 +100,23 @@ (define module-file-dependencies
'()))))))
(define file-name->module-name
- (let ((not-slash (char-set-complement (char-set #\/))))
+ (let ((not-slash (char-set-complement (char-set #\/)))
+ (load-path-prefix-length
+ (lambda (file)
+ ;; Length of the longest prefix among all given load paths.
+ (apply max (map
+ (lambda (path) (if (string-prefix? path file)
+ (string-length path)
+ 0))
+ %load-path)))))
(lambda (file)
"Return the module name (a list of symbols) corresponding to FILE."
(map string->symbol
- (string-tokenize (string-drop-right file 4) not-slash)))))
+ (string-tokenize
+ (string-drop
+ (string-drop-right file 4)
+ (load-path-prefix-length file))
+ not-slash)))))
(define (module-name->file-name module)
"Return the file name for MODULE."
base-commit: ae221813745783ef1b7eee47561a2208cd5ad512
--
2.37.3
This bug report was last modified 2 years and 173 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.