substitute: Select the best compression methods.
authorLudovic Courtès <ludo@gnu.org>
Fri, 31 May 2019 14:26:08 +0000 (16:26 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 2 Jun 2019 20:01:57 +0000 (22:01 +0200)
commitb90ae065b5a5fab4ed475bf2faa3a84476389a02
tree306c6a49fbeb2e87d77dd2d023cc0c2a94a34afd
parentb8fa86adfc01205f1d942af8cb57515eb3726c52
substitute: Select the best compression methods.

When a server publishes several URLs with different compression methods,
'guix substitute' can now choose the best one among the compression
methods that it supports.

* guix/scripts/substitute.scm (<narinfo>)[uri]: Replace with...
[uris]: ... this.
[compression]: Replace with...
[compressions]: ... this.
[file-size]: Replace with...
[file-sizes]: ... this.
[file-hash]: Replace with...
[file-hashes]: ... this.
(narinfo-maker): Adjust accordingly.  Ensure 'file-sizes' and
'file-hashes' have the right length.
(assert-valid-signature, valid-narinfo?): Use the first element of
'narinfo-uris' in error messages.
(read-narinfo): Expect "URL", "Compression", "FileSize", and "FileHash"
to occur multiple times.
(display-narinfo-data): Call 'select-uri' to determine the file size.
(%compression-methods): New variable.
(supported-compression?, compresses-better?, select-uri): New
procedures.
(process-substitution): Call 'select-uri' to select the URI and
compression.
* guix/scripts/weather.scm (report-server-coverage): Account for all the
values returned by 'narinfo-file-sizes'.
* tests/substitute.scm ("substitute, narinfo with several URLs"): New
test.
guix/scripts/challenge.scm
guix/scripts/substitute.scm
guix/scripts/weather.scm
tests/substitute.scm