From patchwork Sun Mar 2 22:43:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Elsing X-Patchwork-Id: 39625 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 EE82427BBEA; Sun, 2 Mar 2025 22:45:26 +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=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,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 91D8327BBE2 for ; Sun, 2 Mar 2025 22:45:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tos3V-0005WI-1M; Sun, 02 Mar 2025 17:45:05 -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 1tos3T-0005Vv-Gc for guix-patches@gnu.org; Sun, 02 Mar 2025 17:45:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tos3T-0007Cc-5c for guix-patches@gnu.org; Sun, 02 Mar 2025 17:45:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=CiUihsdZtNpCn12PhGYfKJk7Y+D40VazT9MIY9L8wbk=; b=B0WMN+YgvXFL/4/26/wVKUmDi9Ykpqq8G9St5rEDE6Bj2r738dh2DKbjNKxR4DOshegoRgiYFWk48Jf3yOYZNeXjLP1LN3p6PuISpUUPf6Q2UrHIzqRXmtUgPXq79XRVVQAWajEEiS7Rle2a0YiQEBg2/ma822O+l8QF/ssXzLgPWc7aAlCgeHdtLUroPkrVIWDkxZm2Vwmp/21uWasucKp40a/dg3VuEFI4QTytk4L1BO9Sw1bx+2QSkN08HQW+Bv2ecj0d8e6ccrVgi4Gh5KkMMs4qqi1ezqEiu+uiBNh08K8RMF3RXeHcQEKy+/BcPN6iGhwzBDOIHANFHqdvVw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tos3S-0000OE-Q8 for guix-patches@gnu.org; Sun, 02 Mar 2025 17:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76694] [PATCH] packages: Honor system and target system for graft replacements. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 02 Mar 2025 22:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 76694 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76694@debbugs.gnu.org Cc: David Elsing X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17409554881401 (code B ref -1); Sun, 02 Mar 2025 22:45:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 Mar 2025 22:44:48 +0000 Received: from localhost ([127.0.0.1]:38381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tos3D-0000MX-Fv for submit@debbugs.gnu.org; Sun, 02 Mar 2025 17:44:48 -0500 Received: from lists.gnu.org ([2001:470:142::17]:58492) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tos39-0000L7-8U for submit@debbugs.gnu.org; Sun, 02 Mar 2025 17:44:45 -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 1tos33-0005Q3-KF for guix-patches@gnu.org; Sun, 02 Mar 2025 17:44:37 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tos31-0007Bc-9U for guix-patches@gnu.org; Sun, 02 Mar 2025 17:44:37 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 47605240027 for ; Sun, 2 Mar 2025 23:44:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1740955472; bh=OgW3PdE3BzRJBRyvDVS12ZtjGQfcxYi2TDuxOXGe+fg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=jbP70Hq/uV8P+5Gc9Z5yj1DuYLwyNi1/v1oWbVThhmEQ/QkG+16/EZfr+M6dRk/BR SJJF8AZ5ISyX7msAM5SrEDWBHEzHuU/RpY+EYoux1QQJheYS4c6Y0jsUiR7eoRNZ7A oVEttEf+OjeodMh9rHKCYWQptrUsf/wCitLdRDNFL5vgSdiBgjQQB0lp1r00HyHc9P bZI8EQn3CerGVdD6TW8VTyR252ua2AIKcybNe7Im0Si8FOGF4X1JUzarg936hCaGU7 lZ4v+49Um34rrwkeNjc4/WRK2Lwlpp1U8OP2G5IxaDypAi1RkUFFYDJ60yjpW2LyGm kXJS7AZ8twWUQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Z5cSt3g3Tz9rxD; Sun, 2 Mar 2025 23:44:30 +0100 (CET) From: David Elsing Date: Sun, 2 Mar 2025 22:43:30 +0000 Message-ID: <20250302224357.23572-1-david.elsing@posteo.net> MIME-Version: 1.0 Received-SPF: pass client-ip=185.67.36.65; envelope-from=david.elsing@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -53 X-Spam_score: -5.4 X-Spam_bar: ----- X-Spam_report: (-5.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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 (input-graft, input-cross-graft): Wrap graft replacement in ‘with-parameters’. * tests/packages.scm ("package-grafts, indirect grafts") ("package-grafts, indirect grafts, propagated inputs") ("package-grafts, same replacement twice") ("package-grafts, dependency on several outputs") ("replacement also grafted"): Adjust accordingly by comparing the replacement after lowering to a derivation. ("package-grafts, indirect grafts, #:system argument"): New test. --- The modified tests are now more expensive, because comparing the replacements now needs to be done by comparing the resulting derivations due to the wrapping in . This requires building the original package. guix/packages.scm | 9 ++++++-- tests/packages.scm | 52 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index bdcea66f77..70ccd8a924 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1824,7 +1824,9 @@ (define (input-graft system) (return (graft (origin orig) (origin-output output) - (replacement replacement) + (replacement + (with-parameters ((%current-system system)) + replacement)) (replacement-output output)))) package output system) (return #f)))) @@ -1846,7 +1848,10 @@ (define (input-cross-graft target system) (return (graft (origin orig) (origin-output output) - (replacement replacement) + (replacement + (with-parameters ((%current-system system) + (%current-target-system target)) + replacement)) (replacement-output output)))) (return #f)))) (_ diff --git a/tests/packages.scm b/tests/packages.scm index 2863fb5991..50c1cab915 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Maxime Devos ;;; Copyright © 2023 Simon Tournier +;;; Copyright © 2025 David Elsing ;;; ;;; This file is part of GNU Guix. ;;; @@ -1095,7 +1096,29 @@ (define right-system? ((graft) (and (eq? (graft-origin graft) (package-derivation %store dep)) - (eq? (graft-replacement graft) new)))))) + (eq? (run-with-store %store + (lower-object (graft-replacement graft))) + (package-derivation %store new))))))) + +(test-assert "package-grafts, indirect grafts, #:system argument" + (let* ((system (if (string=? (%current-system) "riscv64-linux") + "x86_64-linux" + "riscv64-linux")) + (new (dummy-package "dep" + (arguments `(#:implicit-inputs? #f + #:system ,system)))) + (dep (package (inherit new) (version "0.0"))) + (dep* (package (inherit dep) (replacement new))) + (dummy (dummy-package "dummy" + (arguments '(#:implicit-inputs? #f)) + (inputs (list dep*))))) + (match (package-grafts %store dummy) + ((graft) + (and (eq? (graft-origin graft) + (package-derivation %store dep system)) + (eq? (run-with-store %store + (lower-object (graft-replacement graft))) + (package-derivation %store new))))))) ;; XXX: This test would require building the cross toolchain just to see if it ;; needs grafting, which is obviously too expensive, and thus disabled. @@ -1132,7 +1155,9 @@ (define right-system? ((graft) (and (eq? (graft-origin graft) (package-derivation %store dep)) - (eq? (graft-replacement graft) new)))))) + (eq? (run-with-store %store + (lower-object (graft-replacement graft))) + (package-derivation %store new))))))) (test-assert "package-grafts, same replacement twice" (let* ((new (dummy-package "dep" @@ -1157,7 +1182,9 @@ (define right-system? (package-derivation %store (package (inherit dep) (replacement #f)))) - (eq? (graft-replacement graft) new)))))) + (eq? (run-with-store %store + (lower-object (graft-replacement graft))) + (package-derivation %store new))))))) (test-assert "package-grafts, dependency on several outputs" ;; Make sure we get one graft per output; see . @@ -1177,9 +1204,11 @@ (define right-system? ((graft1 graft2) (and (eq? (graft-origin graft1) (graft-origin graft2) (package-derivation %store p0)) - (eq? (graft-replacement graft1) - (graft-replacement graft2) - p0*) + (eq? (run-with-store %store + (lower-object (graft-replacement graft1))) + (run-with-store %store + (lower-object (graft-replacement graft2))) + (package-derivation %store p0*)) (string=? "lib" (graft-origin-output graft1) (graft-replacement-output graft1)) @@ -1256,10 +1285,17 @@ (define right-system? ((graft1 graft2) (and (eq? (graft-origin graft1) (package-derivation %store p1 #:graft? #f)) - (eq? (graft-replacement graft1) p1r) + (eq? (run-with-store %store + (lower-object (graft-replacement graft1))) + (package-derivation %store p1r #:graft? #t)) (eq? (graft-origin graft2) (package-derivation %store p2 #:graft? #f)) - (eq? (graft-replacement graft2) p2r)))))) + ;; XXX: Remove parameterize when + ;; is fixed. + (eq? (parameterize ((%graft? #t)) + (run-with-store %store + (lower-object (graft-replacement graft2)))) + (package-derivation %store p2r #:graft? #t))))))) ;;; XXX: Nowadays 'graft-derivation' needs to build derivations beforehand to ;;; find out about their run-time dependencies, so this test is no longer