From patchwork Sat Oct 30 01:11:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmad Jarara X-Patchwork-Id: 34143 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 B912A27BBE1; Sat, 30 Oct 2021 02:13:12 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI,MIME_HTML_MOSTLY, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 0E63227BBE3 for ; Sat, 30 Oct 2021 02:13:11 +0100 (BST) Received: from localhost ([::1]:51354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgcvm-0001QF-2m for patchwork@mira.cbaines.net; Fri, 29 Oct 2021 21:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgcve-0001Pr-Ex for guix-patches@gnu.org; Fri, 29 Oct 2021 21:13:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgcve-00043A-5u for guix-patches@gnu.org; Fri, 29 Oct 2021 21:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgcve-0003yf-1l for guix-patches@gnu.org; Fri, 29 Oct 2021 21:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51496] [patch] gnu: transformations: apply with-source transformations to inputs Resent-From: "Ahmad Jarara" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 01:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51496 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51496@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163555633215206 (code B ref -1); Sat, 30 Oct 2021 01:13:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Oct 2021 01:12:12 +0000 Received: from localhost ([127.0.0.1]:56327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgcup-0003xB-Iu for submit@debbugs.gnu.org; Fri, 29 Oct 2021 21:12:11 -0400 Received: from lists.gnu.org ([209.51.188.17]:54758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgcun-0003x3-NF for submit@debbugs.gnu.org; Fri, 29 Oct 2021 21:12:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgcun-0001O3-D3 for guix-patches@gnu.org; Fri, 29 Oct 2021 21:12:09 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:42985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgcul-0002pD-97 for guix-patches@gnu.org; Fri, 29 Oct 2021 21:12:09 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5FBF45C01C8 for ; Fri, 29 Oct 2021 21:12:05 -0400 (EDT) Received: from imap46 ([10.202.2.96]) by compute4.internal (MEProxy); Fri, 29 Oct 2021 21:12:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= mime-version:message-id:date:from:to:subject:content-type; s= fm1; bh=fYU7oQ2a/HIWwBH3XWrMfklhClwEnvSUWurFIce+SDc=; b=Wtplgb8S M+r5nDCFCZxE52vIzn+6kezhgelNFEqRGT73/XuF/s9chuhjwcKHw13hplkUhqo2 DSU0A9jn+Q+Lt6GquwmPor1qJkx4CsnQmpXGnsoRGQWDG2Hr1r/nHrdoIw+slvRY 3/x+aiuDMqJHF7R/tnw/DfZvlV+fWcKQ/apVDSdzK/zDsIIipck+lpJj7zNbNu7u IyIoY5b979J15b3mhQEsIX54F7T24yxu1TY+rsXmE6OLv2cr/gPc92FIWRepjp26 g8lNxUZB4/D5cJqcY1IKMA+nxUXcRQrkzrIEa8L/849wNHiAbvxkmYph41CZYKVK 4bUZhCZGQqDQDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=fYU7oQ2a/HIWwBH3XWrMfklhClwEn vSUWurFIce+SDc=; b=H385wGw75b26PYcUYP3ubi87PnzbGdxFIE97DsX6vIz1E z5dWOB7txnxLRz2lJZc/sDGMtAu1o3pRyxrqPYuBDl3/VWkD+UORdYlpBk9q4MUr 3ZdRUE/SNzU+4YjvJvKlGi4dZj4RiPzrDr6paBSL3OLOKVrVor21QWSa+FxWTxLD TyRUOT2B/FP6Ggghshgp9lI5Sj27+lwZi6QnI8cm1aPrFaFJyTGd1CJDfflVhC0s goZ0Lda89gxDjZAQ2ZVWyU4lNRLKlEtlOkVJ7JahiATMjbnMr1Lw8oGuL4Ps9ng/ WyRWf/Y2uhkYqJmB01FaaMv8h4elRUiK4FHwcGfoQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdegiedgfeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehmtderre erredtnecuhfhrohhmpedftehhmhgrugculfgrrhgrrhgrfdcuoegrjhgrrhgrrhgrsehf rghsthhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhepfeekjedtvefgtdekteelve evfeehgfehgfekhfevvdfflefgheduueeugeeitdeinecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprghjrghrrghrrgesfhgrshhtmhgrihhlrd gtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3913E1EE0076; Fri, 29 Oct 2021 21:12:05 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1369-gd055fb5e7c-fm-20211018.002-gd055fb5e Mime-Version: 1.0 Message-Id: Date: Fri, 29 Oct 2021 21:11:29 -0400 From: "Ahmad Jarara" Received-SPF: pass client-ip=66.111.4.27; envelope-from=ajarara@fastmail.com; helo=out3-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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, HTML_MESSAGE=0.001, MIME_HTML_MOSTLY=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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" X-getmail-retrieved-from-mailbox: Patches From 234f84e6ae32131b06c86419a1c763667f1cee4e Mon Sep 17 00:00:00 2001 From: Ahmad Jarara Date: Fri, 29 Oct 2021 21:04:06 -0400 Subject: [PATCH] gnu: transformations: apply with-source transformations to inputs This patch allows for this to behave as expected: guile build guile-ssh \ --with-source=../guile-ssh \ --with-source=../libssh` Previously only the first transformation took effect. --- guix/transformations.scm | 40 ++++++++++++++++++++++++++++----------- tests/transformations.scm | 23 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/guix/transformations.scm b/guix/transformations.scm index 5ae1977cb2..08e7d0777f 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -145,18 +145,36 @@ (define new-sources (string-drop uri (+ 1 index)))))))) sources)) + (define (inject-when-applicable pkg) + (match (assoc-ref new-sources (package-name pkg)) + ((version source) + (package-with-source pkg source version)) + (#f + pkg))) + + (define (inject-new-sources pkg) + (define (inject-new-sources-for-input input) + (list (car input) (inject-new-sources (cadr input)))) + (let ((new-inputs (map inject-new-sources-for-input (package-inputs pkg))) + (new-native-inputs (map inject-new-sources-for-input (package-native-inputs pkg))) + (new-propagated-inputs (map inject-new-sources-for-input (package-propagated-inputs pkg))) + (new-pkg (inject-when-applicable pkg))) + (if (not + (and (eq? new-inputs (package-inputs pkg)) + (eq? new-native-inputs (package-native-inputs pkg)) + (eq? new-propagated-inputs (package-propagated-inputs pkg)) + (eq? new-pkg pkg))) + (package + (inherit new-pkg) + (inputs new-inputs) + (native-inputs new-native-inputs) + (propagated-inputs new-propagated-inputs)) + pkg))) + (lambda (obj) - (let loop ((sources new-sources) - (result '())) - (match obj - ((? package? p) - (match (assoc-ref sources (package-name p)) - ((version source) - (package-with-source p source version)) - (#f - p))) - (_ - obj))))) + (if (package? obj) + (inject-new-sources obj) + obj))) (define (evaluate-replacement-specs specs proc) "Parse SPECS, a list of strings like \"guile=guile@2.1\" and return a list diff --git a/tests/transformations.scm b/tests/transformations.scm index 09839dc1c5..868bcbdf7b 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -145,6 +145,29 @@ (define-module (test-transformations) (add-to-store store (basename s) #t "sha256" s))))))) +(test-assert "options->transformation, with-source, applied to package input" + (let* ((d (dummy-package "bar")) + (p (dummy-package "foo" + (inputs `(("bar" ,d))))) + (s (search-path %load-path "guix.scm")) + (f (string-append "bar=" s)) + (t (options->transformation `((with-source . ,f))))) + (with-store store + (let* ((new (t p))) + (and (not + (string=? (derivation-file-name + (package-derivation store p)) + (derivation-file-name + (package-derivation store new)))) + (string=? (derivation-file-name + (package-derivation store p)) + (derivation-file-name + (package-derivation + store + (package + (inherit new) + (inputs (package-inputs p))))))))))) + (test-assert "options->transformation, with-input" (let* ((p (dummy-package "guix.scm" (inputs `(("foo" ,(specification->package "coreutils")) base-commit: 89d8417b371f3918f0508bbc561675ec100a6add -- 2.33.1