From patchwork Sun Mar 15 21:06:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 20698 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id BF29F27BBEA; Sun, 15 Mar 2020 21:08:27 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 89D9827BBE4 for ; Sun, 15 Mar 2020 21:08:27 +0000 (GMT) Received: from localhost ([::1]:58866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDaUk-000675-T0 for patchwork@mira.cbaines.net; Sun, 15 Mar 2020 17:08:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33420) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDaTP-0005l5-IW for guix-patches@gnu.org; Sun, 15 Mar 2020 17:07:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDaTO-00086M-E8 for guix-patches@gnu.org; Sun, 15 Mar 2020 17:07:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57967) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDaTO-00085z-Ap for guix-patches@gnu.org; Sun, 15 Mar 2020 17:07:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jDaTO-0000Am-4w for guix-patches@gnu.org; Sun, 15 Mar 2020 17:07:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#38754] [PATCH 3/4] lint: Add a #:store argument to check-derivation Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 Mar 2020 21:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38754 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38754@debbugs.gnu.org Received: via spool by 38754-submit@debbugs.gnu.org id=B38754.1584306397606 (code B ref 38754); Sun, 15 Mar 2020 21:07:02 +0000 Received: (at 38754) by debbugs.gnu.org; 15 Mar 2020 21:06:37 +0000 Received: from localhost ([127.0.0.1]:35702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDaSy-00009b-Ez for submit@debbugs.gnu.org; Sun, 15 Mar 2020 17:06:36 -0400 Received: from mira.cbaines.net ([212.71.252.8]:36348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jDaSw-00009A-AQ for 38754@debbugs.gnu.org; Sun, 15 Mar 2020 17:06:35 -0400 Received: from localhost (unknown [46.237.160.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 801CC27BBEB for <38754@debbugs.gnu.org>; Sun, 15 Mar 2020 21:06:33 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id e4b16d6a for <38754@debbugs.gnu.org>; Sun, 15 Mar 2020 21:06:31 +0000 (UTC) From: Christopher Baines Date: Sun, 15 Mar 2020 21:06:30 +0000 Message-Id: <20200315210631.5334-3-mail@cbaines.net> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200315210631.5334-1-mail@cbaines.net> References: <87lfqsxsxn.fsf@gnu.org> <20200315210631.5334-1-mail@cbaines.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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."