[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
12/13: database: 'register-path' resets timestamps.
From: |
Ludovic Courtès |
Subject: |
12/13: database: 'register-path' resets timestamps. |
Date: |
Fri, 1 Jun 2018 09:38:33 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 285cc75c3160421005ba0181490de4b290755b63
Author: Ludovic Courtès <address@hidden>
Date: Sun May 27 21:32:17 2018 +0200
database: 'register-path' resets timestamps.
* guix/store/database.scm (reset-timestamps): New procedure.
(register-path): Use it.
---
guix/store/database.scm | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/guix/store/database.scm b/guix/store/database.scm
index 4233219..b9745db 100644
--- a/guix/store/database.scm
+++ b/guix/store/database.scm
@@ -23,12 +23,14 @@
#:use-module (guix serialization)
#:use-module (guix base16)
#:use-module (guix hash)
+ #:use-module (guix build syscalls)
#:use-module (rnrs io ports)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-19)
#:use-module (ice-9 match)
#:export (sqlite-register
- register-path))
+ register-path
+ reset-timestamps))
;;; Code for working with the store database directly.
@@ -171,6 +173,34 @@ makes a wrapper around a port which implements
GET-POSITION."
(close-port wrapper)
(values hash size)))))
+;; TODO: Factorize with that in (gnu build install).
+(define (reset-timestamps file)
+ "Reset the modification time on FILE and on all the files it contains, if
+it's a directory."
+ (let loop ((file file)
+ (type (stat:type (lstat file))))
+ (case type
+ ((directory)
+ (utime file 0 0 0 0)
+ (let ((parent file))
+ (for-each (match-lambda
+ (("." . _) #f)
+ ((".." . _) #f)
+ ((file . properties)
+ (let ((file (string-append parent "/" file)))
+ (loop file
+ (match (assoc-ref properties 'type)
+ ((or 'unknown #f)
+ (stat:type (lstat file)))
+ (type type))))))
+ (scandir* parent))))
+ ((symlink)
+ ;; FIXME: Implement bindings for 'futime' to reset the timestamps on
+ ;; symlinks.
+ #f)
+ (else
+ (utime file 0 0 0 0)))))
+
;; TODO: make this canonicalize store items that are registered. This involves
;; setting permissions and timestamps, I think. Also, run a "deduplication
;; pass", whatever that involves. Also, handle databases not existing yet
@@ -224,6 +254,7 @@ be used internally by the daemon's build hook."
(real-path (string-append store-dir "/" (basename path))))
(let-values (((hash nar-size)
(nar-sha256 real-path)))
+ (reset-timestamps real-path)
(sqlite-register
#:db-file (string-append db-dir "/db.sqlite")
#:path to-register
- branch master updated (5d66988 -> bf5bf57), Ludovic Courtès, 2018/06/01
- 02/13: pack: Adjust test to expect relative symlinks., Ludovic Courtès, 2018/06/01
- 01/13: tests: Fix arguments in pack test., Ludovic Courtès, 2018/06/01
- 06/13: bootloader: grub: Simplify 'svg->png'., Ludovic Courtès, 2018/06/01
- 12/13: database: 'register-path' resets timestamps.,
Ludovic Courtès <=
- 05/13: tests: ssh: Use 'with-extensions'., Ludovic Courtès, 2018/06/01
- 13/13: Add (guix store deduplication)., Ludovic Courtès, 2018/06/01
- 07/13: bootloader: grub: Use 'with-extensions'., Ludovic Courtès, 2018/06/01
- 10/13: build: Check for Guile-SQLite3., Ludovic Courtès, 2018/06/01
- 08/13: profiles: Use 'with-extensions'., Ludovic Courtès, 2018/06/01
- 03/13: gexp: Add 'with-extensions'., Ludovic Courtès, 2018/06/01
- 09/13: vm: Use 'with-extensions'., Ludovic Courtès, 2018/06/01
- 04/13: pack: Use 'with-extensions' when referring to (guix docker)., Ludovic Courtès, 2018/06/01
- 11/13: Add (gnu store database)., Ludovic Courtès, 2018/06/01