unofficial mirror of guix-devel@gnu.org 
 help / color / Atom feed
* Latest download from website
@ 2020-06-15 15:20 Mathieu Othacehe
  2020-06-16 10:04 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Othacehe @ 2020-06-15 15:20 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]


Hello,

Here's a wip patch for the website. It adds a new "download/latest"
page allowing to download the latest Guix System images from Cuirass.

I've merged all the required mechanisms in Guix and Cuirass, now most of
the remaining work is "cosmetic" (and that's not my cup of tea).

Anyway, the patch and a screenshot are attached, please tell me what you
think.

Thanks,

Mathieu

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-wip-website-Add-latest-downloads.patch --]
[-- Type: text/x-diff, Size: 9362 bytes --]

From 1ef4c571934118deaae93f7f6eccc23ed8c32f9a Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe@gmail.com>
Date: Mon, 15 Jun 2020 17:13:25 +0200
Subject: [PATCH] wip: website: Add "latest" downloads.

---
 website/apps/base/templates/components.scm    |  12 +-
 website/apps/download/builder.scm             |   6 +-
 .../download/templates/download-latest.scm    | 159 ++++++++++++++++++
 website/static/base/css/common.css            |   5 +
 4 files changed, 180 insertions(+), 2 deletions(-)
 create mode 100644 website/apps/download/templates/download-latest.scm

