From af735661f3829390c8e43f83873068b86509526b Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 19 Aug 2017 17:56:28 +0200 Subject: pack: Add "none" compressor. * guix/scripts/pack.scm (%compressors): Add compressor "none"; prepend extension with ".". (self-contained-tarball, docker-image): Assume compressor extensions start with period. * doc/guix.texi (Invoking guix pack): Document it. --- guix/scripts/pack.scm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'guix') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 1273c09f54..c269a1fefc 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2017 Ludovic Courtès ;;; Copyright © 2017 Efraim Flashner +;;; Copyright © 2017 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,19 +51,20 @@ (define-record-type (compressor name extension command) compressor? (name compressor-name) ;string (e.g., "gzip") - (extension compressor-extension) ;string (e.g., "lz") + (extension compressor-extension) ;string (e.g., ".lz") (command compressor-command)) ;gexp (e.g., #~("/gnu/store/…/gzip" "-9n")) (define %compressors ;; Available compression tools. - (list (compressor "gzip" "gz" + (list (compressor "gzip" ".gz" #~(#+(file-append gzip "/bin/gzip") "-9n")) - (compressor "lzip" "lz" + (compressor "lzip" ".lz" #~(#+(file-append lzip "/bin/lzip") "-9")) - (compressor "xz" "xz" + (compressor "xz" ".xz" #~(#+(file-append xz "/bin/xz") "-e -T0")) - (compressor "bzip2" "bz2" - #~(#+(file-append bzip2 "/bin/bzip2") "-9")))) + (compressor "bzip2" ".bz2" + #~(#+(file-append bzip2 "/bin/bzip2") "-9")) + (compressor "none" "" #f))) (define (lookup-compressor name) "Return the compressor object called NAME. Error out if it could not be @@ -180,7 +182,7 @@ (define tar-supports-sort? (_ #f)) directives))))))))) - (gexp->derivation (string-append name ".tar." + (gexp->derivation (string-append name ".tar" (compressor-extension compressor)) build #:references-graphs `(("profile" ,profile)))) @@ -245,7 +247,7 @@ (define build #:compressor '#$(compressor-command compressor) #:creation-time (make-time time-utc 0 1))))) - (gexp->derivation (string-append name ".tar." + (gexp->derivation (string-append name ".tar" (compressor-extension compressor)) build #:references-graphs `(("profile" ,profile)))) -- cgit v1.2.3 From a02967d77af03d6468e25d6e26dbea0db919ce96 Mon Sep 17 00:00:00 2001 From: 宋文武 Date: Sat, 19 Aug 2017 20:41:44 +0800 Subject: guix download: Support retrieving local file without the URI scheme. * 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(-) (limited to 'guix') diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm index bb3dc76741..f40213be33 100644 --- a/guix/scripts/download.scm +++ b/guix/scripts/download.scm @@ -143,12 +143,15 @@ (define (parse-options) (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 ebc853c7fa..30f55fbe2b 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 -- cgit v1.2.3