me
/
guix
Archived
1
0
Fork 0

packages: 'package-field-location' handles 'search-path' returning #f.

Fixes <https://bugs.gnu.org/46390>.
Reported by zimoun <zimon.toutoune@gmail.com>.

This is similar to the fix in d10474c38d.

* guix/packages.scm (package-field-location): Handle FILE not in %LOAD-PATH.
* tests/guix-lint.sh: Add test.
master
Ludovic Courtès 2021-02-22 10:52:21 +01:00
parent 03235402df
commit 9a38bed2cf
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 33 additions and 23 deletions

View File

@ -475,29 +475,34 @@ object."
(match (package-location package) (match (package-location package)
(($ <location> file line column) (($ <location> file line column)
(catch 'system-error (match (search-path %load-path file)
(lambda () ((? string? file)
;; In general we want to keep relative file names for modules. (catch 'system-error
(call-with-input-file (search-path %load-path file) (lambda ()
(lambda (port) ;; In general we want to keep relative file names for modules.
(goto port line column) (call-with-input-file file
(match (read port) (lambda (port)
(('package inits ...) (goto port line column)
(let ((field (assoc field inits))) (match (read port)
(match field (('package inits ...)
((_ value) (let ((field (assoc field inits)))
(let ((loc (and=> (source-properties value) (match field
source-properties->location))) ((_ value)
(and loc (let ((loc (and=> (source-properties value)
;; Preserve the original file name, which may be a source-properties->location)))
;; relative file name. (and loc
(set-field loc (location-file) file)))) ;; Preserve the original file name, which may be a
(_ ;; relative file name.
#f)))) (set-field loc (location-file) file))))
(_ (_
#f))))) #f))))
(lambda _ (_
#f))) #f)))))
(lambda _
#f)))
(#f
;; FILE could not be found in %LOAD-PATH.
#f)))
(_ #f))) (_ #f)))

View File

@ -90,3 +90,8 @@ guix lint -L $module_dir -c inputs-should-be-native dummy dummy@42 dummy
# that it does find it anyway. See <https://bugs.gnu.org/42543>. # that it does find it anyway. See <https://bugs.gnu.org/42543>.
(cd "$module_dir"/.. ; guix lint -c formatting -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out" (cd "$module_dir"/.. ; guix lint -c formatting -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out"
test -z "$(cat "$module_dir/out")" test -z "$(cat "$module_dir/out")"
# Likewise, when there's a warning, 'package-field-location' used to crash
# because it can't find "t-xyz/foo.scm". See <https://bugs.gnu.org/46390>.
(cd "$module_dir"/.. ; guix lint -c synopsis -L "$(basename "$module_dir")" dummy@42) 2>&1 > "$module_dir/out"
grep_warning "`cat "$module_dir/out"`"