Deduplicate inferior packages including replacements

Previously, duplicates could creep through if the duplicate wasn't exported,
and only found as a replacement. Now they're filtered out.

This isn't ideal, as duplicates aren't always mistakes, it would be useful
still to capture this package, but having multiple entries for the same
name+version causes the comparison functionality to break.
This commit is contained in:
Christopher Baines 2022-03-04 14:22:10 +00:00
parent 0cc749a1fa
commit fe556f4a4d

View file

@ -781,31 +781,32 @@ WHERE job_id = $1")
b-name)))))))
(define (inferior-packages-plus-replacements inf)
(let* ((packages
;; This isn't perfect, sometimes there can be two packages with the
;; same name and version, but different derivations. Guix will warn
;; about this case though, generally this means only one of the
;; packages should be exported.
(deduplicate-inferior-packages
(inferior-packages inf)))
(let* ((packages (inferior-packages inf))
(replacements (filter-map inferior-package-replacement packages))
(package-id-hash-table (make-hash-table)))
(non-exported-replacements
(let ((package-id-hash-table (make-hash-table)))
(for-each (lambda (pkg)
(hash-set! package-id-hash-table
(inferior-package-id pkg)
#t))
packages)
(let ((non-exported-replacements
(filter (lambda (pkg)
(eq? #f
(hash-ref package-id-hash-table
(inferior-package-id pkg))))
replacements)))
(append packages non-exported-replacements))))
(deduplicated-packages
;; This isn't perfect, sometimes there can be two packages with the
;; same name and version, but different derivations. Guix will warn
;; about this case though, generally this means only one of the
;; packages should be exported.
(deduplicate-inferior-packages
(append! packages non-exported-replacements))))
deduplicated-packages))
(define* (insert-packages conn inf packages #:key (process-replacements? #t))
(let* ((package-license-set-ids