packages: Remove duplicates from package cache.
Previously the same package could appear several times if several variables were bound to it, as is notably the case for "python" currently. This, in turn, would lead to obnoxious "ambiguous package specification" messages. * gnu/packages.scm (generate-package-cache)[expand-cache]: Change RESULT to RESULT+SEEN and adjust accordingly. Call 'first' on the result of 'fold-module-public-variables*'. * tests/packages.scm ("fold-available-packages with/without cache"): Check for lack of duplicates in FROM-CACHE.
This commit is contained in:
parent
ba48895899
commit
36754eee28
|
@ -371,34 +371,41 @@ reducing the memory footprint."
|
||||||
(define cache-file
|
(define cache-file
|
||||||
(string-append directory %package-cache-file))
|
(string-append directory %package-cache-file))
|
||||||
|
|
||||||
(define (expand-cache module symbol variable result)
|
(define (expand-cache module symbol variable result+seen)
|
||||||
(match (false-if-exception (variable-ref variable))
|
(match (false-if-exception (variable-ref variable))
|
||||||
((? package? package)
|
((? package? package)
|
||||||
(if (hidden-package? package)
|
(match result+seen
|
||||||
result
|
((result . seen)
|
||||||
(cons `#(,(package-name package)
|
(if (or (vhash-assq package seen)
|
||||||
,(package-version package)
|
(hidden-package? package))
|
||||||
,(module-name module)
|
(cons result seen)
|
||||||
,symbol
|
(cons (cons `#(,(package-name package)
|
||||||
,(package-outputs package)
|
,(package-version package)
|
||||||
,(->bool (member (%current-system)
|
,(module-name module)
|
||||||
(package-supported-systems package)))
|
,symbol
|
||||||
,(->bool (package-superseded package))
|
,(package-outputs package)
|
||||||
,@(let ((loc (package-location package)))
|
,(->bool
|
||||||
(if loc
|
(member (%current-system)
|
||||||
`(,(location-file loc)
|
(package-supported-systems package)))
|
||||||
,(location-line loc)
|
,(->bool (package-superseded package))
|
||||||
,(location-column loc))
|
,@(let ((loc (package-location package)))
|
||||||
'(#f #f #f))))
|
(if loc
|
||||||
result)))
|
`(,(location-file loc)
|
||||||
|
,(location-line loc)
|
||||||
|
,(location-column loc))
|
||||||
|
'(#f #f #f))))
|
||||||
|
result)
|
||||||
|
(vhash-consq package #t seen))))))
|
||||||
(_
|
(_
|
||||||
result)))
|
result+seen)))
|
||||||
|
|
||||||
(define exp
|
(define exp
|
||||||
(fold-module-public-variables* expand-cache '()
|
(first
|
||||||
(all-modules (%package-module-path)
|
(fold-module-public-variables* expand-cache
|
||||||
#:warn
|
(cons '() vlist-null)
|
||||||
warn-about-load-error)))
|
(all-modules (%package-module-path)
|
||||||
|
#:warn
|
||||||
|
warn-about-load-error))))
|
||||||
|
|
||||||
(mkdir-p (dirname cache-file))
|
(mkdir-p (dirname cache-file))
|
||||||
(call-with-output-file cache-file
|
(call-with-output-file cache-file
|
||||||
|
|
|
@ -1037,7 +1037,8 @@
|
||||||
result))
|
result))
|
||||||
'()))))))
|
'()))))))
|
||||||
|
|
||||||
(lset= equal? no-cache from-cache)))
|
(and (equal? (delete-duplicates from-cache) from-cache)
|
||||||
|
(lset= equal? no-cache from-cache))))
|
||||||
|
|
||||||
(test-assert "find-packages-by-name"
|
(test-assert "find-packages-by-name"
|
||||||
(match (find-packages-by-name "hello")
|
(match (find-packages-by-name "hello")
|
||||||
|
|
Loading…
Reference in New Issue