From ed7d02f7c198970ce3fe94bcee47592963326446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 9 Dec 2020 22:16:35 +0100 Subject: serialization: 'restore-file' sets canonical timestamp and permissions. * guix/serialization.scm (restore-file): Set the permissions and mtime of FILE. * guix/nar.scm (finalize-store-file): Pass #:reset-timestamps? #f to 'register-items'. * tests/nar.scm (rm-rf): Add 'chmod' calls to ensure files are writable. ("write-file + restore-file with symlinks"): Ensure every file in OUTPUT passes 'canonical-file?'. * tests/guix-archive.sh: Run "chmod -R +w" before "rm -rf". --- guix/serialization.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'guix/serialization.scm') diff --git a/guix/serialization.scm b/guix/serialization.scm index cc56134ef4..677ca60b66 100644 --- a/guix/serialization.scm +++ b/guix/serialization.scm @@ -459,23 +459,27 @@ depends on TYPE." (define (restore-file port file) "Read a file (possibly a directory structure) in Nar format from PORT. -Restore it as FILE." +Restore it as FILE with canonical permissions and timestamps." (fold-archive (lambda (file type content result) (match type ('directory (mkdir file)) ('directory-complete - #t) + (chmod file #o555) + (utime file 1 1 0 0)) ('symlink - (symlink content file)) + (symlink content file) + (utime file 1 1 0 0 AT_SYMLINK_NOFOLLOW)) ((or 'regular 'executable) (match content ((input . size) (call-with-output-file file (lambda (output) (dump input output size) - (when (eq? type 'executable) - (chmod output #o755))))))))) + (chmod output (if (eq? type 'executable) + #o555 + #o444)))) + (utime file 1 1 0 0)))))) #t port file)) -- cgit v1.2.3