guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: scripts: environment: Display friendly container error messages.


From: David Thompson
Subject: 02/02: scripts: environment: Display friendly container error messages.
Date: Tue, 03 Nov 2015 16:43:14 +0000

davexunit pushed a commit to branch master
in repository guix.

commit 00bfa7ea25b4612d730b057308b304d0131bee03
Author: David Thompson <address@hidden>
Date:   Tue Nov 3 09:02:10 2015 -0500

    scripts: environment: Display friendly container error messages.
    
    * guix/scripts/environment.scm (assert-container-features): New
      procedure.
      (guix-environment): Use it.
---
 guix/scripts/environment.scm |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 45b54a9..97410f4 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -437,6 +437,21 @@ Otherwise, return the derivation for the Bash package."
           opts
           (alist-cons 'exec command opts)))))
 
+(define (assert-container-features)
+  "Check if containers can be created and exit with an informative error
+message if any test fails."
+  (unless (user-namespace-supported?)
+    (report-error (_ "cannot create container: user namespaces unavailable\n"))
+    (leave (_ "is your kernel version < 3.10?\n")))
+
+  (unless (unprivileged-user-namespace-supported?)
+    (report-error (_ "cannot create container: unprivileged user cannot create 
user namespaces\n"))
+    (leave (_ "please set /proc/sys/kernel/unprivileged_userns_clone to 
\"1\"\n")))
+
+  (unless (setgroups-supported?)
+    (report-error (_ "cannot create container: /proc/self/setgroups does not 
exist\n"))
+    (leave (_ "is your kernel version < 3.19?\n"))))
+
 ;; Entry point.
 (define (guix-environment . args)
   (with-error-handling
@@ -474,6 +489,9 @@ Otherwise, return the derivation for the Bash package."
                                             '()))
                                           inputs))
                         eq?)))
+
+      (when container? (assert-container-features))
+
       (with-store store
         (run-with-store store
           (mlet* %store-monad ((inputs (lower-inputs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]