From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: [PATCH] profiles: Report about upgrades.
Date: Wed, 20 Aug 2014 16:10:10 +0400 [thread overview]
Message-ID: <87d2bvcqfx.fsf_-_@gmail.com> (raw)
In-Reply-To: <87egwgokco.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sat, 16 Aug 2014 11:27:19 +0200")
[-- Attachment #1: Type: text/plain, Size: 2029 bytes --]
Ludovic Courtès (2014-08-16 13:27 +0400) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> (define* (manifest-show-transaction manifest transaction #:key dry-run?)
>> "Display what will/would be installed/removed from MANIFEST by TRANSACTION."
>
> [...]
>
>> (format (current-error-port)
>> (N_ "The following package ~:[will~;would~] be ~a:~%~{~a~%~}~%"
>> "The following packages ~:[will~;would~] be ~a:~%~{~a~%~}~%"
>> len)
>> dry-run? action-string package-strings)))
>
> [...]
>
>> (display-entries upgrade "upgraded (removed)")
>> (display-entries install "installed")
>> (display-entries remove "removed")))
>
> Computed strings like impede correct internationalization. The whole
> sentences must be kept intact, to make sure people can translate them
> correctly. So that means repeating things a bit, but that’s
> unavoidable.
>
>> I tried to avoid the code duplicating, so it became more compact and
>> perhaps less readable. Also I added reporting about the packages to
>> upgrade: I thought as they are going to be replaced by the packages to
>> install, it is ok to add “(removed)” there. So an output should look
>> like this (assuming "file-5.17" and "guile-2.0.9" are installed and are
>> being upgraded):
>>
>> The following packages will be upgraded (removed):
>> file-5.17 out /gnu/store/...
>> guile-2.0.9 out /gnu/store/...
>>
>> The following packages will be installed:
>> file-5.18 out
>> guile-2.0.11 out
>
> Ideally, I would just like to see:
>
> The following packages will be upgraded:
> file-5.17 out /gnu/store/...
> guile-2.0.9 out /gnu/store/...
>
> and not see them listed under “will be installed.”
>
> I would just keep the current messages for this patch series, and come
> up with an improved message format in a separate patch.
Here is my try to add messages about upgraded packages. Is it OK?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-profiles-Report-about-upgrades.patch --]
[-- Type: text/x-diff, Size: 4371 bytes --]
From 54c027a227d91acccee68202c24e6ebc27c828fb Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Wed, 20 Aug 2014 15:52:36 +0400
Subject: [PATCH] profiles: Report about upgrades.
* guix/profiles.scm (manifest-show-transaction): Report about upgrades.
---
guix/profiles.scm | 56 ++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 13 deletions(-)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 7fff25a..d2d9b9e 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -275,15 +275,34 @@ Remove MANIFEST entries that have the same name and output as ENTRIES."
(define* (manifest-show-transaction store manifest transaction
#:key dry-run?)
"Display what will/would be installed/removed from MANIFEST by TRANSACTION."
- ;; TODO: Report upgrades more clearly.
- (let ((install (manifest-transaction-install transaction))
- (remove (manifest-matching-entries
- manifest (manifest-transaction-remove transaction))))
+ (define (package-strings name version output item)
+ (map (lambda (name version output item)
+ (format #f " ~a-~a\t~a\t~a" name version output
+ (if (package? item)
+ (package-output store item output)
+ item)))
+ name version output item))
+
+ (let* ((remove (manifest-matching-entries
+ manifest (manifest-transaction-remove transaction)))
+ (install/upgrade (manifest-transaction-install transaction))
+ (install '())
+ (upgrade (append-map
+ (lambda (entry)
+ (let ((matching
+ (manifest-matching-entries
+ manifest
+ (list (manifest-pattern
+ (name (manifest-entry-name entry))
+ (output (manifest-entry-output entry)))))))
+ (when (null? matching)
+ (set! install (cons entry install)))
+ matching))
+ install/upgrade)))
(match remove
- ((($ <manifest-entry> name version output path _) ..1)
+ ((($ <manifest-entry> name version output item _) ..1)
(let ((len (length name))
- (remove (map (cut format #f " ~a-~a\t~a\t~a" <> <> <> <>)
- name version output path)))
+ (remove (package-strings name version output item)))
(if dry-run?
(format (current-error-port)
(N_ "The following package would be removed:~%~{~a~%~}~%"
@@ -296,15 +315,26 @@ Remove MANIFEST entries that have the same name and output as ENTRIES."
len)
remove))))
(_ #f))
+ (match upgrade
+ ((($ <manifest-entry> name version output item _) ..1)
+ (let ((len (length name))
+ (upgrade (package-strings name version output item)))
+ (if dry-run?
+ (format (current-error-port)
+ (N_ "The following package would be upgraded:~%~{~a~%~}~%"
+ "The following packages would be upgraded:~%~{~a~%~}~%"
+ len)
+ upgrade)
+ (format (current-error-port)
+ (N_ "The following package will be upgraded:~%~{~a~%~}~%"
+ "The following packages will be upgraded:~%~{~a~%~}~%"
+ len)
+ upgrade))))
+ (_ #f))
(match install
((($ <manifest-entry> name version output item _) ..1)
(let ((len (length name))
- (install (map (lambda (name version output item)
- (format #f " ~a-~a\t~a\t~a" name version output
- (if (package? item)
- (package-output store item output)
- item)))
- name version output item)))
+ (install (package-strings name version output item)))
(if dry-run?
(format (current-error-port)
(N_ "The following package would be installed:~%~{~a~%~}~%"
--
2.0.3
next prev parent reply other threads:[~2014-08-20 12:10 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 17:58 Emacs interface for Guix Alex Kost
2014-07-25 20:36 ` Ludovic Courtès
2014-07-26 17:44 ` Alex Kost
2014-07-28 10:15 ` Alex Kost
2014-08-11 20:54 ` Ludovic Courtès
2014-08-12 10:19 ` [PATCH] " Alex Kost
2014-08-12 14:19 ` Ludovic Courtès
2014-08-12 16:20 ` Alex Kost
2014-08-12 19:50 ` Ludovic Courtès
2014-08-13 6:57 ` Alex Kost
2014-08-13 16:03 ` Ludovic Courtès
2014-08-13 20:58 ` Alex Kost
2014-08-15 5:51 ` Alex Kost
2014-08-16 9:27 ` Ludovic Courtès
2014-08-16 10:52 ` [PATCH] manifest-transaction Alex Kost
2014-08-20 12:10 ` Alex Kost [this message]
2014-08-23 11:58 ` [PATCH] profiles: Report about upgrades Ludovic Courtès
2014-08-30 19:56 ` Ludovic Courtès
2014-08-31 6:04 ` Alex Kost
2014-08-31 19:57 ` Ludovic Courtès
2014-08-31 22:54 ` Jason Self
2014-09-01 7:13 ` Alex Kost
2014-09-02 19:45 ` Ludovic Courtès
[not found] ` <87egvrke1z.fsf@gmail.com>
2014-09-04 19:37 ` Ludovic Courtès
2014-08-16 12:24 ` [PATCH] Emacs interface for Guix Ludovic Courtès
2014-08-16 13:07 ` Alex Kost
2014-08-19 21:00 ` Ludovic Courtès
2014-08-20 10:54 ` Alex Kost
2014-08-22 8:56 ` Ludovic Courtès
2014-08-22 12:44 ` Alex Kost
2014-08-27 8:34 ` Ludovic Courtès
2014-10-04 17:59 ` [PATCH] guix package: Export generation procedures Alex Kost
2014-10-04 20:23 ` Ludovic Courtès
2014-10-05 8:54 ` [PATCH] emacs: Add support for deleting generations Alex Kost
2014-10-05 13:14 ` Ludovic Courtès
2014-10-05 18:23 ` Alex Kost
2014-10-05 19:20 ` Ludovic Courtès
2014-10-05 20:04 ` Alex Kost
2014-10-06 7:36 ` Ludovic Courtès
2014-10-06 14:14 ` [PATCH] guix package: Add '--switch-generation' option Alex Kost
2014-10-06 19:27 ` Ludovic Courtès
2014-10-07 10:04 ` Alex Kost
2014-10-07 16:00 ` Ludovic Courtès
2014-10-07 21:32 ` Alex Kost
2014-10-08 9:44 ` Ludovic Courtès
2014-10-05 14:44 ` [PATCH] guix package: Export generation procedures Andreas Enge
2014-10-05 19:21 ` Ludovic Courtès
2014-07-26 20:58 ` Emacs interface for Guix Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d2bvcqfx.fsf_-_@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).