diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-02-15 22:58:29 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-02-16 01:00:08 +0100 |
| commit | 36754eee28187b41e9a6ef15cd3c9911449a4e8d (patch) | |
| tree | 6ddea122d835508372e1018e97529e68ce58acf7 /gnu/packages.scm | |
| parent | ba48895899a117d6ace2209c3f54411a4a989133 (diff) | |
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.
Diffstat (limited to 'gnu/packages.scm')
| -rw-r--r-- | gnu/packages.scm | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm index a1814205f93..7b17e70c535 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm | |||
| @@ -371,34 +371,41 @@ reducing the memory footprint." | |||
| 371 | (define cache-file | 371 | (define cache-file |
| 372 | (string-append directory %package-cache-file)) | 372 | (string-append directory %package-cache-file)) |
| 373 | 373 | ||
| 374 | (define (expand-cache module symbol variable result) | 374 | (define (expand-cache module symbol variable result+seen) |
| 375 | (match (false-if-exception (variable-ref variable)) | 375 | (match (false-if-exception (variable-ref variable)) |
| 376 | ((? package? package) | 376 | ((? package? package) |
| 377 | (if (hidden-package? package) | 377 | (match result+seen |
| 378 | result | 378 | ((result . seen) |
| 379 | (cons `#(,(package-name package) | 379 | (if (or (vhash-assq package seen) |
| 380 | ,(package-version package) | 380 | (hidden-package? package)) |
| 381 | ,(module-name module) | 381 | (cons result seen) |
| 382 | ,symbol | 382 | (cons (cons `#(,(package-name package) |
| 383 | ,(package-outputs package) | 383 | ,(package-version package) |
| 384 | ,(->bool (member (%current-system) | 384 | ,(module-name module) |
| 385 | (package-supported-systems package))) | 385 | ,symbol |
| 386 | ,(->bool (package-superseded package)) | 386 | ,(package-outputs package) |
| 387 | ,@(let ((loc (package-location package))) | 387 | ,(->bool |
| 388 | (if loc | 388 | (member (%current-system) |
| 389 | `(,(location-file loc) | 389 | (package-supported-systems package))) |
| 390 | ,(location-line loc) | 390 | ,(->bool (package-superseded package)) |
| 391 | ,(location-column loc)) | 391 | ,@(let ((loc (package-location package))) |
| 392 | '(#f #f #f)))) | 392 | (if loc |
| 393 | result))) | 393 | `(,(location-file loc) |
| 394 | ,(location-line loc) | ||
| 395 | ,(location-column loc)) | ||
| 396 | '(#f #f #f)))) | ||
| 397 | result) | ||
| 398 | (vhash-consq package #t seen)))))) | ||
| 394 | (_ | 399 | (_ |
| 395 | result))) | 400 | result+seen))) |
| 396 | 401 | ||
| 397 | (define exp | 402 | (define exp |
| 398 | (fold-module-public-variables* expand-cache '() | 403 | (first |
| 399 | (all-modules (%package-module-path) | 404 | (fold-module-public-variables* expand-cache |
| 400 | #:warn | 405 | (cons '() vlist-null) |
| 401 | warn-about-load-error))) | 406 | (all-modules (%package-module-path) |
| 407 | #:warn | ||
| 408 | warn-about-load-error)))) | ||
| 402 | 409 | ||
| 403 | (mkdir-p (dirname cache-file)) | 410 | (mkdir-p (dirname cache-file)) |
| 404 | (call-with-output-file cache-file | 411 | (call-with-output-file cache-file |
