GNU bug report logs -
#74475
[PATCH core-team] packages: 'package-input-rewriting/spec' optionally replace hidden.
Previous Next
Reported by: Greg Hogan <code <at> greghogan.com>
Date: Fri, 22 Nov 2024 14:30:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 74475 in the body.
You can then email your comments to 74475 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, maxim.cournoyer <at> gmail.com, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
:
bug#74475
; Package
guix-patches
.
(Fri, 22 Nov 2024 14:30:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Greg Hogan <code <at> greghogan.com>
:
New bug report received and forwarded. Copy sent to
guix <at> cbaines.net, dev <at> jpoiret.xyz, ludo <at> gnu.org, othacehe <at> gnu.org, maxim.cournoyer <at> gmail.com, zimon.toutoune <at> gmail.com, me <at> tobias.gr, guix-patches <at> gnu.org
.
(Fri, 22 Nov 2024 14:30:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Commit eee95b5a879b7096dffd533f24107cf8926b621e changed package
rewriting to ignore hidden packages. This patch permits the previous use
by adding an option to rewrite hidden packages.
* guix/packages.scm (package-input-rewriting/spec)[rewrite]: When P is
hidden, return it as-is unless #:replace-hidden? has been enabled.
* tests/packages.scm ("package-input-rewriting/spec, replace hidden
package"): New test.
* doc/guix.texi (Defining Package Variants): Update.
Change-Id: I0a7988cac70e0c6b88b0fe6e27c1036fa723e030
---
doc/guix.texi | 5 +++--
guix/packages.scm | 9 ++++++---
tests/packages.scm | 15 +++++++++++++++
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 1c39628ffa..e22bb693d7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8619,7 +8619,8 @@ Defining Package Variants
The following variant of @code{package-input-rewriting} can match packages to
be replaced by name rather than by identity.
-@deffn {Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
+@deffn {Procedure} package-input-rewriting/spec @var{replacements} @
+ [#:deep? #t] [#:replace-hidden? #t]
Return a procedure that, given a package, applies the given
@var{replacements} to all the package graph, including implicit inputs
unless @var{deep?} is false.
@@ -8628,7 +8629,7 @@ Defining Package Variants
package specification such as @code{"gcc"} or @code{"guile@@2"}, and
each procedure takes a matching package and returns a replacement for
that package. Matching packages that have the @code{hidden?} property
-set are not replaced.
+set are not replaced unless @var{replace-hidden?} is set to true.
@end deffn
The example above could be rewritten this way:
diff --git a/guix/packages.scm b/guix/packages.scm
index f373136d22..dbb8597488 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1611,14 +1611,16 @@ (define* (package-input-rewriting replacements
(package-mapping rewrite cut?
#:deep? deep?))
-(define* (package-input-rewriting/spec replacements #:key (deep? #t))
+(define* (package-input-rewriting/spec replacements
+ #:key (deep? #t) (replace-hidden? #f))
"Return a procedure that, given a package, applies the given REPLACEMENTS to
all the package graph, including implicit inputs unless DEEP? is false.
REPLACEMENTS is a list of spec/procedures pair; each spec is a package
specification such as \"gcc\" or \"guile <at> 2\", and each procedure takes a
matching package and returns a replacement for that package. Matching
-packages that have the 'hidden?' property set are not replaced."
+packages that have the 'hidden?' property set are not replaced unless
+REPLACE-HIDDEN? is set to true."
(define table
(fold (lambda (replacement table)
(match replacement
@@ -1647,7 +1649,8 @@ (define* (package-input-rewriting/spec replacements #:key (deep? #t))
(define (rewrite p)
(if (or (assq-ref (package-properties p) replacement-property)
- (hidden-package? p))
+ (and (not replace-hidden?)
+ (hidden-package? p)))
p
(match (find-replacement p)
(#f p)
diff --git a/tests/packages.scm b/tests/packages.scm
index a623628447..7c28e75c45 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -1628,6 +1628,21 @@ (define compressors '(("gzip" . "gz")
(match (delete-duplicates pythons eq?)
((p) (eq? p python)))))
+(test-assert "package-input-rewriting/spec, replace hidden package"
+ ;; Rewrite hidden packages when requested.
+ (let* ((python (hidden-package python))
+ (p0 (dummy-package "chbouib"
+ (build-system trivial-build-system)
+ (inputs (list python))))
+ (rewrite (package-input-rewriting/spec
+ `(("python" . ,(const sed)))
+ #:replace-hidden? #t))
+ (p1 (rewrite p0)))
+ (match (package-inputs p1)
+ ((("python" python))
+ (and (string=? (package-full-name python)
+ (package-full-name sed)))))))
+
(test-equal "package-input-rewriting/spec, graft"
(derivation-file-name (package-derivation %store sed))
base-commit: ba3a03151e6971bdfa9a86af5179055601042ff8
--
2.46.0
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Mon, 02 Dec 2024 11:03:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Greg Hogan <code <at> greghogan.com>
:
bug acknowledged by developer.
(Mon, 02 Dec 2024 11:03:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 74475-done <at> debbugs.gnu.org (full text, mbox):
Greg Hogan <code <at> greghogan.com> skribis:
> Commit eee95b5a879b7096dffd533f24107cf8926b621e changed package
> rewriting to ignore hidden packages. This patch permits the previous use
> by adding an option to rewrite hidden packages.
>
> * guix/packages.scm (package-input-rewriting/spec)[rewrite]: When P is
> hidden, return it as-is unless #:replace-hidden? has been enabled.
> * tests/packages.scm ("package-input-rewriting/spec, replace hidden
> package"): New test.
> * doc/guix.texi (Defining Package Variants): Update.
>
> Change-Id: I0a7988cac70e0c6b88b0fe6e27c1036fa723e030
Applied, thanks!
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 30 Dec 2024 12:24:12 GMT)
Full text and
rfc822 format available.
This bug report was last modified 166 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.