summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-12-10 15:12:34 +0100
committerLudovic Courtès <ludo@gnu.org>2020-12-15 17:32:10 +0100
commit6a060ff27ff68384d7c90076baa36c349fff689d (patch)
treef7b1f9c7a52e84848fbcaa90d4dc38c25d7d65eb /gnu
parentdea1ee1fd740248307f74ca4cb70b94742264098 (diff)
store-copy: 'populate-store' can optionally deduplicate files.
Until now deduplication was performed as an additional pass after copying files, which involve re-traversing all the files that had just been copied. * guix/store/deduplication.scm (copy-file/deduplicate): New procedure. * tests/store-deduplication.scm ("copy-file/deduplicate"): New test. * guix/build/store-copy.scm (populate-store): Add #:deduplicate? parameter and honor it. * tests/gexp.scm ("gexp->derivation, store copy"): Pass #:deduplicate? #f to 'populate-store'. * gnu/build/image.scm (initialize-root-partition): Pass #:deduplicate? to 'populate-store'. Pass #:deduplicate? #f to 'register-closure'. * gnu/build/vm.scm (root-partition-initializer): Likewise. * gnu/build/install.scm (populate-single-profile-directory): Pass #:deduplicate? #f to 'populate-store'. * gnu/build/linux-initrd.scm (build-initrd): Likewise. * guix/scripts/pack.scm (self-contained-tarball)[import-module?]: New procedure. [build]: Pass it as an argument to 'source-module-closure'. * guix/scripts/pack.scm (squashfs-image)[build]: Wrap in 'with-extensions'. * gnu/system/linux-initrd.scm (expression->initrd)[import-module?]: New procedure. [builder]: Pass it to 'source-module-closure'. * gnu/system/install.scm (cow-store-service-type)[import-module?]: New procedure. Pass it to 'source-module-closure'.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/build/image.scm5
-rw-r--r--gnu/build/install.scm3
-rw-r--r--gnu/build/linux-initrd.scm3
-rw-r--r--gnu/build/vm.scm5
-rw-r--r--gnu/system/install.scm12
-rw-r--r--gnu/system/linux-initrd.scm10
6 files changed, 29 insertions, 9 deletions
diff --git a/gnu/build/image.scm b/gnu/build/image.scm
index 0deea10a9d5..8f50f27f78a 100644
--- a/gnu/build/image.scm
+++ b/gnu/build/image.scm
@@ -186,7 +186,8 @@ rest of the store when registering the closures. SYSTEM-DIRECTORY is the name
186of the directory of the 'system' derivation. Pass WAL-MODE? to 186of the directory of the 'system' derivation. Pass WAL-MODE? to
187register-closure." 187register-closure."
188 (populate-root-file-system system-directory root) 188 (populate-root-file-system system-directory root)
189 (populate-store references-graphs root) 189 (populate-store references-graphs root
190 #:deduplicate? deduplicate?)
190 191
191 ;; Populate /dev. 192 ;; Populate /dev.
192 (when make-device-nodes 193 (when make-device-nodes
@@ -195,7 +196,7 @@ register-closure."
195 (when register-closures? 196 (when register-closures?
196 (for-each (lambda (closure) 197 (for-each (lambda (closure)
197 (register-closure root closure 198 (register-closure root closure
198 #:deduplicate? deduplicate? 199 #:deduplicate? #f
199 #:wal-mode? wal-mode?)) 200 #:wal-mode? wal-mode?))
200 references-graphs)) 201 references-graphs))
201 202
diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index 63995e1d09f..f5c8407b894 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -214,7 +214,8 @@ This is used to create the self-contained tarballs with 'guix pack'."
214 (symlink old (scope new))) 214 (symlink old (scope new)))
215 215
216 ;; Populate the store. 216 ;; Populate the store.
217 (populate-store (list closure) directory) 217 (populate-store (list closure) directory
218 #:deduplicate? #f)
218 219
219 (when database 220 (when database
220 (install-database-and-gc-roots directory database profile 221 (install-database-and-gc-roots directory database profile
diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm
index 99796adba65..bb2ed0db0c7 100644
--- a/gnu/build/linux-initrd.scm
+++ b/gnu/build/linux-initrd.scm
@@ -127,7 +127,8 @@ REFERENCES-GRAPHS."
127 (mkdir "contents") 127 (mkdir "contents")
128 128
129 ;; Copy the closures of all the items referenced in REFERENCES-GRAPHS. 129 ;; Copy the closures of all the items referenced in REFERENCES-GRAPHS.
130 (populate-store references-graphs "contents") 130 (populate-store references-graphs "contents"
131 #:deduplicate? #f)
131 132
132 (with-directory-excursion "contents" 133 (with-directory-excursion "contents"
133 ;; Make '/init'. 134 ;; Make '/init'.
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index abb0317faf6..03be5697b75 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -395,7 +395,8 @@ system that is passed to 'populate-root-file-system'."
395 (when copy-closures? 395 (when copy-closures?
396 ;; Populate the store. 396 ;; Populate the store.
397 (populate-store (map (cut string-append "/xchg/" <>) closures) 397 (populate-store (map (cut string-append "/xchg/" <>) closures)
398 target)) 398 target
399 #:deduplicate? deduplicate?))
399 400
400 ;; Populate /dev. 401 ;; Populate /dev.
401 (make-device-nodes target) 402 (make-device-nodes target)
@@ -412,7 +413,7 @@ system that is passed to 'populate-root-file-system'."
412 (for-each (lambda (closure) 413 (for-each (lambda (closure)
413 (register-closure target 414 (register-closure target
414 (string-append "/xchg/" closure) 415 (string-append "/xchg/" closure)
415 #:deduplicate? deduplicate?)) 416 #:deduplicate? #f))
416 closures) 417 closures)
417 (unless copy-closures? 418 (unless copy-closures?
418 (umount target-store))) 419 (umount target-store)))
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index a6b9e3d9523..e7534634739 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4;;; Copyright © 2016 Andreas Enge <andreas@enge.fr> 4;;; Copyright © 2016 Andreas Enge <andreas@enge.fr>
5;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com> 5;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
@@ -176,6 +176,13 @@ manual."
176 (shepherd-service-type 176 (shepherd-service-type
177 'cow-store 177 'cow-store
178 (lambda _ 178 (lambda _
179 (define (import-module? module)
180 ;; Since we don't use deduplication support in 'populate-store', don't
181 ;; import (guix store deduplication) and its dependencies, which
182 ;; includes Guile-Gcrypt.
183 (and (guix-module-name? module)
184 (not (equal? module '(guix store deduplication)))))
185
179 (shepherd-service 186 (shepherd-service
180 (requirement '(root-file-system user-processes)) 187 (requirement '(root-file-system user-processes))
181 (provision '(cow-store)) 188 (provision '(cow-store))
@@ -190,7 +197,8 @@ the given target.")
190 ,@%default-modules)) 197 ,@%default-modules))
191 (start 198 (start
192 (with-imported-modules (source-module-closure 199 (with-imported-modules (source-module-closure
193 '((gnu build install))) 200 '((gnu build install))
201 #:select? import-module?)
194 #~(case-lambda 202 #~(case-lambda
195 ((target) 203 ((target)
196 (mount-cow-store target #$%backing-directory) 204 (mount-cow-store target #$%backing-directory)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 4fb1d863c9d..c6ba9bb5605 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -76,12 +76,20 @@ the derivations referenced by EXP are automatically copied to the initrd."
76 (define init 76 (define init
77 (program-file "init" exp #:guile guile)) 77 (program-file "init" exp #:guile guile))
78 78
79 (define (import-module? module)
80 ;; Since we don't use deduplication support in 'populate-store', don't
81 ;; import (guix store deduplication) and its dependencies, which includes
82 ;; Guile-Gcrypt. That way we can run tests with '--bootstrap'.
83 (and (guix-module-name? module)
84 (not (equal? module '(guix store deduplication)))))
85
79 (define builder 86 (define builder
80 ;; Do not use "guile-zlib" extension here, otherwise it would drag the 87 ;; Do not use "guile-zlib" extension here, otherwise it would drag the
81 ;; non-static "zlib" package to the initrd closure. It is not needed 88 ;; non-static "zlib" package to the initrd closure. It is not needed
82 ;; anyway because the modules are stored uncompressed within the initrd. 89 ;; anyway because the modules are stored uncompressed within the initrd.
83 (with-imported-modules (source-module-closure 90 (with-imported-modules (source-module-closure
84 '((gnu build linux-initrd))) 91 '((gnu build linux-initrd))
92 #:select? import-module?)
85 #~(begin 93 #~(begin
86 (use-modules (gnu build linux-initrd)) 94 (use-modules (gnu build linux-initrd))
87 95