From 15452f319c08f5654963dc11425eab01067df087 Mon Sep 17 00:00:00 2001 From: Sarah Morgensen Date: Tue, 3 Aug 2021 11:24:50 -0700 Subject: import: Use PARSE-COMMAND-LINE for options. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/import/go.scm (guix-import-go)[parse-options]: Use PARSE-COMMAND-LINE instead of ARGS-FOLD*. * guix/scripts/import/egg.scm (guix-import-egg)[parse-options]: Likewise. * guix/scripts/import/gem.scm (guix-import-gem)[parse-options]: Likewise. * guix/scripts/import/gnu.scm (guix-import-gnu)[parse-options]: Likewise. * guix/scripts/import/cpan.scm (guix-import-cpan)[parse-options]: Likewise. * guix/scripts/import/cran.scm (guix-import-cran)[parse-options]: Likewise. * guix/scripts/import/elpa.scm (guix-import-elpa)[parse-options]: Likewise. * guix/scripts/import/json.scm (guix-import-json)[parse-options]: Likewise. * guix/scripts/import/opam.scm (guix-import-opam)[parse-options]: Likewise. * guix/scripts/import/pypi.scm (guix-import-pypi)[parse-options]: Likewise. * guix/scripts/import/crate.scm (guix-import-crate)[parse-options]: Likewise. * guix/scripts/import/texlive.scm (guix-import-texlive)[parse-options]: Likewise. * guix/scripts/import/hackage.scm (guix-import-hackage)[parse-options]: Likewise. * guix/scripts/import/stackage.scm (guix-import-stackage)[parse-options]: Likewise. Signed-off-by: Ludovic Courtès --- guix/scripts/import/cpan.scm | 9 +++------ guix/scripts/import/cran.scm | 9 +++------ guix/scripts/import/crate.scm | 10 +++------- guix/scripts/import/egg.scm | 9 +++------ guix/scripts/import/elpa.scm | 9 +++------ guix/scripts/import/gem.scm | 9 +++------ guix/scripts/import/gnu.scm | 9 +++------ guix/scripts/import/go.scm | 9 +++------ guix/scripts/import/hackage.scm | 9 +++------ guix/scripts/import/json.scm | 9 +++------ guix/scripts/import/opam.scm | 9 +++------ guix/scripts/import/pypi.scm | 9 +++------ guix/scripts/import/stackage.scm | 9 +++------ guix/scripts/import/texlive.scm | 9 +++------ 14 files changed, 42 insertions(+), 85 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm index 77ffe1f38e..bdf5a1e423 100644 --- a/guix/scripts/import/cpan.scm +++ b/guix/scripts/import/cpan.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 Eric Bavier +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,12 +67,8 @@ Import and convert the CPAN package for PACKAGE-NAME.\n")) (define (guix-import-cpan . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm index aa3ef324e0..3e4b038cc4 100644 --- a/guix/scripts/import/cran.scm +++ b/guix/scripts/import/cran.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus ;;; Copyright © 2020 Martin Becze +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -86,12 +87,8 @@ Import and convert the CRAN package for PACKAGE-NAME.\n")) (define (guix-import-cran . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm index 3a96defb86..97152904ac 100644 --- a/guix/scripts/import/crate.scm +++ b/guix/scripts/import/crate.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2014 David Thompson ;;; Copyright © 2016 David Craven ;;; Copyright © 2019, 2020 Martin Becze +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -75,13 +76,8 @@ Import and convert the crates.io package for PACKAGE-NAME.\n")) (define (guix-import-crate . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) - + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/egg.scm b/guix/scripts/import/egg.scm index 7dbd6fcd5a..829cdc2ca0 100644 --- a/guix/scripts/import/egg.scm +++ b/guix/scripts/import/egg.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -71,12 +72,8 @@ Import and convert the egg package for PACKAGE-NAME.\n")) (define (guix-import-egg . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (repo (and=> (assoc-ref opts 'repo) string->symbol)) diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm index d6b38e5c4b..052b0cc0e7 100644 --- a/guix/scripts/import/elpa.scm +++ b/guix/scripts/import/elpa.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2018 Oleg Pykhalov ;;; Copyright © 2020 Martin Becze +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,12 +81,8 @@ Import the latest package named PACKAGE-NAME from an ELPA repository.\n")) (define (guix-import-elpa . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm index c64596b514..65d2bf10b4 100644 --- a/guix/scripts/import/gem.scm +++ b/guix/scripts/import/gem.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson ;;; Copyright © 2018 Oleg Pykhalov +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -73,12 +74,8 @@ Import and convert the RubyGems package for PACKAGE-NAME.\n")) (define (guix-import-gem . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/gnu.scm b/guix/scripts/import/gnu.scm index ae98370037..344e363abe 100644 --- a/guix/scripts/import/gnu.scm +++ b/guix/scripts/import/gnu.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2016 Ludovic Courtès +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -81,12 +82,8 @@ Return a package declaration template for PACKAGE, a GNU package.\n")) (define (guix-import-gnu . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm index 74e8e60cce..e08a1e427e 100644 --- a/guix/scripts/import/go.scm +++ b/guix/scripts/import/go.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2020 Katherine Cox-Buday ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Zheng Junjie <873216071@qq.com> +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -83,12 +84,8 @@ that are not yet in Guix")) (define (guix-import-go . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm index 906dca24b1..83128fb816 100644 --- a/guix/scripts/import/hackage.scm +++ b/guix/scripts/import/hackage.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -105,12 +106,8 @@ version.\n")) (define (guix-import-hackage . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (define (run-importer package-name opts error-fn) (let* ((arguments (list diff --git a/guix/scripts/import/json.scm b/guix/scripts/import/json.scm index d8d5c3a4af..a3b5e6d79c 100644 --- a/guix/scripts/import/json.scm +++ b/guix/scripts/import/json.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2015, 2017 Ricardo Wurmus ;;; Copyright © 2021 Simon Tournier +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -74,12 +75,8 @@ Import and convert the JSON package definition in PACKAGE-FILE.\n")) (define (guix-import-json . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm index da9392821c..64164e7cc4 100644 --- a/guix/scripts/import/opam.scm +++ b/guix/scripts/import/opam.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Julien Lepiller +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -76,12 +77,8 @@ Import and convert the opam package for PACKAGE-NAME.\n")) (define (guix-import-opam . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (repo (and=> (assoc-ref opts 'repo) string->symbol)) diff --git a/guix/scripts/import/pypi.scm b/guix/scripts/import/pypi.scm index 33167174e2..9170a0b359 100644 --- a/guix/scripts/import/pypi.scm +++ b/guix/scripts/import/pypi.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 David Thompson ;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -72,12 +73,8 @@ Import and convert the PyPI package for PACKAGE-NAME.\n")) (define (guix-import-pypi . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda diff --git a/guix/scripts/import/stackage.scm b/guix/scripts/import/stackage.scm index d77328dcbf..211ac73ada 100644 --- a/guix/scripts/import/stackage.scm +++ b/guix/scripts/import/stackage.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Federico Beffa ;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -89,12 +90,8 @@ Import and convert the LTS Stackage package for PACKAGE-NAME.\n")) (define (guix-import-stackage . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (define (run-importer package-name opts error-fn) (let* ((arguments (list diff --git a/guix/scripts/import/texlive.scm b/guix/scripts/import/texlive.scm index 1cceee7051..6f0818e274 100644 --- a/guix/scripts/import/texlive.scm +++ b/guix/scripts/import/texlive.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Ricardo Wurmus +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -73,12 +74,8 @@ Import and convert the Texlive package for PACKAGE-NAME.\n")) (define (guix-import-texlive . args) (define (parse-options) ;; Return the alist of option values. - (args-fold* args %options - (lambda (opt name arg result) - (leave (G_ "~A: unrecognized option~%") name)) - (lambda (arg result) - (alist-cons 'argument arg result)) - %default-options)) + (parse-command-line args %options (list %default-options) + #:build-options? #f)) (let* ((opts (parse-options)) (args (filter-map (match-lambda -- cgit v1.2.3 From 7bd5f72918556359e502fee73e8a7b0e725b901f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 9 Aug 2021 17:37:54 +0200 Subject: inferior: 'cached-channel-instance' no longer calls 'show-what-to-build'. This allows the user of 'cached-channel-instance' to install the build handler of its choice. In particular, it allows "guix time-machine" to install a build notifier with the right options instead of using the defaults that 'cached-channel-instance' would pass to 'show-what-to-build*'. * guix/inferior.scm (cached-channel-instance): Remove call to 'show-what-to-build*'. (inferior-for-channels): Wrap body in 'with-build-handler'. * guix/scripts/time-machine.scm (guix-time-machine): Use 'with-build-handler'. --- guix/inferior.scm | 18 ++++++++++++------ guix/scripts/time-machine.scm | 14 ++++++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) (limited to 'guix/scripts') diff --git a/guix/inferior.scm b/guix/inferior.scm index 7c8e478f2a..81958baaa5 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -48,7 +48,7 @@ #:use-module (gcrypt hash) #:autoload (guix cache) (maybe-remove-expired-cache-entries file-expiration-time) - #:autoload (guix ui) (show-what-to-build*) + #:autoload (guix ui) (build-notifier) #:autoload (guix build utils) (mkdir-p) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -801,8 +801,10 @@ determines whether CHANNELS are authenticated." (profile (channel-instances->derivation instances))) (mbegin %store-monad - (show-what-to-build* (list profile)) + ;; It's up to the caller to install a build handler to report + ;; what's going to be built. (built-derivations (list profile)) + ;; Note: Caching is fine even when AUTHENTICATE? is false because ;; we always call 'latest-channel-instances?'. (symlink* (derivation->output-path profile) cached) @@ -821,10 +823,14 @@ This is a convenience procedure that people may use in manifests passed to 'guix package -m', for instance." (define cached (with-store store - (cached-channel-instance store - channels - #:cache-directory cache-directory - #:ttl ttl))) + ;; XXX: Install a build notifier out of convenience, so users know + ;; what's going on. However, we cannot be sure that its options, such + ;; as #:use-substitutes?, correspond to the daemon's default settings. + (with-build-handler (build-notifier) + (cached-channel-instance store + channels + #:cache-directory cache-directory + #:ttl ttl)))) (open-inferior cached)) ;;; Local Variables: diff --git a/guix/scripts/time-machine.scm b/guix/scripts/time-machine.scm index 4aafd432e8..5179ea035f 100644 --- a/guix/scripts/time-machine.scm +++ b/guix/scripts/time-machine.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Konrad Hinsen -;;; Copyright © 2019, 2020 Ludovic Courtès +;;; Copyright © 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. @@ -141,13 +141,19 @@ Execute COMMAND ARGS... in an older version of Guix.\n")) (let* ((opts (parse-args args)) (channels (channel-list opts)) (command-line (assoc-ref opts 'exec)) + (substitutes? (assoc-ref opts 'substitutes?)) (authenticate? (assoc-ref opts 'authenticate-channels?))) (when command-line (let* ((directory (with-store store (with-status-verbosity (assoc-ref opts 'verbosity) - (set-build-options-from-command-line store opts) - (cached-channel-instance store channels - #:authenticate? authenticate?)))) + (with-build-handler (build-notifier #:use-substitutes? + substitutes? + #:verbosity + (assoc-ref opts 'verbosity) + #:dry-run? #f) + (set-build-options-from-command-line store opts) + (cached-channel-instance store channels + #:authenticate? authenticate?))))) (executable (string-append directory "/bin/guix"))) (apply execl (cons* executable executable command-line)))))))) -- cgit v1.2.3 From dc8451c1cd01ace41b7e1a4fe21f35ccb05b2c3a Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 9 Aug 2021 08:35:32 +0200 Subject: scripts: publish: Remove unused argument. --- guix/scripts/publish.scm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index f35f81dc34..5e1cdee17d 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -320,7 +320,7 @@ with COMPRESSION, starting at NAR-PATH." (format #f "URL: ~a~%Compression: ~a~%~@[FileSize: ~a~%~]" url (compression-type compression) file-size))) -(define* (narinfo-string store store-path key +(define* (narinfo-string store store-path #:key (compressions (list %no-compression)) (nar-path "nar") (file-sizes '())) "Generate a narinfo key/value string for STORE-PATH; an exception is raised @@ -414,7 +414,7 @@ appropriate duration. NAR-PATH specifies the prefix for nar URLs." `((cache-control (max-age . ,ttl))) '())) (cut display - (narinfo-string store store-path (%private-key) + (narinfo-string store store-path #:nar-path nar-path #:compressions compressions) <>))))) @@ -654,7 +654,6 @@ requested using POOL." (with-store store (let ((sizes (filter-map compressed-nar-size compression))) (display (narinfo-string store item - (%private-key) #:nar-path nar-path #:compressions compressions #:file-sizes sizes) -- cgit v1.2.3 From 53a487e871400fa41111f5d415b639462a334706 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Tue, 10 Aug 2021 12:00:45 +0200 Subject: scripts: publish: Remove leftover comment. * guix/scripts/publish.scm (render-narinfo/cached): Remove leftover comment. --- guix/scripts/publish.scm | 1 - 1 file changed, 1 deletion(-) (limited to 'guix/scripts') diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 5e1cdee17d..913cbd4fda 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -566,7 +566,6 @@ requested using POOL." (single-baker item ;; Check whether CACHED has been produced in the meantime. (unless (file-exists? cached) - ;; (format #t "baking ~s~%" item) (bake-narinfo+nar cache item #:ttl ttl #:compressions compressions -- cgit v1.2.3