From patchwork Tue Mar 7 17:18:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 47775 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 89BE916DE6; Tue, 7 Mar 2023 17:21:03 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=unavailable 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 D6BBB16DE3 for ; Tue, 7 Mar 2023 17:21:02 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZayA-0006qe-7L; Tue, 07 Mar 2023 12:19:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZaxt-0006cr-Lr for guix-patches@gnu.org; Tue, 07 Mar 2023 12:19:08 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZaxt-0007go-9f; Tue, 07 Mar 2023 12:19:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZaxp-00043K-O9; Tue, 07 Mar 2023 12:19:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#62036] [PATCH] guix: packages: Consider 'patches' by 'package-direct-sources'. Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 07 Mar 2023 17:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62036 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62036@debbugs.gnu.org Cc: Simon Tournier , Christopher Baines , Josselin Poiret , , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.167820952715556 (code B ref -1); Tue, 07 Mar 2023 17:19:01 +0000 Received: (at submit) by debbugs.gnu.org; 7 Mar 2023 17:18:47 +0000 Received: from localhost ([127.0.0.1]:47108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZaxa-00042n-N0 for submit@debbugs.gnu.org; Tue, 07 Mar 2023 12:18:47 -0500 Received: from lists.gnu.org ([209.51.188.17]:45514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZaxY-00042f-5P for submit@debbugs.gnu.org; Tue, 07 Mar 2023 12:18:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZaxX-0004h5-QN for guix-patches@gnu.org; Tue, 07 Mar 2023 12:18:43 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZaxW-0007cd-2Q for guix-patches@gnu.org; Tue, 07 Mar 2023 12:18:43 -0500 Received: by mail-wr1-x42d.google.com with SMTP id v16so12952451wrn.0 for ; Tue, 07 Mar 2023 09:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678209520; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6QRbDDVH6o/ytumYy8LG8YndqDJXizJUZivCVyCwSlk=; b=UeAmlW4wutQUp9NQ7VDDAGhxgsYCyesh7QasCEwTjrfFy00wpgXoDy7v0eJlgOqfnI oBbDP4A6jMZMjoOCR3GiMg62WVjG3onz9OE3UOiPyvlF/xytTKnGmV1jITwOVYvBZ0gj mPkj+JG+A0i6+dNK5IU8Fs5BN90U5G910J0xyyutw6t61xmhQ5xp4NHtybaIaTJoHtqc K7m4BatWJd4hxaR0nlP80BIeU0jOyf36PZQTIyXBwAADRXdFVYHP5h1fMYxzZ5TMXilX CIBvpd8jBdyWEh6dNpI1F0vI3BQgKijPLdU/8rRdGmZJSxxDdlIcWlhipm4ZPrJlB+bf oTIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678209520; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6QRbDDVH6o/ytumYy8LG8YndqDJXizJUZivCVyCwSlk=; b=vUOvYl8J5jtdGXzKRbesytqWwsfz5cUZVUMIPi4xwk0HIPcn/v47KWywBrNBUMOVCR MN0nee/gjt9S8Wdg2ClFB8LqjI/neXnFY2FOKSIMLricbjV0pPfeTAWz2XfmS63JOxZT UvVJQ4DlXZyRvsggPttpCDl13Q5HQH/AlHAIvckvJG12LTmsEjQeeabrMUTuR3qLI8U9 YLibXZCV41TtF8LkU1orzcMUArVH+lgReRmkliKb+cjckaBba6GI3QwTKdoB9IJlZugb AXbnqQE/hxraUPTleR77IOvKZLkH8c3AYEyUAkcPMJxrPgg/3X03EZvum2z3mioBoB5A gqvQ== X-Gm-Message-State: AO0yUKWaZ5wJ72ubXUiFt30iYWv0OAw5KmoyLdagU135L/E7f05PKHM1 i8tdAcM91oOKs+/oy+PoF8KrSs2AYbI= X-Google-Smtp-Source: AK7set82pLYM0JxDbYApO7tqB0cuGUHpt7bR+i+n6Q0WWwDQnmGvKCKSdv8ruSJA1JYIFgUqog1rIg== X-Received: by 2002:adf:fc0d:0:b0:2c7:1755:30ad with SMTP id i13-20020adffc0d000000b002c7175530admr10984311wrr.2.1678209520378; Tue, 07 Mar 2023 09:18:40 -0800 (PST) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id e13-20020a5d65cd000000b002c3f81c51b6sm12807621wrw.90.2023.03.07.09.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 09:18:39 -0800 (PST) From: Simon Tournier Date: Tue, 7 Mar 2023 18:18:33 +0100 Message-Id: <20230307171833.4170067-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/packages.scm (package-direct-sources): Return 'origin' from 'patches'. * tests/packages.scm: Test it. --- guix/packages.scm | 10 ++++++++-- tests/packages.scm | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) Hi, This patch improves some coverage when listing all the origins (fixed outputs) of some packages. The procedure 'packages-direct-sources' already lists the 'origin' as inputs but is missing the 'origin' as 'patches'. For an instance of such, see the package 'ntp'. Note that it is not recursive. If an 'origin' is listed in 'patches' or 'inputs' and that origin also contains 'patches' which is another 'origin' then it will be missed. For now, it is not covered because it somehow adds complexity without an instance (yet) of such case. Cheers, simon base-commit: 723fc5df3e964fcecb09c7c6fd48f00f97e2e806 diff --git a/guix/packages.scm b/guix/packages.scm index 041a872f9d..0f88564ab4 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2021 Chris Marusich ;;; Copyright © 2022 Maxime Devos ;;; Copyright © 2022 jgart +;;; Copyright © 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -1239,8 +1240,13 @@ (define-syntax modify-inputs (define (package-direct-sources package) "Return all source origins associated with PACKAGE; including origins in -PACKAGE's inputs." - `(,@(or (and=> (package-source package) list) '()) +PACKAGE's inputs and patches." + (define (expand source) + (append + (list source) + (filter origin? (origin-patches source)))) + + `(,@(or (and=> (package-source package) expand) '()) ,@(filter-map (match-lambda ((_ (? origin? orig) _ ...) orig) diff --git a/tests/packages.scm b/tests/packages.scm index f58c47817b..27fb918f90 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -418,12 +419,15 @@ (define read-at (let* ((o (dummy-origin)) (u (dummy-origin)) (i (dummy-origin)) + (j (dummy-origin (patches (list o)))) (a (dummy-package "a")) (b (dummy-package "b" (inputs (list a i)))) (c (package (inherit b) (source o))) (d (dummy-package "d" (build-system trivial-build-system) - (source u) (inputs (list c))))) + (source u) (inputs (list c)))) + (e (dummy-package "e" (source j))) + (f (package (inherit e) (inputs (list u))))) (test-assert "package-direct-sources, no source" (null? (package-direct-sources a))) (test-equal "package-direct-sources, #f source" @@ -437,6 +441,17 @@ (define read-at (and (= (length (pk 's-sources s)) 2) (member o s) (member i s)))) + (test-assert "package-direct-sources, with patches" + (let ((s (package-direct-sources e))) + (and (= (length (pk 's-sources s)) 2) + (member o s) + (member j s)))) + (test-assert "package-direct-sources, with patches and inputs" + (let ((s (package-direct-sources f))) + (and (= (length (pk 's-sources s)) 3) + (member o s) + (member j s) + (member u s)))) (test-assert "package-transitive-sources" (let ((s (package-transitive-sources d))) (and (= (length (pk 'd-sources s)) 3)