From f0d8a8f1e5a5c69752c2c6139b6a5325734c4ba1 Mon Sep 17 00:00:00 2001 From: Vincent Legoll Date: Tue, 23 Aug 2016 15:06:12 +0200 Subject: [PATCH] Add --nodownload CLI option * guix/scripts/pull.scm (show-help, %option): add new option (guix-pull): handle --nodownload option (build-and-install): add store parameter, create $STORE/latest symlink Signed-off-by: Vincent Legoll --- guix/scripts/pull.scm | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index a4824e4..b1911ba 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -79,6 +79,8 @@ Download and deploy the latest version of Guix.\n")) --url=URL download the Guix tarball from URL")) (display (_ " --bootstrap use the bootstrap Guile to build the new Guix")) + (display (_ " + --nodownload only switch to the last downloaded version of Guix")) (newline) (display (_ " -h, --help display this help and exit")) @@ -99,6 +101,9 @@ Download and deploy the latest version of Guix.\n")) (option '("bootstrap") #f #f (lambda (opt name arg result) (alist-cons 'bootstrap? #t result))) + (option '("nodownload") #f #f + (lambda (opt name arg result) + (alist-cons 'nodownload? #t result))) (option '(#\h "help") #f #f (lambda args @@ -197,6 +202,7 @@ contained therein." (if built? (mlet* %store-monad ((latest -> (string-append config-dir "/latest")) + (latest-in-store -> (string-append %store-directory "/latest")) (done (indirect-root-added latest))) (if (and (file-exists? latest) (string=? (readlink latest) source-dir)) @@ -205,6 +211,9 @@ contained therein." (return #t)) (begin (switch-symlinks latest source-dir) + (switch-symlinks latest-in-store source-dir) + (display "symlinked: " latest source-dir) + (display "symlinked: " latest-in-store source-dir) (format #t (_ "updated ~a successfully deployed under `~a'~%") %guix-package-name latest) @@ -224,18 +233,27 @@ contained therein." (with-error-handling (let* ((opts (parse-options)) (store (open-connection)) + (config-dir (config-directory)) (url (assoc-ref opts 'tarball-url))) - (let ((tarball (download-to-store store url "guix-latest.tar.gz"))) - (unless tarball - (leave (_ "failed to download up-to-date source, exiting\n"))) - (parameterize ((%guile-for-build - (package-derivation store - (if (assoc-ref opts 'bootstrap?) - %bootstrap-guile - (canonical-package guile-2.0))))) + (if (assoc-ref opts 'nodownload?) (run-with-store store - (build-and-install tarball (config-directory) - #:verbose? (assoc-ref opts 'verbose?)))))))) + (mlet* %store-monad + ((latest -> (string-append config-dir "/latest")) + (latest-in-store -> (string-append %store-directory "/latest"))) + (begin + (switch-symlinks latest latest-in-store) + (display "symlinked: " latest latest-in-store)))) + (let ((tarball (download-to-store store url "guix-latest.tar.gz"))) + (unless tarball + (leave (_ "failed to download up-to-date source, exiting\n"))) + (parameterize ((%guile-for-build + (package-derivation store + (if (assoc-ref opts 'bootstrap?) + %bootstrap-guile + (canonical-package guile-2.0))))) + (run-with-store store + (build-and-install tarball config-dir + #:verbose? (assoc-ref opts 'verbose?))))))))) ;; Local Variables: ;; eval: (put 'with-PATH 'scheme-indent-function 1) -- 2.9.3