[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#36919] [PATCH 1/2] gnu-maintenance: KDE updater no longer relies on
From: |
Ludovic Courtès |
Subject: |
[bug#36919] [PATCH 1/2] gnu-maintenance: KDE updater no longer relies on FTP access. |
Date: |
Sat, 17 Aug 2019 23:01:11 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hi Hartmut,
Hartmut Goebel <address@hidden> skribis:
> * guix/gnu-maintenance.scm (%kde-file-list-uri): New variable.
> (download.kde.org-files): New procedure.
> (latest-kde-release): Change to use DOWNLOAD.KDE.ORG-FILES and search
> for files in this list.
Nice!
How about moving this code to (guix import kde) as was done for (guix
import gnome) when we discussed it back then? (See
<https://issues.guix.gnu.org/issue/28159>.)
> +(define download.kde.org-files
> + (mlambda ()
> + "Return the list of files available at download.kde.org."
> + ;; XXX: Memoize the whole procedure to work around the fact that
> + ;; 'http-fetch/cached' caches the bzip2-compressed version.
> +
> + (define (canonicalize-path path)
> + (if (string-prefix? "/srv/archives/ftp/" path)
> + (set! path (string-drop path 17)))
> + (if (string-suffix? ":" path)
> + (set! path (string-drop-right path 1)))
> + (if (not (string-suffix? "/" path))
> + (set! path (string-append path "/")))
> + path)
As a rule of thumb we don’t use ‘set!’ in Guix, except in special
circumstances. In this case you can write:
(define (canonicalize-path path)
(cond ((string-prefix? …)
(string-drop path 17))
((string-suffix? …)
(string-drop-right path 1))
…))
> + (define (ls-lR-line->filename path line)
> + ;; remove mode, blocks, user, group, size, date, time and one space
> + (regexp-substitute
> + #f (string-match "^(\\S+\\s+){6}\\S+\\s" line) path 'post))
> +
> + (let ((entries `())
> + (port (decompressed-port
> + 'bzip2
> + (http-fetch/cached %kde-file-list-uri #:ttl 3600))))
What about passing ‘http-fetch/cached’ a custom #:write-cache, as is
done in (guix cve)? That would allow us to store the cached file list
in a pre-processed (and possibly decompressed) format, speeding up
operation on cache hits.
> + (do ((path (read-line port) (read-line port)))
> + ((or (eof-object? path) (string= path "")))
> + (set! path (canonicalize-path path))
I also recommend against ‘do’. You can use a “named let” loop instead,
as in:
(let loop ((files '()))
(match (read-line port)
((? eof-object?)
(reverse files))
(line
(loop (cons … files)))))
That’s about it.
Thanks!
Ludo’.