GNU bug report logs -
#36919
[PATCH 0/2] Make the KDE updater find packaes in subdirectories
Previous Next
Full log
View this message in rfc822 format
Hi Hartmut,
Hartmut Goebel <h.goebel <at> crazy-compilers.com> 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’.
This bug report was last modified 5 years and 310 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.