diff --git a/website/apps/base/templates/components.scm b/website/apps/base/templates/components.scm
index a10fb00..3252dc7 100644
--- a/website/apps/base/templates/components.scm
+++ b/website/apps/base/templates/components.scm
@@ -290,7 +290,17 @@
      (h2 (@ (class "a11y-offset")) "Website menu:")
      (ul
       ,(menu-item #:label "Overview" #:active-item active-item #:url (guix-url))
-      ,(menu-item #:label "Download" #:active-item active-item #:url (guix-url "download/"))
+
+      ,(menu-dropdown #:label "Download"
+                      #:active-item active-item
+                      #:items
+                      (list
+                       (menu-item #:label "Stable"
+                                  #:active-item active-item
+                                  #:url (guix-url "download/"))
+                       (menu-item #:label "Latest"
+                                  #:active-item active-item
+                                  #:url (guix-url "download/latest/"))))
       ,(menu-item #:label "Packages" #:active-item active-item #:url (guix-url "packages/"))
       ,(menu-item #:label "Blog" #:active-item active-item #:url (guix-url "blog/"))
 
diff --git a/website/apps/download/builder.scm b/website/apps/download/builder.scm
index dddd0b6..cc983c5 100644
--- a/website/apps/download/builder.scm
+++ b/website/apps/download/builder.scm
@@ -4,6 +4,7 @@
 
 (define-module (apps download builder)
   #:use-module (apps download templates download)
+  #:use-module (apps download templates download-latest)
   #:use-module (apps download data)
   #:use-module (haunt html)
   #:use-module (haunt page)
@@ -30,13 +31,16 @@
    RETURN (list of <page>)
      A list of page objects that represent the web resources of the
      application. See Haunt <page> objects for more information."
-  (list (download-builder)))
+  (list (download-builder)
+        (download-latest-builder)))
 
 
 
 ;;;
 ;;; Helper builders.
 ;;;
+(define (download-latest-builder)
+  (make-page "download/latest/index.html" (download-latest-t) sxml->html))
 
 (define (download-builder)
   "Return a Haunt page representing the Download page of the website."
diff --git a/website/apps/download/templates/download-latest.scm b/website/apps/download/templates/download-latest.scm
new file mode 100644
index 0000000..c14db8e
--- /dev/null
+++ b/website/apps/download/templates/download-latest.scm
@@ -0,0 +1,159 @@
+;;; GNU Guix web site
+;;; Initially written by sirgazil who waives all
+;;; copyright interest on this file.
+;;;
+;;; This file is part of the GNU Guix web site.
+;;;
+;;; The GNU Guix web site is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU Affero General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; The GNU Guix web site is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU Affero General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Affero General Public License
+;;; along with the GNU Guix web site.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (apps download templates download-latest)
+  #:use-module (apps base templates theme)
+  #:use-module (apps base types)
+  #:use-module (apps base utils)
+  #:use-module (apps download templates components)
+  #:use-module (guix ci)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9)
+  #:use-module (ice-9 match)
+  #:export (download-latest-t))
+
+(define ci-url "https://ci.guix.gnu.org")
+
+(define-record-type <image>
+  (make-image description logo job type)
+  image?
+  (description image-description)   ;string
+  (logo        image-logo)          ;string
+  (job         image-job)           ;string
+  (type        image-type))         ;string
+
+(define images
+  (list (make-image
+         "GNU Guix System ISO-9660 image for x86_64"
+         (guix-url "static/base/img/GuixSD-package.png")
+         "iso9660-image.x86_64-linux"
+         "ISO-9660")))
+
+(define (build-detail-url url build)
+  "Return the detail page for BUILD hosted on CI server at URL."
+  (format #f "~a/build/~a/details" url (build-id build)))
+
+(define (build-product-download-url url build-product)
+  "Return a download URL for BUILD-PRODUCT hosted on CI server at URL."
+  (string-append url "/download/" (number->string
+                                   (build-product-id build-product))))
+(define* (products-latest-urls job type
+                               #:optional (limit 15)
+                               #:key url)
+  "Fetch the latest LIMIT jobs from URL matching the given JOB. Then, for the
+first job with a build output of the given TYPE, return '(DETAIL-URL
+. DOWNLOAD-URL), where DETAIL-URL is the URL describing the matching build in
+the CI, and DOWNLOAD-URL is the URL to download the build output. If no
+matching jobs are found, return an empty list."
+  ;; See build-status enumeration in (cuirass database).
+  (define build-status-success 0)
+
+  (define (find-product-by-type build-products type)
+    (find (lambda (build-product)
+            (string=? (build-product-type build-product) type))
+          build-products))
+
+  (define (latest-build-products)
+    (let ((builds
+           (latest-builds url limit
+                          #:job job
+                          #:status build-status-success)))
+      (filter-map
+       (lambda (build)
+         (let ((products (build-products build)))
+           (match products
+             (() #f)
+             (x (let ((product
+                       (find-product-by-type products type)))
+                  (and product
+                       (cons build product)))))))
+       builds)))
+
+  (match (latest-build-products)
+    (((build . product) . rest)
+     (cons
+      (build-detail-url url build)
+      (build-product-download-url url product)))
+    (_ '())))
+
+(define (image-table-row image)
+  "Return as an HTML table row, the representation of IMAGE."
+  (let* ((description (image-description image))
+         (job (image-job image))
+         (type (image-type image))
+         (logo (image-logo image))
+         (urls (products-latest-urls job type #:url ci-url)))
+    `(tr
+      (td
+       (table
+        (@ (class "download-table-box"))
+        (tbody
+         (tr
+          (td
+           (@ (class "download-table-box"))
+           (img (@ (src ,logo) (alt ""))))
+          (td
+           (@ (class "download-table-box"))
+           (h3 ,description))))))
+      ,(if (null? urls)
+           '(td "No available image")
+           (match urls
+             ((detail-url . download-url)
+              `(td
+                (a (@ (href ,download-url)) "Download")
+                " "
+                (a (@ (href ,detail-url)) "(details)"))))))))
+
+(define (download-latest-t)
+  "Return the Download latest page in SHTML."
+  (theme
+   #:title '("Download latest")
+   #:description
+   "Download latest GNU Guix System images built by the Cuirass continuous
+integration system."
+   #:keywords
+   '("GNU" "Linux" "Unix" "Free software" "Libre software"
+     "Operating system" "GNU Hurd" "GNU Guix package manager"
+     "Installer" "Source code" "Package manager")
+   #:active-menu-item "Download"
+   #:css (list
+          (guix-url "static/base/css/page.css")
+          (guix-url "static/base/css/download.css"))
+   #:crumbs (list (crumb "Download" (guix-url "download/"))
+                  (crumb "Latest" "./"))
+   #:content
+   `(main
+     (section
+      (@ (class "page"))
+      (h2 "Download latest images")
+      (p
+       (@ (class "centered-block limit-width"))
+       "Download latest GNU Guix System images built by the "
+       (a (@ (href ,(manual-url "Continuous-Integration.html"))) "Cuirass")
+       " continuous integration system at "
+       (a (@ (href ci-url)) "ci.guix.gnu.org")
+       ".")
+      (div
+       (@ (class "centered-block limit-width table-box"))
+       (table
+        (thread
+         (tr (th "image")
+             (th "download")))
+        (tbody
+         ,(map image-table-row images))))))))
diff --git a/website/static/base/css/common.css b/website/static/base/css/common.css
index 373558e..ee7a4e7 100644
--- a/website/static/base/css/common.css
+++ b/website/static/base/css/common.css
@@ -146,6 +146,11 @@
     overflow-x: auto;
 }
 
+.download-table-box {
+    border: none;
+    border-collapse: collapse;
+}
+
 .top-shadow-bg {
     background-image: url("../img/top-shadow-bg.png");
     background-repeat: repeat-x;
-- 
2.26.2


[-- Attachment #3: latest.png --]
[-- Type: image/png, Size: 96450 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Latest download from website
  2020-06-15 15:20 Latest download from website Mathieu Othacehe
@ 2020-06-16 10:04 ` Ludovic Courtès
  2020-06-18  7:24   ` Mathieu Othacehe
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2020-06-16 10:04 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: guix-devel

Hi!

Mathieu Othacehe <othacehe@gnu.org> skribis:

> Here's a wip patch for the website. It adds a new "download/latest"
> page allowing to download the latest Guix System images from Cuirass.
>
> I've merged all the required mechanisms in Guix and Cuirass, now most of
> the remaining work is "cosmetic" (and that's not my cup of tea).
>
> Anyway, the patch and a screenshot are attached, please tell me what you
> think.

That looks nice to me!  I think it should prominently say that these are
“development snapshots” (probably these two words must appear) though,
and perhaps contain a link to /download for those looking for releases.

Other than that, I’d say go for it!

Thanks,
Ludo’.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Latest download from website
  2020-06-16 10:04 ` Ludovic Courtès
@ 2020-06-18  7:24   ` Mathieu Othacehe
  2020-06-19 20:45     ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Othacehe @ 2020-06-18  7:24 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


Hey Ludo!

> That looks nice to me!  I think it should prominently say that these are
> “development snapshots” (probably these two words must appear) though,
> and perhaps contain a link to /download for those looking for releases.
>
> Other than that, I’d say go for it!

I took your remark into account and pushed. However, I missed
something. As the website is built as a derivation, there's no network
connection and the "latest-builds" request fails.

--8<---------------cut here---------------start------------->8---
ERROR: In procedure getaddrinfo:
In procedure getaddrinfo: Servname not supported for ai_socktype
building pages in '/tmp/gnu.org/software/guix'...
Backtrace:
           2 (primitive-load "/gnu/store/k2r4jxc4jww15f05n3kndxrk0a4?")
In ice-9/eval.scm:
    619:8  1 (_ #f)
In guix/build/utils.scm:
    654:6  0 (invoke _ . _)
--8<---------------cut here---------------end--------------->8---

Do you see a work-around? I could always rewrite this Guile part in
JavaScript but that would be sad!

Thanks,

Mathieu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Latest download from website
  2020-06-18  7:24   ` Mathieu Othacehe
@ 2020-06-19 20:45     ` Ludovic Courtès
  2020-06-25 10:10       ` Mathieu Othacehe
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2020-06-19 20:45 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: guix-devel

Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

>> That looks nice to me!  I think it should prominently say that these are
>> “development snapshots” (probably these two words must appear) though,
>> and perhaps contain a link to /download for those looking for releases.
>>
>> Other than that, I’d say go for it!
>
> I took your remark into account and pushed. However, I missed
> something. As the website is built as a derivation, there's no network
> connection and the "latest-builds" request fails.
>
> ERROR: In procedure getaddrinfo:
> In procedure getaddrinfo: Servname not supported for ai_socktype
> building pages in '/tmp/gnu.org/software/guix'...
> Backtrace:
>            2 (primitive-load "/gnu/store/k2r4jxc4jww15f05n3kndxrk0a4?")
> In ice-9/eval.scm:
>     619:8  1 (_ #f)
> In guix/build/utils.scm:
>     654:6  0 (invoke _ . _)
>
> Do you see a work-around?

I missed something.  Can’t we have a static page that refers to
ci.guix.gnu.org/…/latest, and Cuirass returns a redirect from /latest to
the actual URL?

Thanks,
Ludo’.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Latest download from website
  2020-06-19 20:45     ` Ludovic Courtès
@ 2020-06-25 10:10       ` Mathieu Othacehe
  2020-06-28 20:19         ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Mathieu Othacehe @ 2020-06-25 10:10 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


Hey Ludo!

> I missed something.  Can’t we have a static page that refers to
> ci.guix.gnu.org/…/latest, and Cuirass returns a redirect from /latest to
> the actual URL?

Yes in fact I missed something first :). I did add build products
support to cuirass JSON API and its Guix "latest-builds" wrapper
procedure.

Then, I patched the website so that it fetches latest builds using this
API. This means that website build needs network access, and a reachable
Cuirass server. Not great.

So, based on your suggestion I added two new routes to Cuirass:
"/search/latest" and "/search/latest/<build-product>". They allow
respectively to get details on the last build and to download any
available build product.

I updated the website to use those routes as you can see here:
https://guix.gnu.org/download/latest/.

Thanks,

Mathieu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Latest download from website
  2020-06-25 10:10       ` Mathieu Othacehe
@ 2020-06-28 20:19         ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2020-06-28 20:19 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: guix-devel

Hi!

Mathieu Othacehe <othacehe@gnu.org> skribis:

> So, based on your suggestion I added two new routes to Cuirass:
> "/search/latest" and "/search/latest/<build-product>". They allow
> respectively to get details on the last build and to download any
> available build product.
>
> I updated the website to use those routes as you can see here:
> https://guix.gnu.org/download/latest/.

Really nice.  It’ll be very helpful to get people to try out bug fixes
in the installer.  Thank you!

Ludo’.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 15:20 Latest download from website Mathieu Othacehe
2020-06-16 10:04 ` Ludovic Courtès
2020-06-18  7:24   ` Mathieu Othacehe
2020-06-19 20:45     ` Ludovic Courtès
2020-06-25 10:10       ` Mathieu Othacehe
2020-06-28 20:19         ` Ludovic Courtès

unofficial mirror of guix-devel@gnu.org 

Archives are clonable:
	git clone --mirror https://yhetil.org/guix-devel/0 guix-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-devel guix-devel/ https://yhetil.org/guix-devel \
		guix-devel@gnu.org
	public-inbox-index guix-devel

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.devel
	nntp://news.gmane.io/gmane.comp.gnu.guix.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git