From patchwork Wed Oct 28 16:51:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 24856 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 DC13527BBF3; Wed, 28 Oct 2020 17:09:08 +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.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_DKIM_INVALID,URIBL_BLOCKED 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 ESMTPS id 6824727BBF2 for ; Wed, 28 Oct 2020 17:09:08 +0000 (GMT) Received: from localhost ([::1]:35800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXowd-0007Qc-G2 for patchwork@mira.cbaines.net; Wed, 28 Oct 2020 13:09:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXog9-0003bF-7P for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXog5-0002a0-Uj for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kXog5-0004zv-Ta for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43261] [PATCH v2 1/2] scripts: lint: Fix '--no-network' option. References: <20200907180229.29475-1-zimon.toutoune@gmail.com> In-Reply-To: <20200907180229.29475-1-zimon.toutoune@gmail.com> Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 28 Oct 2020 16:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43261 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43261@debbugs.gnu.org Cc: ludo@gnu.org, zimoun Received: via spool by 43261-submit@debbugs.gnu.org id=B43261.160390388919161 (code B ref 43261); Wed, 28 Oct 2020 16:52:01 +0000 Received: (at 43261) by debbugs.gnu.org; 28 Oct 2020 16:51:29 +0000 Received: from localhost ([127.0.0.1]:50387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXofZ-0004yz-3x for submit@debbugs.gnu.org; Wed, 28 Oct 2020 12:51:29 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:33037) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXofW-0004yd-U7 for 43261@debbugs.gnu.org; Wed, 28 Oct 2020 12:51:28 -0400 Received: by mail-wr1-f47.google.com with SMTP id b8so6488258wrn.0 for <43261@debbugs.gnu.org>; Wed, 28 Oct 2020 09:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cHH8s23wTNCPGK2CbwHM4rOyLtc7Hm8Pz25od2Hcdk4=; b=WPD8gjp01v3qSyLchrFQgYyAUUk3K2h94pCMmaCvLLUsmRdWsgEXeJiECIrixDxbaa OxJRpsYu5A7AbSPxJPb3aMDCHgWnUwYZA94tipPAn/ATkk5Vs6dlk7ok5oAY6TSvs3s9 ho3OReYjnbv1wWYDJTk1Pa2aVX2Y5WhlZszIyH/4Slx2JeDdwtaB7JeLamalEYQbis3N AciXPa3f1d42ohvqy3ZfKhic1pRSPJ+By9CI7LIUmdiko7UkHWZISEBLbii47YqYn4hh o++9/ARghNRDnsEpIAxmcr9jU4Wq4b/BXghxf+yI0Gprzz0I+bSxOeuh+oLBAX9CWTfX tZSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cHH8s23wTNCPGK2CbwHM4rOyLtc7Hm8Pz25od2Hcdk4=; b=Km+262Eb1G5ohcRv399v2i86Krs7fJIGmEnK7aOmjIiMVi/WIbvJpfPGgfphs7Ab7P hFvzSQBxL833/tLsrsQ1lH+44w4Abcp1JkKQ7C0ZVtao5radVQLPqED5yoXg6hBnyq6O Vg+85lv2sWFZpruvtVnpY1hakIaaJBW+COYRj4dGFvn/TtD3sZ1Pn+4ZbnK7+D1zRSCx 3t4NsZiy1CzxILEjNabvd+lx06g8ordwH8ubZxqaqCSTRc2XQl2SK7U4w2CTOuO9SJ9m pbqy2SpFjVtfF9czCjAeP8IxIx1ogrCC90QsbEEfK/xgyBQYDh8X1qk2Ob3O6UzzjTza gPJg== X-Gm-Message-State: AOAM531wGWd80ILPSX/oW1fhtzu5Esz5M6pDmHkMARQv6GCwZTLru2eV DEBy1DYXHspZ4sNXYJvwxXp4sRmy3BU= X-Google-Smtp-Source: ABdhPJz9zZLcEuzOCMRKbT1AkzGtiKnIoA6uj6tw7HwEV0w/4W3JJWgW8BoFeGncClILUvj5mMe1rg== X-Received: by 2002:a5d:490a:: with SMTP id x10mr157229wrq.289.1603903880753; Wed, 28 Oct 2020 09:51:20 -0700 (PDT) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id y206sm221247wmd.34.2020.10.28.09.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 09:51:20 -0700 (PDT) From: zimoun Date: Wed, 28 Oct 2020 17:51:11 +0100 Message-Id: <20201028165112.28575-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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 * guix/scripts/lint.scm: (show-help): Add '--no-network' option message. (%options, parse-options): Fix argument order. * doc/guix.texi (Invoking guix lint): Document it. --- doc/guix.texi | 4 ++++ guix/scripts/lint.scm | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) base-commit: d22d129da903cf6c3382cff5226d81a881fed2aa diff --git a/doc/guix.texi b/doc/guix.texi index 22bddf10e3..19cf26572c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11528,6 +11528,10 @@ and exit. Only enable the checkers specified in a comma-separated list using the names returned by @option{--list-checkers}. +@item --no-network +@itemx -n +Only enable the checkers which do not dependent on Internet access. + @item --load-path=@var{directory} @itemx -L @var{directory} Add @var{directory} to the front of the package module search path diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 979d4f8363..1ab563a3fa 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -9,7 +9,7 @@ ;;; Copyright © 2017 Tobias Geerinckx-Rice ;;; Copyright © 2017, 2018 Efraim Flashner ;;; Copyright © 2018, 2019 Arun Isaac -;;; Copyright © 2019 Simon Tournier +;;; Copyright © 2019, 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -98,6 +98,9 @@ run the checkers on all packages.\n")) (display (G_ " -c, --checkers=CHECKER1,CHECKER2... only run the specified checkers")) + (display (G_ " + -n, --no-network only run checkers which do not access to network")) + (display (G_ " -L, --load-path=DIR prepend DIR to the package module search path")) (newline) @@ -132,10 +135,7 @@ run the checkers on all packages.\n")) result)))) (option '(#\n "no-network") #f #f (lambda (opt name arg result) - (alist-cons 'checkers - %local-checkers - (alist-delete 'checkers - result)))) + (alist-cons 'no-network? #t result))) (find (lambda (option) (member "load-path" (option-names option))) %standard-build-options) @@ -172,7 +172,13 @@ run the checkers on all packages.\n")) value) (_ #f)) (reverse opts))) - (checkers (or (assoc-ref opts 'checkers) %all-checkers))) + (the-checkers (or (assoc-ref opts 'checkers) %all-checkers)) + (checkers + (if (assoc-ref opts 'no-network?) + (filter (lambda (checker) + (member checker %local-checkers)) + the-checkers) + the-checkers))) (when (assoc-ref opts 'list?) (list-checkers-and-exit checkers)) From patchwork Wed Oct 28 16:51:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 24858 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 DB57A27BBF3; Wed, 28 Oct 2020 17:09:16 +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.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_DKIM_INVALID 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 ESMTPS id 6185827BBF2 for ; Wed, 28 Oct 2020 17:09:16 +0000 (GMT) Received: from localhost ([::1]:36568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXowl-0007kK-IO for patchwork@mira.cbaines.net; Wed, 28 Oct 2020 13:09:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXog9-0003bG-7x for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXog6-0002a1-9m for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kXog6-000503-92 for guix-patches@gnu.org; Wed, 28 Oct 2020 12:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43261] [PATCH v2 2/2] scripts: lint: Add '--exclude' option. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 28 Oct 2020 16:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43261 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43261@debbugs.gnu.org Cc: ludo@gnu.org, zimoun Received: via spool by 43261-submit@debbugs.gnu.org id=B43261.160390389219172 (code B ref 43261); Wed, 28 Oct 2020 16:52:02 +0000 Received: (at 43261) by debbugs.gnu.org; 28 Oct 2020 16:51:32 +0000 Received: from localhost ([127.0.0.1]:50389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXofc-0004zA-E5 for submit@debbugs.gnu.org; Wed, 28 Oct 2020 12:51:32 -0400 Received: from mail-wm1-f42.google.com ([209.85.128.42]:38917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kXofY-0004yf-05 for 43261@debbugs.gnu.org; Wed, 28 Oct 2020 12:51:28 -0400 Received: by mail-wm1-f42.google.com with SMTP id d3so224177wma.4 for <43261@debbugs.gnu.org>; Wed, 28 Oct 2020 09:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zyGHYMuOUG9SI+erhkP2hv4dqLyoSKx1z1vxYaZ9MO8=; b=lvPDkGfPW/BEXjAznOeP7oTu2tjTpL/fp63MSXM0nMf/rlzAWfd3QyjS6xICRsTt43 fYZe9vxmTfH5O/67C+BSA/SjNYOyRVeukD45oPyRVKtMvKi3jQHuzqhL4wzV7hS5pGgf 6Bgxnrp0Uf+/hL25ebOICk8j6vcs/V8JG2hQkbCdUwH6hKy/2BHed8dugjhwtk7ptKDB PHKRZU81k5MGM78Q//IoD5PaH4w2wT9QoM+iJNQOKDd1Z5qGGWU2EfVt17q5c7EufPCa GpWMU4yUP8xIhlaiPIZ5lhkez7wH9vF2AtPEClpcv9FCHz2M2tif2Dg3s00XVGcHjU+9 zysg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zyGHYMuOUG9SI+erhkP2hv4dqLyoSKx1z1vxYaZ9MO8=; b=M4szBZkklJ6xF8xsvMNtdLUXpNDQktE0437dX7JwqOSif3i2TZzIkuoD+2E4FWAtnV Z8XC0e1xzYgHBGDKadE82t/MMBZw+r5cyV2LsbvCFzn+V9wXJXAxpVCYoKxfFmYY3u5k ApPXDl3aJzDIaR16tHcu+3MVEl1FFfYy4bRbC6QPoiftnGPOIkLb88wAEDjPLrdoBMws Zy1ZTBV4dcTbcP2lmjNh/1xzkmJ3OqIlEPAuT07ZBTtXSgNpZCJQj9d6ayoPS5bAoQFm 1TLAQNvshZohAXDiy6/V7NH3Ji0DKzsx5ZIhmjcl4cYvcuIhpWMWLFWpRzm6AAJ/xP+/ 8mNA== X-Gm-Message-State: AOAM531DSyUilE8suT1Z1AP/+SiHHmzSUTF0ONUcspVD6tu9RWOvX0z/ QutVhoD5ecX85+0bHzBZvUsDnopcHi4= X-Google-Smtp-Source: ABdhPJyPpuV2ydDJltGuJ3Wh8FE7rBsYQ1Fr6GGnt+j/NKH+UqEWkvbFssc16WQ9mZlxEs9Neuimqg== X-Received: by 2002:a7b:c20d:: with SMTP id x13mr335105wmi.83.1603903881773; Wed, 28 Oct 2020 09:51:21 -0700 (PDT) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id y206sm221247wmd.34.2020.10.28.09.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 09:51:21 -0700 (PDT) From: zimoun Date: Wed, 28 Oct 2020 17:51:12 +0100 Message-Id: <20201028165112.28575-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201028165112.28575-1-zimon.toutoune@gmail.com> References: <20201028165112.28575-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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 * guix/scripts/lint.scm (%options, parse-options): Add '--exclude' option. (option-checker): New helper function. * doc/guix.texi (Invoking guix lint): Document it. --- doc/guix.texi | 5 +++++ guix/scripts/lint.scm | 44 ++++++++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 19cf26572c..1c146026fd 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -11528,6 +11528,11 @@ and exit. Only enable the checkers specified in a comma-separated list using the names returned by @option{--list-checkers}. +@item --exclude +@itemx -x +Only disable the checkers specified in a comma-separated list using the +names returned by @option{--list-checkers}. + @item --no-network @itemx -n Only enable the checkers which do not dependent on Internet access. diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 1ab563a3fa..cfe1a41211 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -99,6 +99,9 @@ run the checkers on all packages.\n")) -c, --checkers=CHECKER1,CHECKER2... only run the specified checkers")) (display (G_ " + -x, --exclude=CHECKER1,CHECKER2... + exclude the specified checkers")) + (display (G_ " -n, --no-network only run checkers which do not access to network")) (display (G_ " @@ -113,26 +116,34 @@ run the checkers on all packages.\n")) (newline) (show-bug-report-information)) +(define (option-checker short-long) + ;; Factorize the creation of the two options -c/--checkers and -x/--exclude, + ;; see %options. The parameter SHORT-LONG is the list containing the short + ;; and long name. The alist uses the long name as symbol. + (option short-long #t #f + (lambda (opt name arg result) + (let ((names (map string->symbol (string-split arg #\,))) + (checker-names (map lint-checker-name %all-checkers)) + (option-name (string->symbol (match short-long + ((short long) long))))) + (for-each (lambda (c) + (unless (memq c checker-names) + (leave (G_ "~a: invalid checker~%") c))) + names) + (alist-cons option-name + (filter (lambda (checker) + (member (lint-checker-name checker) + names)) + %all-checkers) + result))))) (define %options ;; Specification of the command-line options. ;; TODO: add some options: ;; * --certainty=[low,medium,high]: only run checkers that have at least this ;; 'certainty'. - (list (option '(#\c "checkers") #t #f - (lambda (opt name arg result) - (let ((names (map string->symbol (string-split arg #\,))) - (checker-names (map lint-checker-name %all-checkers))) - (for-each (lambda (c) - (unless (memq c checker-names) - (leave (G_ "~a: invalid checker~%") c))) - names) - (alist-cons 'checkers - (filter (lambda (checker) - (member (lint-checker-name checker) - names)) - %all-checkers) - result)))) + (list (option-checker '(#\c "checkers")) + (option-checker '(#\x "exclude")) (option '(#\n "no-network") #f #f (lambda (opt name arg result) (alist-cons 'no-network? #t result))) @@ -172,7 +183,10 @@ run the checkers on all packages.\n")) value) (_ #f)) (reverse opts))) - (the-checkers (or (assoc-ref opts 'checkers) %all-checkers)) + (no-checkers (or (assoc-ref opts 'exclude) '())) + (the-checkers (filter (lambda (checker) + (not (member checker no-checkers))) + (or (assoc-ref opts 'checkers) %all-checkers))) (checkers (if (assoc-ref opts 'no-network?) (filter (lambda (checker)