pack: Create /tmp in Docker images.
authorLudovic Courtès <ludovic.courtes@inria.fr>
Tue, 27 Aug 2019 09:27:02 +0000 (11:27 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 27 Aug 2019 10:20:44 +0000 (12:20 +0200)
Fixes <https://bugs.gnu.org/37161>.

* guix/scripts/pack.scm (docker-image)[build]: Add a 'directory' entry
for "/tmp" to DIRECTIVES.
* tests/pack.scm ("docker-image + localstatedir"): Test the presence of /tmp.
* gnu/tests/docker.scm (run-docker-test)["Load docker image and run
it"]: Test the presence and permission bits of "/tmp".

gnu/tests/docker.scm
guix/scripts/pack.scm
tests/pack.scm

index 3ec5c3d..3f98a1e 100644 (file)
@@ -100,7 +100,7 @@ inside %DOCKER-OS."
              marionette))
 
           (test-equal "Load docker image and run it"
-            '("hello world" "hi!" "JSON!")
+            '("hello world" "hi!" "JSON!" #o1777)
             (marionette-eval
              `(begin
                 (define slurp
@@ -131,8 +131,15 @@ inside %DOCKER-OS."
                                    ,(string-append #$docker-cli "/bin/docker")
                                    "run" repository&tag
                                    "-c" "(use-modules (json))
-  (display (json-string->scm (scm->json-string \"JSON!\")))")))
-                  (list response1 response2 response3)))
+  (display (json-string->scm (scm->json-string \"JSON!\")))"))
+
+                       ;; Check whether /tmp exists.
+                       (response4 (slurp
+                                   ,(string-append #$docker-cli "/bin/docker")
+                                   "run" repository&tag "-c"
+                                   "(display (stat:perms (lstat \"/tmp\")))")))
+                  (list response1 response2 response3
+                        (string->number response4))))
              marionette))
 
           (test-end)
index a15530a..dd91a24 100644 (file)
@@ -511,8 +511,10 @@ the image."
                      (,source -> ,target))))))
 
             (define directives
-              ;; Fully-qualified symlinks.
-              (append-map symlink->directives '#$symlinks))
+              ;; Create a /tmp directory, as some programs expect it, and
+              ;; create SYMLINKS.
+              `((directory "/tmp" ,(getuid) ,(getgid) #o1777)
+                ,@(append-map symlink->directives '#$symlinks)))
 
 
             (setenv "PATH" (string-append #$archiver "/bin"))
index ea88cd8..71ff5ae 100644 (file)
                          (when
                           (and (file-exists? (string-append bin "/guile"))
                                (file-exists? "var/guix/db/db.sqlite")
+                               (file-is-directory? "tmp")
                                (string=? (string-append #$%bootstrap-guile "/bin")
                                          (pk 'binlink (readlink bin)))
                                (string=? (string-append #$profile "/bin/guile")