tests: nfs: Improve "nfs-root-fs".
[jackhill/guix/guix.git] / gnu / build / image.scm
index 14503b0..d8efa73 100644 (file)
@@ -77,7 +77,7 @@ take the partition metadata size into account, take a 25% margin."
         (uuid (partition-uuid partition))
         (journal-options "lazy_itable_init=1,lazy_journal_init=1"))
     (apply invoke
-           `("mke2fs" "-t" ,fs "-d" ,root
+           `("fakeroot" "mke2fs" "-t" ,fs "-d" ,root
              "-L" ,label "-U" ,(uuid->string uuid)
              "-E" ,(format #f "root_owner=~a:~a,~a"
                            owner-uid owner-gid journal-options)
@@ -93,7 +93,8 @@ take the partition metadata size into account, take a 25% margin."
   "Handle the creation of VFAT partition images.  See 'make-partition-image'."
   (let ((size (partition-size partition))
         (label (partition-label partition)))
-    (invoke "mkdosfs" "-n" label "-C" target "-F" "16" "-S" "1024"
+    (invoke "fakeroot" "mkdosfs" "-n" label "-C" target
+            "-F" "16" "-S" "1024"
             (size-in-kib
              (if (eq? size 'guess)
                  (estimate-partition-size root)
@@ -130,19 +131,23 @@ given CONFIG file."
 (define* (register-closure prefix closure
                            #:key
                            (deduplicate? #t) (reset-timestamps? #t)
-                           (schema (sql-schema)))
+                           (schema (sql-schema))
+                           (wal-mode? #t))
   "Register CLOSURE in PREFIX, where PREFIX is the directory name of the
 target store and CLOSURE is the name of a file containing a reference graph as
 produced by #:references-graphs..  As a side effect, if RESET-TIMESTAMPS? is
 true, reset timestamps on store files and, if DEDUPLICATE? is true,
-deduplicates files common to CLOSURE and the rest of PREFIX."
+deduplicates files common to CLOSURE and the rest of PREFIX.  Pass WAL-MODE?
+to call-with-database."
   (let ((items (call-with-input-file closure read-reference-graph)))
-    (register-items items
-                    #:prefix prefix
-                    #:deduplicate? deduplicate?
-                    #:reset-timestamps? reset-timestamps?
-                    #:registration-time %epoch
-                    #:schema schema)))
+    (parameterize ((sql-schema schema))
+      (with-database (store-database-file #:prefix prefix) db
+       #:wal-mode? wal-mode?
+       (register-items db items
+                       #:prefix prefix
+                       #:deduplicate? deduplicate?
+                       #:reset-timestamps? reset-timestamps?
+                       #:registration-time %epoch)))))
 
 (define* (initialize-efi-partition root
                                    #:key
@@ -161,23 +166,31 @@ deduplicates files common to CLOSURE and the rest of PREFIX."
                                     references-graphs
                                     (register-closures? #t)
                                     system-directory
+                                    make-device-nodes
+                                    (wal-mode? #t)
                                     #:allow-other-keys)
   "Initialize the given ROOT directory. Use BOOTCFG and BOOTCFG-LOCATION to
 install the bootloader configuration.
 
 If REGISTER-CLOSURES? is true, register REFERENCES-GRAPHS in the store.  If
 DEDUPLICATE? is true, then also deduplicate files common to CLOSURES and the
-rest of the store when registering the closures. SYSTEM-DIRECTORY is the name
-of the directory of the 'system' derivation."
+rest of the store when registering the closures.  SYSTEM-DIRECTORY is the name
+of the directory of the 'system' derivation.  Pass WAL-MODE? to
+register-closure."
   (populate-root-file-system system-directory root)
   (populate-store references-graphs root)
 
+  ;; Populate /dev.
+  (when make-device-nodes
+    (make-device-nodes root))
+
   (when register-closures?
     (for-each (lambda (closure)
                 (register-closure root
                                   closure
                                   #:reset-timestamps? #t
-                                  #:deduplicate? deduplicate?))
+                                  #:deduplicate? deduplicate?
+                                  #:wal-mode? wal-mode?))
               references-graphs))
 
   (when bootloader-installer