diff mbox series

[bug#39547,v3] sources.json: array instead of list

Message ID CAJ3okZ2UO8Wb0f8PKqiNs2_Podro23D8rpaQBD-rZ5E+TpNbTw@mail.gmail.com
State Accepted
Headers show
Series [bug#39547,v3] sources.json: array instead of list | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job

Commit Message

Simon Tournier March 2, 2020, 5:24 p.m. UTC
Hi Ludo,

Attached, the tiny modification to output the list (array) of URLs
instead of the first one.
The version number is still '1' because I do not know yet if lewo would bump it.
Note also that "transformer" is not useful any more because
'packages-json-builder' and 'sources-json-builder' returns both
vectors now.


Cheers,
simon

Comments

Ludovic Courtès March 6, 2020, 11:01 a.m. UTC | #1
Hi!

zimoun <zimon.toutoune@gmail.com> skribis:

> Attached, the tiny modification to output the list (array) of URLs
> instead of the first one.
> The version number is still '1' because I do not know yet if lewo would bump it.
> Note also that "transformer" is not useful any more because
> 'packages-json-builder' and 'sources-json-builder' returns both
> vectors now.

Cool.

> From 57a444f6f215fb6327719161a6e6ad4ad229273f Mon Sep 17 00:00:00 2001
> From: zimoun <zimon.toutoune@gmail.com>
> Date: Mon, 10 Feb 2020 17:52:13 +0100
> Subject: [PATCH v3 1/2] website: Refactor and resolve mirror:// of JSON
>  package list.
>
> * website/apps/packages/builder.scm (origin->json): New procedure.

LGTM!

> From 73557bc00760b4404bfe17ecb3aca983c6dcc11e Mon Sep 17 00:00:00 2001
> From: zimoun <zimon.toutoune@gmail.com>
> Date: Tue, 18 Feb 2020 13:25:14 +0100
> Subject: [PATCH v3 2/2] website: Provide JSON sources list used by Software
>  Heritage.
>
> Format discussed here <https://forge.softwareheritage.org/D2025#51269>.
>
> * website/apps/packages/builder.scm (origin->json): Add list modifier.
> * website/apps/packages/builder.scm (sources-json-builder): New procedure.

Nitpick: no need to repeat the file name here.

Also: please mention the addition to the ‘builder’ procedure.

> +(define* (origin->json origin #:optional (transformer list->vector))

You can remove this parameter, as you wrote.

I can make these changes and push it on your behalf if you want, let me
know!

Thanks,
Ludo’.
Simon Tournier March 7, 2020, 10:17 p.m. UTC | #2
Hi Ludo,

Yes please push.

Cheers,
simon

PS: i am typing with my smartphone because i am sleeping in a hospital
(Purpan, Toulouse). I lose part of sensitivity and mobility of my right arm
after a shock to my neck during a basket ball party with some friends.
Everything is on the process but I cannot say when i will have access to my
laptop next ; maybe Tomorrow, maybe one week later. So please go ahead (-:

On Friday, 6 March 2020, Ludovic Courtès <ludovic.courtes@inria.fr> wrote:

> Hi!
>
> zimoun <zimon.toutoune@gmail.com> skribis:
>
> > Attached, the tiny modification to output the list (array) of URLs
> > instead of the first one.
> > The version number is still '1' because I do not know yet if lewo would
> bump it.
> > Note also that "transformer" is not useful any more because
> > 'packages-json-builder' and 'sources-json-builder' returns both
> > vectors now.
>
> Cool.
>
> > From 57a444f6f215fb6327719161a6e6ad4ad229273f Mon Sep 17 00:00:00 2001
> > From: zimoun <zimon.toutoune@gmail.com>
> > Date: Mon, 10 Feb 2020 17:52:13 +0100
> > Subject: [PATCH v3 1/2] website: Refactor and resolve mirror:// of JSON
> >  package list.
> >
> > * website/apps/packages/builder.scm (origin->json): New procedure.
>
> LGTM!
>
> > From 73557bc00760b4404bfe17ecb3aca983c6dcc11e Mon Sep 17 00:00:00 2001
> > From: zimoun <zimon.toutoune@gmail.com>
> > Date: Tue, 18 Feb 2020 13:25:14 +0100
> > Subject: [PATCH v3 2/2] website: Provide JSON sources list used by
> Software
> >  Heritage.
> >
> > Format discussed here <https://forge.softwareheritage.org/D2025#51269>.
> >
> > * website/apps/packages/builder.scm (origin->json): Add list modifier.
> > * website/apps/packages/builder.scm (sources-json-builder): New
> procedure.
>
> Nitpick: no need to repeat the file name here.
>
> Also: please mention the addition to the ‘builder’ procedure.
>
> > +(define* (origin->json origin #:optional (transformer list->vector))
>
> You can remove this parameter, as you wrote.
>
> I can make these changes and push it on your behalf if you want, let me
> know!
>
> Thanks,
> Ludo’.
>
Ludovic Courtès March 9, 2020, 9:53 a.m. UTC | #3
Hi,

zimoun <zimon.toutoune@gmail.com> skribis:

> Yes please push.

Done!  <https://guix.gnu.org/sources.json> should show up within an hour.

> PS: i am typing with my smartphone because i am sleeping in a hospital
> (Purpan, Toulouse). I lose part of sensitivity and mobility of my right arm
> after a shock to my neck during a basket ball party with some friends.
> Everything is on the process but I cannot say when i will have access to my
> laptop next ; maybe Tomorrow, maybe one week later. So please go ahead (-:

Ouch, I wish you quick recovery!

Take care of yourself,
Ludo’.
diff mbox series

Patch

From 73557bc00760b4404bfe17ecb3aca983c6dcc11e Mon Sep 17 00:00:00 2001
From: zimoun <zimon.toutoune@gmail.com>
Date: Tue, 18 Feb 2020 13:25:14 +0100
Subject: [PATCH v3 2/2] website: Provide JSON sources list used by Software
 Heritage.

Format discussed here <https://forge.softwareheritage.org/D2025#51269>.

* website/apps/packages/builder.scm (origin->json): Add list modifier.
* website/apps/packages/builder.scm (sources-json-builder): New procedure.
---
 website/apps/packages/builder.scm | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/website/apps/packages/builder.scm b/website/apps/packages/builder.scm
index d3a777e..3fc1285 100644
--- a/website/apps/packages/builder.scm
+++ b/website/apps/packages/builder.scm
@@ -74,6 +74,7 @@ 
   (flatten
    (list
     (index-builder)
+    (sources-json-builder)
     (packages-json-builder)
     (packages-builder)
     (package-list-builder))))
@@ -88,7 +89,7 @@ 
   ;; Maximum number of packages shown on /packages.
   30)
 
-(define (origin->json origin)
+(define* (origin->json origin #:optional (transformer list->vector))
     (define method
       (origin-method origin))
 
@@ -105,7 +106,7 @@ 
                      ((eq? svn-fetch method) 'svn)
                      (else                   #nil)))
       ,@(cond ((eq? url-fetch method)
-               `(("url" . ,(list->vector
+               `(("url" . ,(transformer
                             (resolve
                              (match uri
                                ((? string? url) (list url))
@@ -155,6 +156,21 @@ 
 	     (list->vector (map package->json (all-packages)))
              scm->json))
 
+(define (sources-json-builder)
+  "Return a JSON page listing all the sources.
+
+See <https://forge.softwareheritage.org/D2025#51269>."
+  (define (package->json package)
+    `(,@(if (origin? (package-source package))
+            (origin->json (package-source package))
+            `(("type" . "no-origin")
+              ("name" . ,(package-name package))))))
+
+  (make-page "sources.json"
+             `(("sources" . ,(list->vector (map package->json (all-packages))))
+               ("version" . "1"))
+             scm->json))
+
 (define (index-builder)
   "Return a Haunt page listing some random packages."
   (define (sample n from)
-- 
2.25.0