packages: Ensure bags are insensitive to '%current-target-system'.

Fixes a bug whereby a bag's transitive dependencies would depend on the
global '%current-target-system' value.

Partly fixes <https://issues.guix.gnu.org/41182>.

* guix/packages.scm (bag-transitive-inputs)
(bag-transitive-build-inputs, bag-transitive-target-inputs):
Parameterize '%current-target-system'.
* tests/packages.scm ("package->bag, sensitivity to %current-target-system"):
New test.
This commit is contained in:
Ludovic Courtès 2020-05-14 16:03:56 +02:00
parent a89df83c79
commit f52fbf7094
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 19 additions and 3 deletions

View file

@ -814,11 +814,13 @@ (define (bag-direct-inputs bag)
(define (bag-transitive-inputs bag) (define (bag-transitive-inputs bag)
"Same as 'package-transitive-inputs', but applied to a bag." "Same as 'package-transitive-inputs', but applied to a bag."
(transitive-inputs (bag-direct-inputs bag))) (parameterize ((%current-target-system #f))
(transitive-inputs (bag-direct-inputs bag))))
(define (bag-transitive-build-inputs bag) (define (bag-transitive-build-inputs bag)
"Same as 'package-transitive-native-inputs', but applied to a bag." "Same as 'package-transitive-native-inputs', but applied to a bag."
(transitive-inputs (bag-build-inputs bag))) (parameterize ((%current-target-system #f))
(transitive-inputs (bag-build-inputs bag))))
(define (bag-transitive-host-inputs bag) (define (bag-transitive-host-inputs bag)
"Same as 'package-transitive-target-inputs', but applied to a bag." "Same as 'package-transitive-target-inputs', but applied to a bag."
@ -827,7 +829,8 @@ (define (bag-transitive-host-inputs bag)
(define (bag-transitive-target-inputs bag) (define (bag-transitive-target-inputs bag)
"Return the \"target inputs\" of BAG, recursively." "Return the \"target inputs\" of BAG, recursively."
(transitive-inputs (bag-target-inputs bag))) (parameterize ((%current-target-system (bag-target bag)))
(transitive-inputs (bag-target-inputs bag))))
(define* (package-closure packages #:key (system (%current-system))) (define* (package-closure packages #:key (system (%current-system)))
"Return the closure of PACKAGES on SYSTEM--i.e., PACKAGES and the list of "Return the closure of PACKAGES on SYSTEM--i.e., PACKAGES and the list of

View file

@ -1000,6 +1000,19 @@ (define read-at
(("dep" package) (("dep" package)
(eq? package dep))))) (eq? package dep)))))
(test-assert "package->bag, sensitivity to %current-target-system"
(let* ((dep (dummy-package "dep"
(propagated-inputs (if (%current-target-system)
`(("libxml2" ,libxml2))
'()))))
(pkg (dummy-package "foo"
(native-inputs `(("dep" ,dep)))))
(bag (package->bag pkg (%current-system) "foo86-hurd")))
(equal? (parameterize ((%current-target-system "foo64-gnu"))
(bag-transitive-inputs bag))
(parameterize ((%current-target-system #f))
(bag-transitive-inputs bag)))))
(test-assert "bag->derivation" (test-assert "bag->derivation"
(parameterize ((%graft? #f)) (parameterize ((%graft? #f))
(let ((bag (package->bag gnu-make)) (let ((bag (package->bag gnu-make))