From patchwork Sat Oct 1 16:19:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 1008 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 B6EBD27BBEB; Sat, 1 Oct 2022 17:20:25 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8880C27BBEA for ; Sat, 1 Oct 2022 17:20:24 +0100 (BST) Received: from localhost ([::1]:50352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oefDz-0005Na-Fr for patchwork@mira.cbaines.net; Sat, 01 Oct 2022 12:20:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefDf-0005Mb-Pl for guix-patches@gnu.org; Sat, 01 Oct 2022 12:20:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefDe-0005cH-PV for guix-patches@gnu.org; Sat, 01 Oct 2022 12:20:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oefDe-0003jv-LG for guix-patches@gnu.org; Sat, 01 Oct 2022 12:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58231] [PATCH 0/2] Checking the 'license' field of packages Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 01 Oct 2022 16:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58231 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58231@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.166464116614321 (code B ref -1); Sat, 01 Oct 2022 16:20:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Oct 2022 16:19:26 +0000 Received: from localhost ([127.0.0.1]:45621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oefD4-0003iv-DK for submit@debbugs.gnu.org; Sat, 01 Oct 2022 12:19:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:47482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oefD2-0003in-DD for submit@debbugs.gnu.org; Sat, 01 Oct 2022 12:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefD2-0005Cu-7X for guix-patches@gnu.org; Sat, 01 Oct 2022 12:19:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefD1-0005an-Uh; Sat, 01 Oct 2022 12:19:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=D0VaQ5FZtSqQcqV0tL1H4vviN/5uOJXgqNNleppnInM=; b=LR896TbkgKOOPO D6EPypu7Ca8GsMVGPnshsqLpu+ujXvCjRvqsZLI7u05gJdhtXGjYz8S9trm/3XxrmDTOzbq7kcZ4x fIsR404bgkYjS/2Aqr5sJhUGptuTiWsTCyhpc8E5071uggWZs4b4vi5NHhOqXb8kbKS9p9m4WOGLJ K7S+IGeyh0yiuJIi0arXL72Ux5hJAI8jtjVyAww6bA95wKBdRRSnVNYpwxAaPSd4q3gVcn7VuJszN C+r2cNakwTDT3nDdGz9i6/Gx8e6OcRcQMhgDf35yVHajzZsFEXqM7UD+ZfGOP57leVK6guh5lk66w mEZ6qbQ497al5vI/fpvw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:62741 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefD1-0007vT-C6; Sat, 01 Oct 2022 12:19:23 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 1 Oct 2022 18:19:11 +0200 Message-Id: <20221001161911.8116-1-ludo@gnu.org> X-Mailer: git-send-email 2.37.3 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 Hello Guix! We already have ‘guix lint -c license’ but that hasn’t prevented us from occasionally having invalid licenses committed. This patch adds add a ‘sanitize’ option to the ‘license’ field of to detect invalid licenses early on, as zimoun suggested at: https://lists.gnu.org/archive/html/guix-devel/2022-09/msg00067.html The funny part of this patch is that the license validation expands to #t in the majority of cases, meaning that it comes without run-time overhead (there is macro-expansion overhead, but I didn’t measure it). Kinda like static type checking, except that we can only tell when a value is definitely a valid license and cannot conclude in other cases. Feedback welcome! Thanks, Ludo’. Ludovic Courtès (2): licenses: Let 'license?' expand to #t in trivial cases. packages: Raise an exception for invalid 'license' values. guix/licenses.scm | 58 +++++++++++++++++++++++++++++++++++++++------- guix/packages.scm | 40 +++++++++++++++++++++++++++++++- tests/packages.scm | 7 ++++++ 3 files changed, 95 insertions(+), 10 deletions(-) base-commit: d9b7982ba58fdea0934b60a81f507440a56c82ee