From: "Ludovic Courtès" <ludo@gnu.org>
To: 27162@debbugs.gnu.org
Subject: bug#27162: [PATCH 5/6] ui: 'show-what-to-build' warns when we don't have enough disk space.
Date: Wed, 31 May 2017 15:51:58 +0200 [thread overview]
Message-ID: <20170531135159.8186-5-ludo@gnu.org> (raw)
In-Reply-To: <20170531135159.8186-1-ludo@gnu.org>
* guix/ui.scm (check-available-space): New procedure.
(show-what-to-build): Compute 'installed-size' and call
'check-available-space'.
---
guix/ui.scm | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 04c7463fb..0e47a200c 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -38,7 +38,8 @@
#:use-module (guix serialization)
#:use-module ((guix build utils) #:select (mkdir-p))
#:use-module ((guix licenses) #:select (license? license-name))
- #:use-module ((guix build syscalls) #:select (terminal-columns))
+ #:use-module ((guix build syscalls)
+ #:select (free-disk-space terminal-columns))
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-19)
@@ -581,6 +582,17 @@ error."
(derivation->output-path derivation out-name)))
(derivation-outputs derivation))))
+(define (check-available-space need)
+ "Make sure at least NEED bytes are available in the store. Otherwise emit a
+warning."
+ (let ((free (catch 'system-error
+ (lambda ()
+ (free-disk-space (%store-prefix)))
+ (const #f))))
+ (when (and free (>= need free))
+ (warning (G_ "at least ~,1h MB needed but only ~,1h MB available in ~a~%")
+ (/ need 1e6) (/ free 1e6) (%store-prefix)))))
+
(define* (show-what-to-build store drv
#:key dry-run? (use-substitutes? #t)
(mode (build-mode normal)))
@@ -631,7 +643,9 @@ report what is prerequisites are available for download."
substitutable-references
download))))
download)))
- ;; TODO: Show the installed size of DOWNLOAD.
+ (define installed-size
+ (reduce + 0 (map substitutable-nar-size download)))
+
(define download-size
(/ (reduce + 0 (map substitutable-download-size download))
1e6))
@@ -682,6 +696,9 @@ report what is prerequisites are available for download."
(length download))
(null? download)
(map substitutable-path download)))))
+
+ (check-available-space installed-size)
+
(pair? build)))
(define show-what-to-build*
--
2.13.0
next prev parent reply other threads:[~2017-05-31 13:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-31 13:49 bug#27162: [PATCH 0/6] Display how much will be downloaded Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 1/6] derivations: 'substitution-oracle' returns a <substitutable> Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 2/6] derivations: 'derivation-prerequisites-to-build' returns <substitutable> Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 3/6] ui: 'show-what-to-build' displays how much will be downloaded Ludovic Courtès
2017-05-31 13:51 ` bug#27162: [PATCH 4/6] syscalls: Provide 'free-disk-space' Ludovic Courtès
2017-05-31 13:51 ` Ludovic Courtès [this message]
2017-05-31 13:51 ` bug#27162: [PATCH 6/6] substitute: Do not display the installed size Ludovic Courtès
2017-05-31 19:42 ` bug#27162: [PATCH 0/6] Display how much will be downloaded Maxim Cournoyer
2017-05-31 20:48 ` Ludovic Courtès
2017-05-31 21:39 ` Danny Milosavljevic
2017-05-31 22:02 ` Maxim Cournoyer
2017-06-02 16:49 ` Ludovic Courtès
2017-06-01 11:19 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170531135159.8186-5-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=27162@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.