diff options
| -rw-r--r-- | guix/build/store-copy.scm | 31 | ||||
| -rw-r--r-- | guix/scripts/system.scm | 11 |
2 files changed, 29 insertions, 13 deletions
diff --git a/guix/build/store-copy.scm b/guix/build/store-copy.scm index 7f0672cd9de..01e1f41870f 100644 --- a/guix/build/store-copy.scm +++ b/guix/build/store-copy.scm | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | file-size | 39 | file-size |
| 40 | closure-size | 40 | closure-size |
| 41 | copy-store-item | ||
| 41 | populate-store)) | 42 | populate-store)) |
| 42 | 43 | ||
| 43 | ;;; Commentary: | 44 | ;;; Commentary: |
| @@ -242,6 +243,24 @@ permissions. Write verbose output to the LOG port." | |||
| 242 | stat | 243 | stat |
| 243 | lstat))) | 244 | lstat))) |
| 244 | 245 | ||
| 246 | (define* (copy-store-item item target | ||
| 247 | #:key | ||
| 248 | (deduplicate? #t) | ||
| 249 | (log-port (%make-void-port "w"))) | ||
| 250 | "Copy ITEM, a store item, to the store under TARGET, the target root | ||
| 251 | directory. When DEDUPLICATE? is true, deduplicate it within TARGET." | ||
| 252 | (define store | ||
| 253 | (string-append target (%store-directory))) | ||
| 254 | |||
| 255 | (copy-recursively item (string-append target item) | ||
| 256 | #:keep-mtime? #t | ||
| 257 | #:keep-permissions? #t | ||
| 258 | #:copy-file | ||
| 259 | (if deduplicate? | ||
| 260 | (cut copy-file/deduplicate <> <> #:store store) | ||
| 261 | copy-file) | ||
| 262 | #:log log-port)) | ||
| 263 | |||
| 245 | (define* (populate-store reference-graphs target | 264 | (define* (populate-store reference-graphs target |
| 246 | #:key | 265 | #:key |
| 247 | (deduplicate? #t) | 266 | (deduplicate? #t) |
| @@ -273,16 +292,8 @@ regular files as they are copied to TARGET." | |||
| 273 | (call-with-progress-reporter progress | 292 | (call-with-progress-reporter progress |
| 274 | (lambda (report) | 293 | (lambda (report) |
| 275 | (for-each (lambda (thing) | 294 | (for-each (lambda (thing) |
| 276 | (copy-recursively thing | 295 | (copy-store-item thing target |
| 277 | (string-append target thing) | 296 | #:deduplicate? deduplicate?) |
| 278 | #:keep-mtime? #t | ||
| 279 | #:keep-permissions? #t | ||
| 280 | #:copy-file | ||
| 281 | (if deduplicate? | ||
| 282 | (cut copy-file/deduplicate <> <> | ||
| 283 | #:store store) | ||
| 284 | copy-file) | ||
| 285 | #:log (%make-void-port "w")) | ||
| 286 | (report)) | 297 | (report)) |
| 287 | things))))) | 298 | things))))) |
| 288 | 299 | ||
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index db80e0be8f5..c08929066b9 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #:use-module ((guix status) #:select (with-status-verbosity)) | 30 | #:use-module ((guix status) #:select (with-status-verbosity)) |
| 31 | #:use-module (guix store) | 31 | #:use-module (guix store) |
| 32 | #:autoload (guix store database) (register-path) | 32 | #:autoload (guix store database) (register-path) |
| 33 | #:autoload (guix build store-copy) (copy-store-item) | ||
| 33 | #:use-module (guix describe) | 34 | #:use-module (guix describe) |
| 34 | #:use-module (guix grafts) | 35 | #:use-module (guix grafts) |
| 35 | #:use-module (guix gexp) | 36 | #:use-module (guix gexp) |
| @@ -147,8 +148,8 @@ REFERENCES as its set of references." | |||
| 147 | #:directories? #t)) | 148 | #:directories? #t)) |
| 148 | (delete-file-recursively dest)) | 149 | (delete-file-recursively dest)) |
| 149 | 150 | ||
| 150 | (copy-recursively item dest | 151 | (copy-store-item item target |
| 151 | #:log (%make-void-port "w")) | 152 | #:deduplicate? #t) |
| 152 | 153 | ||
| 153 | ;; Register ITEM; as a side-effect, it resets timestamps, etc. | 154 | ;; Register ITEM; as a side-effect, it resets timestamps, etc. |
| 154 | ;; Explicitly use "TARGET/var/guix" as the state directory, to avoid | 155 | ;; Explicitly use "TARGET/var/guix" as the state directory, to avoid |
| @@ -157,7 +158,11 @@ REFERENCES as its set of references." | |||
| 157 | (unless (register-path item | 158 | (unless (register-path item |
| 158 | #:prefix target | 159 | #:prefix target |
| 159 | #:state-directory state | 160 | #:state-directory state |
| 160 | #:references references) | 161 | #:references references |
| 162 | |||
| 163 | ;; Those are taken care of by 'copy-store-item'. | ||
| 164 | #:reset-timestamps? #f | ||
| 165 | #:deduplicate? #f) | ||
| 161 | (leave (G_ "failed to register '~a' under '~a'~%") | 166 | (leave (G_ "failed to register '~a' under '~a'~%") |
| 162 | item target)))) | 167 | item target)))) |
| 163 | 168 | ||
