From: "Ahmad Jarara" <ajarara@fastmail.com>
To: 51496@debbugs.gnu.org
Subject: [bug#51496] [patch] gnu: transformations: apply with-source transformations to inputs
Date: Fri, 29 Oct 2021 21:11:29 -0400 [thread overview]
Message-ID: <e778dc3c-7f39-4302-bd3a-b7691df4d38b@www.fastmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #1.2: Type: text/html, Size: 151 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-transformations-apply-with-source-transformation.patch --]
[-- Type: text/x-patch; name="0001-gnu-transformations-apply-with-source-transformation.patch", Size: 4124 bytes --]
From 234f84e6ae32131b06c86419a1c763667f1cee4e Mon Sep 17 00:00:00 2001
From: Ahmad Jarara <git@ajarara.io>
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
next reply other threads:[~2021-10-30 1:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-30 1:11 Ahmad Jarara [this message]
[not found] ` <handler.51496.B.163555633215206.ack@debbugs.gnu.org>
2021-11-01 2:09 ` [bug#51496] Acknowledgement ([patch] gnu: transformations: apply with-source transformations to inputs) Ahmad Jarara
2021-12-03 2:01 ` bug#51496: Working on another attempt with package-mapping Ahmad Jarara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e778dc3c-7f39-4302-bd3a-b7691df4d38b@www.fastmail.com \
--to=ajarara@fastmail.com \
--cc=51496@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.