unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] guix download: Support retrieving local file without the URI scheme.
@ 2017-08-20  5:15 宋文武
  2017-08-20 12:44 ` Marius Bakke
  0 siblings, 1 reply; 2+ messages in thread
From: 宋文武 @ 2017-08-20  5:15 UTC (permalink / raw)
  To: guix-devel

* guix/scripts/download.scm (guix-download): Treat the URL argument as a local
file path when it fails on 'string->uri'.  Call 'fetch' with the processed
'uri' instead of the original URL argument.
* tests/guix-download.sh: Adjust accordingly.
---
 guix/scripts/download.scm | 5 ++++-
 tests/guix-download.sh    | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index bb3dc7674..f40213be3 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -143,12 +143,15 @@ Supported formats: 'nix-base32' (default), 'base32', and 'base16'
            (arg   (or (assq-ref opts 'argument)
                       (leave (G_ "no download URI was specified~%"))))
            (uri   (or (string->uri arg)
+                      (false-if-exception
+                       (string->uri
+                        (string-append "file://" (canonicalize-path arg))))
                       (leave (G_ "~a: failed to parse URI~%")
                              arg)))
            (fetch (assq-ref opts 'download-proc))
            (path  (parameterize ((current-terminal-columns
                                   (terminal-columns)))
-                    (fetch arg
+                    (fetch (uri->string uri)
                            #:verify-certificate?
                            (assq-ref opts 'verify-certificate?))))
            (hash  (call-with-input-file
diff --git a/tests/guix-download.sh b/tests/guix-download.sh
index ebc853c7f..30f55fbe2 100644
--- a/tests/guix-download.sh
+++ b/tests/guix-download.sh
@@ -29,12 +29,15 @@ then false; else true; fi
 if guix download unknown://some/where;
 then false; else true; fi
 
-if guix download not/a/uri;
+if guix download /does-not-exist
 then false; else true; fi
 
 # This one should succeed.
 guix download "file://$abs_top_srcdir/README"
 
+# And this one, without the URI scheme.
+guix download "$abs_top_srcdir/README"
+
 # This one too, even if it cannot talk to the daemon.
 output="t-download-$$"
 trap 'rm -f "$output"' EXIT
-- 
2.13.3

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

* Re: [PATCH] guix download: Support retrieving local file without the URI scheme.
  2017-08-20  5:15 [PATCH] guix download: Support retrieving local file without the URI scheme 宋文武
@ 2017-08-20 12:44 ` Marius Bakke
  0 siblings, 0 replies; 2+ messages in thread
From: Marius Bakke @ 2017-08-20 12:44 UTC (permalink / raw)
  To: 宋文武, guix-devel

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

宋文武 <iyzsong@member.fsf.org> writes:

> * guix/scripts/download.scm (guix-download): Treat the URL argument as a local
> file path when it fails on 'string->uri'.  Call 'fetch' with the processed
> 'uri' instead of the original URL argument.
> * tests/guix-download.sh: Adjust accordingly.

Yay!  LGTM.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

end of thread, other threads:[~2017-08-20 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-20  5:15 [PATCH] guix download: Support retrieving local file without the URI scheme 宋文武
2017-08-20 12:44 ` Marius Bakke

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).