summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-12-13 17:43:02 +0100
committerLudovic Courtès <ludo@gnu.org>2021-12-13 17:48:25 +0100
commitaca2defe0172868295941fd9f0e97886f6e9b2d4 (patch)
tree2eb08a14c1f0743761aaf5125f5319edff973176
parent148a03b971b0225ee17720c8e0b69245d2b82130 (diff)
packages: 'modify-inputs' preserves and introduces input labels if needed.
Fixes a bug whereby, in an expression like this: (modify-inputs lst (delete ...) (prepend ...)) the 'delete' clause would have no effect because 'prepend' would pass it a label-less input list. * guix/packages.scm (inputs-sans-labels): Remove. (modify-inputs): In the 'prepend' and 'append' cases, preserve/add input labels instead of removing them.
-rw-r--r--guix/packages.scm16
1 files changed, 6 insertions, 10 deletions
diff --git a/guix/packages.scm b/guix/packages.scm
index b3c5a000118..b00fa2f702e 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1083,13 +1083,6 @@ otherwise."
1083otherwise." 1083otherwise."
1084 (lookup-input (package-direct-inputs package) name)) 1084 (lookup-input (package-direct-inputs package) name))
1085 1085
1086(define (inputs-sans-labels inputs)
1087 "Return INPUTS stripped of any input labels."
1088 (map (match-lambda
1089 ((label obj) obj)
1090 ((label obj output) `(,obj ,output)))
1091 inputs))
1092
1093(define (replace-input name replacement inputs) 1086(define (replace-input name replacement inputs)
1094 "Replace input NAME by REPLACEMENT within INPUTS." 1087 "Replace input NAME by REPLACEMENT within INPUTS."
1095 (map (lambda (input) 1088 (map (lambda (input)
@@ -1124,7 +1117,10 @@ inputs of Coreutils and adds libcap:
1124 (delete \"gmp\" \"acl\") 1117 (delete \"gmp\" \"acl\")
1125 (append libcap)) 1118 (append libcap))
1126 1119
1127Other types of clauses include 'prepend' and 'replace'." 1120Other types of clauses include 'prepend' and 'replace'.
1121
1122The first argument must be a labeled input list; the result is also a labeled
1123input list."
1128 ;; Note: This macro hides the fact that INPUTS, as returned by 1124 ;; Note: This macro hides the fact that INPUTS, as returned by
1129 ;; 'package-inputs' & co., is actually an alist with labels. Eventually, 1125 ;; 'package-inputs' & co., is actually an alist with labels. Eventually,
1130 ;; it will operate on list of inputs without labels. 1126 ;; it will operate on list of inputs without labels.
@@ -1135,10 +1131,10 @@ Other types of clauses include 'prepend' and 'replace'."
1135 (modify-inputs (fold alist-delete inputs (list names ...)) 1131 (modify-inputs (fold alist-delete inputs (list names ...))
1136 clauses ...)) 1132 clauses ...))
1137 ((_ inputs (prepend lst ...) clauses ...) 1133 ((_ inputs (prepend lst ...) clauses ...)
1138 (modify-inputs (append (list lst ...) (inputs-sans-labels inputs)) 1134 (modify-inputs (append (map add-input-label (list lst ...)) inputs)
1139 clauses ...)) 1135 clauses ...))
1140 ((_ inputs (append lst ...) clauses ...) 1136 ((_ inputs (append lst ...) clauses ...)
1141 (modify-inputs (append (inputs-sans-labels inputs) (list lst ...)) 1137 (modify-inputs (append inputs (map add-input-label (list lst ...)))
1142 clauses ...)) 1138 clauses ...))
1143 ((_ inputs (replace name replacement) clauses ...) 1139 ((_ inputs (replace name replacement) clauses ...)
1144 (modify-inputs (replace-input name replacement inputs) 1140 (modify-inputs (replace-input name replacement inputs)