guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: Deduplicate inferior packages including replacements


From: Christopher Baines
Subject: 02/02: Deduplicate inferior packages including replacements
Date: Fri, 4 Mar 2022 09:25:01 -0500 (EST)

cbaines pushed a commit to branch master
in repository data-service.

commit fe556f4a4d6d7ce7f92e31e955595a557faae435
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Mar 4 14:22:10 2022 +0000

    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.
---
 guix-data-service/jobs/load-new-guix-revision.scm | 37 ++++++++++++-----------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/guix-data-service/jobs/load-new-guix-revision.scm 
b/guix-data-service/jobs/load-new-guix-revision.scm
index 2bcb99d..2b8a34b 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -781,31 +781,32 @@ WHERE job_id = $1")
                            b-name)))))))
 
 (define (inferior-packages-plus-replacements inf)
-  (let* ((packages
+  (let* ((packages (inferior-packages inf))
+         (replacements (filter-map inferior-package-replacement packages))
+         (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)
+
+            (filter (lambda (pkg)
+                      (eq? #f
+                           (hash-ref package-id-hash-table
+                                     (inferior-package-id pkg))))
+                    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
-           (inferior-packages inf)))
-         (replacements (filter-map inferior-package-replacement packages))
-
-         (package-id-hash-table (make-hash-table)))
-
-    (for-each (lambda (pkg)
-                (hash-set! package-id-hash-table
-                           (inferior-package-id pkg)
-                           #t))
-              packages)
+           (append! packages non-exported-replacements))))
 
-    (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))
 
 (define* (insert-packages conn inf packages #:key (process-replacements? #t))
   (let* ((package-license-set-ids



reply via email to

[Prev in Thread] Current Thread [Next in Thread]