guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Emacs interface for Guix


From: Alex Kost
Subject: Re: [PATCH] Emacs interface for Guix
Date: Fri, 15 Aug 2014 09:51:21 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Alex Kost (2014-08-14 00:58 +0400) wrote:

> Ludovic Courtès (2014-08-13 20:03 +0400) wrote:
>
> [...]
>
>> Could you turn the above thing into a patch with a commit log?  Bonus
>> points for ‘manifest-perform-transaction’ unit tests.  Make sure to add
>> a copyright line for yourself in profiles.scm.
>>
>> And then a second patch to actually use it in (guix scripts package)
>> would be wonderful.  :-)
>
> Ok, I'm attaching these patches.  But there are several issues there:
>
> - I fixed a typo in "tests/profiles.scm" (“profile” -> “profiles”) – Is
>   it ok to do this in that commit or should there be a separate commit?
>
> - I added a copyright line to the test file as well.  Is it ok?
>
> - The main thing: look at ‘manifest-show-transaction’ – unlike
>   ‘show-what-to-remove/install’ it doesn't display an output path of a
>   package item, because a store should be used for that.  So is it
>   acceptable or should something be changed there?
>
>> In the next iteration, ‘show-what-to-remove/install’ should report
>> packages that are going to be upgraded (by checking among ‘install’
>> those are already in the manifest.)
>
> I'll try to do this.

Hello and pardon for replying to my own letter.

If the displaying an ouput path is not an issue, what about the
following variant of ‘manifest-show-transaction’:

(define* (manifest-show-transaction manifest transaction #:key dry-run?)
  "Display what will/would be installed/removed from MANIFEST by TRANSACTION."
  (define (display-entries entries action-string)
    (match entries
      ((($ <manifest-entry> name version output item _) ..1)
       (let ((len (length name))
             (package-strings
              (map (lambda (name version output item)
                     (if (package? item)
                         (format #f "   ~a-~a\t~a" name version output)
                         (format #f "   ~a-~a\t~a\t~a" name version output 
item)))
                   name version output item)))
         (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)))
      (_ #f)))

  (let* ((remove  (manifest-matching-entries
                   manifest (manifest-transaction-remove transaction)))
         (install (manifest-transaction-install transaction))
         (upgrade (append-map
                   (lambda (entry)
                     (manifest-matching-entries
                      manifest
                      (list (manifest-pattern
                             (name (manifest-entry-name entry))
                             (output (manifest-entry-output entry))))))
                   install)))
    (display-entries upgrade "upgraded (removed)")
    (display-entries install "installed")
    (display-entries remove "removed")))
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]