[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ui: 'package->recutils' serializes the source field.
From: |
Alex Kost |
Subject: |
Re: [PATCH] ui: 'package->recutils' serializes the source field. |
Date: |
Sat, 06 Aug 2016 15:35:29 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
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
- How to get the package metadata as structured data?, Philippe Ombredanne, 2016/08/04
- Re: How to get the package metadata as structured data?, David Craven, 2016/08/04
- Re: How to get the package metadata as structured data?, Ludovic Courtès, 2016/08/04
- RE: How to get the package metadata as structured data?, Cook, Malcolm, 2016/08/04
- Re: How to get the package metadata as structured data?, David Craven, 2016/08/05
- Re: How to get the package metadata as structured data?, David Craven, 2016/08/05
- Re: How to get the package metadata as structured data?, Aljosha Papsch, 2016/08/05
- Re: How to get the package metadata as structured data?, Philippe Ombredanne, 2016/08/05
- [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/05
- Re: [PATCH] ui: 'package->recutils' serializes the source field.,
Alex Kost <=
- Re: [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/06
- Re: [PATCH] ui: 'package->recutils' serializes the source field., Mathieu Lirzin, 2016/08/06
- Re: [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., Mathieu Lirzin, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., Mathieu Lirzin, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., Mathieu Lirzin, 2016/08/07
- Re: [PATCH] ui: 'package->recutils' serializes the source field., David Craven, 2016/08/08