all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: 38754@debbugs.gnu.org
Subject: [bug#38754] [PATCH 3/4] lint: Add a #:store argument to check-derivation
Date: Sun, 15 Mar 2020 21:06:30 +0000	[thread overview]
Message-ID: <20200315210631.5334-3-mail@cbaines.net> (raw)
In-Reply-To: <20200315210631.5334-1-mail@cbaines.net>

This can then be used to avoid opening up a store connection each time a
package needs checking.

* guix/lint.scm (check-derivation): Add a #:store argument, and pull the
handling of the store connection out of the try function.
---
 guix/lint.scm | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/guix/lint.scm b/guix/lint.scm
index b20510b45d..cfe3be2302 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -917,9 +917,9 @@ descriptions maintained upstream."
    (define exception-with-kind-and-args?
      (const #f))))
 
-(define (check-derivation package)
+(define* (check-derivation package #:key store)
   "Emit a warning if we fail to compile PACKAGE to a derivation."
-  (define (try system)
+  (define (try store system)
     (catch #t     ;TODO: Remove 'catch' when Guile 2.x is no longer supported.
       (lambda ()
         (guard (c ((store-protocol-error? c)
@@ -938,25 +938,29 @@ descriptions maintained upstream."
                                  (G_ "failed to create ~a derivation: ~a")
                                  (list system
                                        (condition-message c)))))
-          (with-store store
-            ;; Disable grafts since it can entail rebuilds.
-            (parameterize ((%graft? #f))
-              (package-derivation store package system #:graft? #f)
-
-              ;; If there's a replacement, make sure we can compute its
-              ;; derivation.
-              (match (package-replacement package)
-                (#f #t)
-                (replacement
-                 (package-derivation store replacement system
-                                     #:graft? #f)))))))
+          (parameterize ((%graft? #f))
+            (package-derivation store package system #:graft? #f)
+
+            ;; If there's a replacement, make sure we can compute its
+            ;; derivation.
+            (match (package-replacement package)
+              (#f #t)
+              (replacement
+               (package-derivation store replacement system
+                                   #:graft? #f))))))
       (lambda args
         (make-warning package
                       (G_ "failed to create ~a derivation: ~s")
                       (list system args)))))
 
-  (filter lint-warning?
-          (map try (package-supported-systems package))))
+  (define (check-with-store store)
+    (filter lint-warning?
+            (map (cut try store <>) (package-supported-systems package))))
+
+  ;; For backwards compatability, don't rely on store being set
+  (or (and=> store check-with-store)
+      (with-store store
+        (check-with-store store))))
 
 (define (check-license package)
   "Warn about type errors of the 'license' field of PACKAGE."
-- 
2.25.0

  parent reply	other threads:[~2020-03-15 21:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26 17:33 [bug#38754] [PATCH 0/2] Speed up the derivation linter Christopher Baines
2019-12-26 18:01 ` [bug#38754] [PATCH 1/2] guix: lint: Add an optional parameter for a store connection Christopher Baines
2019-12-26 18:01   ` [bug#38754] [PATCH 2/2] scripts: lint: Set the %link-checker-store-connection parameter Christopher Baines
2019-12-30 22:12     ` Ludovic Courtès
2019-12-30 23:34       ` Christopher Baines
2019-12-31 18:15         ` Ludovic Courtès
2020-03-15 21:06           ` [bug#38754] [PATCH 1/4] lint: Add a requires-store? field to the checker record Christopher Baines
2020-03-15 21:06             ` [bug#38754] [PATCH 2/4] lint: Mark the derivation checker as requiring a store connection Christopher Baines
2020-03-15 21:06             ` Christopher Baines [this message]
2020-03-15 21:06             ` [bug#38754] [PATCH 4/4] scripts: lint: Handle store connections for lint checkers Christopher Baines
2020-03-15 21:35           ` [bug#38754] [PATCH 2/2] scripts: lint: Set the %link-checker-store-connection parameter Christopher Baines
2020-03-24 10:20             ` Ludovic Courtès
2020-03-24 19:50               ` bug#38754: " Christopher Baines
2019-12-30 22:01 ` [bug#38754] [PATCH 0/2] Speed up the derivation linter Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200315210631.5334-3-mail@cbaines.net \
    --to=mail@cbaines.net \
    --cc=38754@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.