scripts: lint: Handle store connections for lint checkers.
Rather than individual checkers opening up a connection to the store for each package to check, if any checker requires a store connection, open a connection and pass it to all checkers that would use it. This makes running the derivation checker much faster for multiple packages. * guix/scripts/lint.scm (run-checkers): Add a #:store argument, and pass the store to checkers if they require a store connection. (guix-lint): Establish a store connection if any checker requires one, and pass it through to run-checkers.master
parent
7826fbc02b
commit
57e12aad6d
|
@ -30,6 +30,7 @@
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (guix lint)
|
#:use-module (guix lint)
|
||||||
#:use-module (guix ui)
|
#:use-module (guix ui)
|
||||||
|
#:use-module (guix store)
|
||||||
#:use-module (guix scripts)
|
#:use-module (guix scripts)
|
||||||
#:use-module (guix scripts build)
|
#:use-module (guix scripts build)
|
||||||
#:use-module (gnu packages)
|
#:use-module (gnu packages)
|
||||||
|
@ -53,7 +54,7 @@
|
||||||
(lint-warning-message lint-warning))))
|
(lint-warning-message lint-warning))))
|
||||||
warnings))
|
warnings))
|
||||||
|
|
||||||
(define (run-checkers package checkers)
|
(define* (run-checkers package checkers #:key store)
|
||||||
"Run the given CHECKERS on PACKAGE."
|
"Run the given CHECKERS on PACKAGE."
|
||||||
(let ((tty? (isatty? (current-error-port))))
|
(let ((tty? (isatty? (current-error-port))))
|
||||||
(for-each (lambda (checker)
|
(for-each (lambda (checker)
|
||||||
|
@ -63,7 +64,9 @@
|
||||||
(lint-checker-name checker))
|
(lint-checker-name checker))
|
||||||
(force-output (current-error-port)))
|
(force-output (current-error-port)))
|
||||||
(emit-warnings
|
(emit-warnings
|
||||||
((lint-checker-check checker) package)))
|
(if (lint-checker-requires-store? checker)
|
||||||
|
((lint-checker-check checker) package #:store store)
|
||||||
|
((lint-checker-check checker) package))))
|
||||||
checkers)
|
checkers)
|
||||||
(when tty?
|
(when tty?
|
||||||
(format (current-error-port) "\x1b[K")
|
(format (current-error-port) "\x1b[K")
|
||||||
|
@ -167,12 +170,27 @@ run the checkers on all packages.\n"))
|
||||||
(_ #f))
|
(_ #f))
|
||||||
(reverse opts)))
|
(reverse opts)))
|
||||||
(checkers (or (assoc-ref opts 'checkers) %all-checkers)))
|
(checkers (or (assoc-ref opts 'checkers) %all-checkers)))
|
||||||
(cond
|
|
||||||
((assoc-ref opts 'list?)
|
(when (assoc-ref opts 'list?)
|
||||||
(list-checkers-and-exit checkers))
|
(list-checkers-and-exit checkers))
|
||||||
|
|
||||||
|
(let ((any-lint-checker-requires-store?
|
||||||
|
(any lint-checker-requires-store? checkers)))
|
||||||
|
|
||||||
|
(define (call-maybe-with-store proc)
|
||||||
|
(if any-lint-checker-requires-store?
|
||||||
|
(with-store store
|
||||||
|
(proc store))
|
||||||
|
(proc #f)))
|
||||||
|
|
||||||
|
(call-maybe-with-store
|
||||||
|
(lambda (store)
|
||||||
|
(cond
|
||||||
((null? args)
|
((null? args)
|
||||||
(fold-packages (lambda (p r) (run-checkers p checkers)) '()))
|
(fold-packages (lambda (p r) (run-checkers p checkers
|
||||||
|
#:store store)) '()))
|
||||||
(else
|
(else
|
||||||
(for-each (lambda (spec)
|
(for-each (lambda (spec)
|
||||||
(run-checkers (specification->package spec) checkers))
|
(run-checkers (specification->package spec) checkers
|
||||||
args)))))
|
#:store store))
|
||||||
|
args))))))))
|
||||||
|
|
Reference in New Issue