unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Hartmut Goebel <h.goebel@crazy-compilers.com>
Cc: 36919@debbugs.gnu.org
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	[thread overview]
Message-ID: <87k1bbcxrc.fsf@gnu.org> (raw)
In-Reply-To: <20190804102856.32609-2-h.goebel@crazy-compilers.com> (Hartmut Goebel's message of "Sun, 4 Aug 2019 12:28:55 +0200")

Hi Hartmut,

Hartmut Goebel <h.goebel@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’.

  reply	other threads:[~2019-08-17 21:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-04 10:25 [bug#36919] [PATCH 0/2] Make the KDE updater find packaes in subdirectories Hartmut Goebel
2019-08-04 10:28 ` Hartmut Goebel
2019-08-04 10:28   ` [bug#36919] [PATCH 1/2] gnu-maintenance: KDE updater no longer relies on FTP access Hartmut Goebel
2019-08-17 21:01     ` Ludovic Courtès [this message]
2019-08-27  8:11       ` Hartmut Goebel
2019-09-01 19:43         ` Ludovic Courtès
2019-08-27  8:30       ` Hartmut Goebel
2019-08-04 10:28   ` [bug#36919] [PATCH 2/2] gnu-maintenance: KDE updater finds packages even in sub-directory Hartmut Goebel
2019-09-03 12:24 ` [bug#36919] [Patch v2 0/4] Make the KDE updater find packages in subdirectories Hartmut Goebel
2019-09-03 12:24   ` [bug#36919] [Patch v2 1/4] guix: Rename and move sans-extension to tarball-sans-extension Hartmut Goebel
2019-09-03 12:24   ` [bug#36919] [Patch v2 2/4] gnu-maintenance: KDE updater no longer relies on FTP access Hartmut Goebel
2019-09-03 12:24   ` [bug#36919] [Patch v2 3/4] upstream: Move KDE updater into a separate module Hartmut Goebel
2019-09-03 12:24   ` [bug#36919] [Patch v2 4/4] import: KDE updater finds packages even in sub-directory Hartmut Goebel
2019-09-09 22:44   ` [bug#36919] [Patch v2 0/4] Make the KDE updater find packages in subdirectories Ludovic Courtès
2019-09-10 17:09     ` bug#36919: " Hartmut Goebel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1bbcxrc.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=36919@debbugs.gnu.org \
    --cc=h.goebel@crazy-compilers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).