all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: David Craven <david@craven.ch>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] ui: 'package->recutils' serializes the source field.
Date: Sat, 06 Aug 2016 15:35:29 +0300	[thread overview]
Message-ID: <87y44af52m.fsf@gmail.com> (raw)
In-Reply-To: <20160805145804.26753-1-david@craven.ch> (David Craven's message of "Fri, 5 Aug 2016 16:58:04 +0200")

David Craven (2016-08-05 17:58 +0300) wrote:

> * guix/ui.scm (package->recutils): Format origin.
> ---
>  guix/ui.scm | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
>
> diff --git a/guix/ui.scm b/guix/ui.scm
> index 4d1b65c..e232548 100644
> --- a/guix/ui.scm
> +++ b/guix/ui.scm
> @@ -26,6 +26,7 @@
>  (define-module (guix ui)
>    #:use-module (guix utils)
>    #:use-module (guix store)
> +  #:use-module (guix base32)
>    #:use-module (guix config)
>    #:use-module (guix packages)
>    #:use-module (guix profiles)
> @@ -33,6 +34,7 @@
>    #:use-module (guix combinators)
>    #:use-module (guix build-system)
>    #:use-module (guix serialization)
> +  #:use-module (guix git-download)
>    #:use-module ((guix build utils) #:select (mkdir-p))
>    #:use-module ((guix licenses) #:select (license? license-name))
>    #:use-module ((guix build syscalls) #:select (terminal-columns))
> @@ -878,6 +880,22 @@ WIDTH columns."
>    ;; Note: Don't i18n field names so that people can post-process it.
>    (format port "name: ~a~%" (package-name p))
>    (format port "version: ~a~%" (package-version p))
> +
> +  (let ((uri (origin-uri (package-source p))))

This will fail for some packages (for example, for 'gcc-toolchain')
because the source value can be #f, and (origin-uri #f) errors.

> +    (cond
> +      ((git-reference? uri)
> +        (begin

'begin' is not needed here.

> +          (format port "source-git-url: ~a~%"
> +                       (git-reference-url uri))
> +          (format port "source-git-commit: ~a~%"
> +                       (git-reference-commit uri))
> +          (format port "source-git-recursive: ~a~%"
> +                       (git-reference-recursive? uri))))
> +      (#t

I think using 'else' here would be more Schemey than '#t'.

> +        (format port "source-uri: ~a~%" uri))))
> +
> +  (format port "source-hash: ~a~%" (bytevector->base32-string
> +                                      (origin-sha256 (package-source p))))
>    (format port "outputs: ~a~%" (string-join (package-outputs p)))
>    (format port "systems: ~a~%"
>            (string-join (package-transitive-supported-systems p)))

After all I would write it like this:

  (let ((source (package-source p)))
    (when (origin? source)
      (let ((uri (origin-uri source)))
        (cond
         ((git-reference? uri)
          (format port "source-git-url: ~a~%"
                  (git-reference-url uri))
          (format port "source-git-commit: ~a~%"
                  (git-reference-commit uri))
          (format port "source-git-recursive: ~a~%"
                  (git-reference-recursive? uri)))
         (else
          (format port "source-uri: ~a~%" uri))))
      (format port "source-hash: ~a~%"
              (bytevector->base32-string (origin-sha256 source)))))

However, I'm not sure whether all these source things are needed to be
in the output, I would wait for other opinions.

(I agree with you though and I would like to add the same info for Emacs
interface :-))

Also note that packages may have multiple sources.  For example, for
'sudo' package, the output will be:

  source-uri: (https://www.sudo.ws/sudo/dist/sudo-1.8.17p1.tar.gz ftp://ftp.sudo.ws/pub/sudo/OLD/sudo-1.8.17p1.tar.gz)

I'm not sure if this is a desired formatting, WDYT?

-- 
Alex

  reply	other threads:[~2016-08-06 12:35 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 20:49 How to get the package metadata as structured data? David Craven
2016-08-04 21:08 ` Ludovic Courtès
2016-08-04 22:03   ` Cook, Malcolm
2016-08-05 10:17     ` David Craven
2016-08-05 11:04       ` David Craven
2016-08-05 12:40         ` Aljosha Papsch
2016-08-05 14:50         ` Philippe Ombredanne
2016-08-05 14:58           ` [PATCH] ui: 'package->recutils' serializes the source field David Craven
2016-08-06 12:35             ` Alex Kost [this message]
2016-08-06 12:46               ` David Craven
2016-08-06 15:00               ` Mathieu Lirzin
2016-08-07 10:26                 ` David Craven
2016-08-07 11:15                   ` Mathieu Lirzin
2016-08-07 11:19                     ` David Craven
2016-08-07 12:12                       ` David Craven
2016-08-07 13:27                       ` Mathieu Lirzin
2016-08-07 21:33                         ` David Craven
2016-08-08  0:15                           ` Mathieu Lirzin
2016-08-08 11:20                             ` David Craven
2016-08-08 17:53                               ` Mathieu Lirzin
2016-08-08 18:12                                 ` David Craven
2016-08-08 19:07                                 ` Alex Kost
2016-08-08 21:09                                   ` Mathieu Lirzin
2016-08-08 22:58                                     ` David Craven
2016-08-08 23:56                                       ` Mathieu Lirzin
2016-08-09  0:18                                         ` David Craven
2016-08-10 10:12                                           ` David Craven
2016-08-10 11:30                                             ` Mathieu Lirzin
2016-08-10 11:38                                               ` David Craven
2016-08-10 11:46                                                 ` David Craven
2016-08-10 12:06                                                 ` Mathieu Lirzin
2016-08-10 12:15                                                   ` Ben Woodcroft
2016-08-10 12:27                                                     ` David Craven
2016-08-10 12:53                                                       ` Ben Woodcroft
2016-08-10 13:23                                                         ` David Craven
2016-08-10 13:42                                                         ` Ricardo Wurmus
2016-08-10 14:13                                                           ` David Craven
2016-08-11 14:38                                                             ` Alex Kost
2016-08-11 16:19                                                               ` David Craven
2016-08-11 18:15                                                                 ` Ricardo Wurmus
2016-08-12  8:22                                                                 ` Alex Kost
2016-08-11 16:42                                                               ` Ricardo Wurmus
2016-08-12  8:33                                                                 ` Alex Kost
2016-08-12  8:41                                                                   ` Ricardo Wurmus
2016-08-12 10:05                                                                     ` David Craven
2016-08-13  7:46                                                                       ` Alex Kost
2016-08-13 13:00                                                                         ` David Craven
2016-08-13 13:18                                                                           ` Leo Famulari
2016-08-14 16:00                                                                             ` Alex Kost
2016-08-10 14:25                                                           ` Thompson, David
2016-08-10 17:56                                                     ` Leo Famulari
2016-08-11 10:15                             ` Mark H Weaver
2016-08-11 10:21                               ` Mark H Weaver
2016-08-11 11:06                                 ` David Craven
2016-08-11 11:41                                   ` Mark H Weaver
2016-08-11 11:46                                   ` David Craven
2016-08-10 11:46           ` How to get the package metadata as structured data? Ricardo Wurmus
2016-08-10 12:14             ` Catonano
2016-08-10 12:52               ` Ricardo Wurmus
2016-08-10 23:40                 ` Catonano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y44af52m.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=david@craven.ch \
    --cc=guix-devel@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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.