;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
(let* ((old (dummy-package "foo" (version "1")))
(tx (mock ((gnu packages) find-best-packages-by-name
(const '()))
- ((@@ (guix scripts package) transaction-upgrade-entry)
+ (transaction-upgrade-entry
+ #f ;no store access needed
(manifest-entry
(inherit (package->manifest-entry old))
(item (string-append (%store-prefix) "/"
(manifest-transaction)))))
(manifest-transaction-null? tx)))
+(test-assert "transaction-upgrade-entry, zero upgrades, equivalent package"
+ (let* ((old (dummy-package "foo" (version "1")))
+ (drv (package-derivation %store old))
+ (tx (mock ((gnu packages) find-best-packages-by-name
+ (const (list old)))
+ (transaction-upgrade-entry
+ %store
+ (manifest-entry
+ (inherit (package->manifest-entry old))
+ (item (derivation->output-path drv)))
+ (manifest-transaction)))))
+ (manifest-transaction-null? tx)))
+
+(test-assert "transaction-upgrade-entry, zero upgrades, propagated inputs"
+ ;; Properly detect equivalent packages even when they have propagated
+ ;; inputs. See <https://bugs.gnu.org/35872>.
+ (let* ((dep (dummy-package "dep" (version "2")))
+ (old (dummy-package "foo" (version "1")
+ (propagated-inputs `(("dep" ,dep)))))
+ (drv (package-derivation %store old))
+ (tx (mock ((gnu packages) find-best-packages-by-name
+ (const (list old)))
+ (transaction-upgrade-entry
+ %store
+ (manifest-entry
+ (inherit (package->manifest-entry old))
+ (item (derivation->output-path drv))
+ (dependencies
+ (list (manifest-entry
+ (inherit (package->manifest-entry dep))
+ (item (derivation->output-path
+ (package-derivation %store dep)))))))
+ (manifest-transaction)))))
+ (manifest-transaction-null? tx)))
+
(test-assert "transaction-upgrade-entry, one upgrade"
(let* ((old (dummy-package "foo" (version "1")))
(new (dummy-package "foo" (version "2")))
(tx (mock ((gnu packages) find-best-packages-by-name
(const (list new)))
- ((@@ (guix scripts package) transaction-upgrade-entry)
+ (transaction-upgrade-entry
+ #f ;no store access needed
(manifest-entry
(inherit (package->manifest-entry old))
(item (string-append (%store-prefix) "/"
(dep (deprecated-package "foo" new))
(tx (mock ((gnu packages) find-best-packages-by-name
(const (list dep)))
- ((@@ (guix scripts package) transaction-upgrade-entry)
+ (transaction-upgrade-entry
+ #f ;no store access needed
(manifest-entry
(inherit (package->manifest-entry old))
(item (string-append (%store-prefix) "/"
(string=? (manifest-pattern-version pattern) "1")
(string=? (manifest-pattern-output pattern) "out")))))))
+(test-assert "transaction-upgrade-entry, grafts"
+ ;; Ensure that, when grafts are enabled, 'transaction-upgrade-entry' doesn't
+ ;; try to build stuff.
+ (with-build-handler (const 'failed!)
+ (parameterize ((%graft? #t))
+ (let* ((old (dummy-package "foo" (version "1")))
+ (bar (dummy-package "bar" (version "0")
+ (replacement old)))
+ (new (dummy-package "foo" (version "1")
+ (inputs `(("bar" ,bar)))))
+ (tx (mock ((gnu packages) find-best-packages-by-name
+ (const (list new)))
+ (transaction-upgrade-entry
+ %store
+ (manifest-entry
+ (inherit (package->manifest-entry old))
+ (item (string-append (%store-prefix) "/"
+ (make-string 32 #\e) "-foo-1")))
+ (manifest-transaction)))))
+ (and (match (manifest-transaction-install tx)
+ ((($ <manifest-entry> "foo" "1" "out" item))
+ (eq? item new)))
+ (null? (manifest-transaction-remove tx)))))))
+
(test-assert "package-field-location"
(let ()
(define (goto port line column)
(build-system gnu-build-system)
(supported-systems
`("does-not-exist" "foobar" ,@%supported-systems)))))
- (invalidate-memoization! package-transitive-supported-systems)
(parameterize ((%current-system "armhf-linux")) ; a traditionally-bootstrapped architecture
(package-transitive-supported-systems p))))
(build-system gnu-build-system)
(supported-systems
`("does-not-exist" "foobar" ,@%supported-systems)))))
- (invalidate-memoization! package-transitive-supported-systems)
(parameterize ((%current-system "x86_64-linux"))
(package-transitive-supported-systems p))))
(test-assert "supported-package?"
- (let ((p (dummy-package "foo"
- (build-system gnu-build-system)
- (supported-systems '("x86_64-linux" "does-not-exist")))))
+ (let* ((d (dummy-package "dep"
+ (build-system trivial-build-system)
+ (supported-systems '("x86_64-linux"))))
+ (p (dummy-package "foo"
+ (build-system gnu-build-system)
+ (inputs `(("d" ,d)))
+ (supported-systems '("x86_64-linux" "armhf-linux")))))
+ (and (supported-package? p "x86_64-linux")
+ (not (supported-package? p "i686-linux"))
+ (not (supported-package? p "armhf-linux")))))
+
+(test-assert "supported-package? vs. system-dependent graph"
+ ;; The inputs of a package can depend on (%current-system). Thus,
+ ;; 'supported-package?' must make sure that it binds (%current-system)
+ ;; appropriately before traversing the dependency graph. In the example
+ ;; below, 'supported-package?' must thus return true for both systems.
+ (let* ((p0a (dummy-package "foo-arm"
+ (build-system trivial-build-system)
+ (supported-systems '("armhf-linux"))))
+ (p0b (dummy-package "foo-x86_64"
+ (build-system trivial-build-system)
+ (supported-systems '("x86_64-linux"))))
+ (p (dummy-package "bar"
+ (build-system trivial-build-system)
+ (inputs
+ (if (string=? (%current-system) "armhf-linux")
+ `(("foo" ,p0a))
+ `(("foo" ,p0b)))))))
(and (supported-package? p "x86_64-linux")
- (not (supported-package? p "does-not-exist"))
- (not (supported-package? p "i686-linux")))))
+ (supported-package? p "armhf-linux"))))
(test-skip (if (not %store) 8 0))