summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-02-08 18:52:00 +0100
committerLudovic Courtès <ludo@gnu.org>2015-02-08 19:00:39 +0100
commit46b23e1a436d209d6b96daee4bc398f102267502 (patch)
tree99903e4f5167d515c017a5002d014b5aa0f07b26 /guix
parent77ee4a96f4a128d2a139a1908f7b8c5d0d97d9a8 (diff)
profiles: Distinguish downgrades from upgrades.
Fixes <http://bugs.gnu.org/19764>. * guix/profiles.scm (manifest-transaction-effects): Return downgraded packages as a fourth value. * guix/ui.scm (show-manifest-transaction): Adjust accordingly. * tests/profiles.scm ("manifest-transaction-effects and downgrades"): New test.
Diffstat (limited to 'guix')
-rw-r--r--guix/profiles.scm31
-rw-r--r--guix/ui.scm20
2 files changed, 38 insertions, 13 deletions
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 921d001fa2..ac2009154f 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -303,24 +303,25 @@ no match.."
(default '())))
(define (manifest-transaction-effects manifest transaction)
- "Compute the effect of applying TRANSACTION to MANIFEST. Return 3 values:
-the list of packages that would be removed, installed, or upgraded when
-applying TRANSACTION to MANIFEST. Upgrades are represented as pairs where the
-head is the entry being upgraded and the tail is the entry that will replace
-it."
+ "Compute the effect of applying TRANSACTION to MANIFEST. Return 4 values:
+the list of packages that would be removed, installed, upgraded, or downgraded
+when applying TRANSACTION to MANIFEST. Upgrades are represented as pairs
+where the head is the entry being upgraded and the tail is the entry that will
+replace it."
(define (manifest-entry->pattern entry)
(manifest-pattern
(name (manifest-entry-name entry))
(output (manifest-entry-output entry))))
- (let loop ((input (manifest-transaction-install transaction))
- (install '())
- (upgrade '()))
+ (let loop ((input (manifest-transaction-install transaction))
+ (install '())
+ (upgrade '())
+ (downgrade '()))
(match input
(()
(let ((remove (manifest-transaction-remove transaction)))
(values (manifest-matching-entries manifest remove)
- (reverse install) (reverse upgrade))))
+ (reverse install) (reverse upgrade) (reverse downgrade))))
((entry rest ...)
;; Check whether installing ENTRY corresponds to the installation of a
;; new package or to an upgrade.
@@ -328,12 +329,18 @@ it."
;; XXX: When the exact same output directory is installed, we're not
;; really upgrading anything. Add a check for that case.
(let* ((pattern (manifest-entry->pattern entry))
- (previous (manifest-lookup manifest pattern)))
+ (previous (manifest-lookup manifest pattern))
+ (newer? (and previous
+ (version>? (manifest-entry-version entry)
+ (manifest-entry-version previous)))))
(loop rest
(if previous install (cons entry install))
- (if previous
+ (if (and previous newer?)
(alist-cons previous entry upgrade)
- upgrade)))))))
+ upgrade)
+ (if (and previous (not newer?))
+ (alist-cons previous entry downgrade)
+ downgrade)))))))
(define (manifest-perform-transaction manifest transaction)
"Perform TRANSACTION on MANIFEST and return new manifest."
diff --git a/guix/ui.scm b/guix/ui.scm
index 696d0df964..382b5b1e0d 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -416,7 +416,7 @@ replacement if PORT is not Unicode-capable."
(package-output store item output)
item)))
- (let-values (((remove install upgrade)
+ (let-values (((remove install upgrade downgrade)
(manifest-transaction-effects manifest transaction)))
(match remove
((($ <manifest-entry> name version output item) ..1)
@@ -434,6 +434,24 @@ replacement if PORT is not Unicode-capable."
len)
remove))))
(_ #f))
+ (match downgrade
+ (((($ <manifest-entry> name old-version)
+ . ($ <manifest-entry> _ new-version output item)) ..1)
+ (let ((len (length name))
+ (downgrade (map upgrade-string
+ name old-version new-version output item)))
+ (if dry-run?
+ (format (current-error-port)
+ (N_ "The following package would be downgraded:~%~{~a~%~}~%"
+ "The following packages would be downgraded:~%~{~a~%~}~%"
+ len)
+ downgrade)
+ (format (current-error-port)
+ (N_ "The following package will be downgraded:~%~{~a~%~}~%"
+ "The following packages will be downgraded:~%~{~a~%~}~%"
+ len)
+ downgrade))))
+ (_ #f))
(match upgrade
(((($ <manifest-entry> name old-version)
. ($ <manifest-entry> _ new-version output item)) ..1)