diff --git a/gnu/build/linux-initrd.scm b/gnu/build/linux-initrd.scm index 815c7a0aeb..e26c067b49 100644 --- a/gnu/build/linux-initrd.scm +++ b/gnu/build/linux-initrd.scm @@ -68,7 +68,8 @@ (define files (call-with-output-file output (lambda (port) - (cpio:write-cpio-archive files port))) + (cpio:write-cpio-archive files port + #:file->header cpio:file->cpio-header*))) (or (not compress?) (and (zero? (system* gzip "--best" output)) diff --git a/guix/cpio.scm b/guix/cpio.scm index f1c2130bfa..e4692e2e9c 100644 --- a/guix/cpio.scm +++ b/guix/cpio.scm @@ -26,6 +26,7 @@ (define-module (guix cpio) #:export (cpio-header? make-cpio-header file->cpio-header + file->cpio-header* write-cpio-header read-cpio-header @@ -174,6 +175,18 @@ (define* (file->cpio-header file #:optional (file-name file) #:rdev (stat:rdev st) #:name-size (string-length file-name)))) +(define* (file->cpio-header* file + #:optional (file-name file) + #:key (stat lstat)) + "Similar to 'file->cpio-header', but return a header with a zeroed +modification time, inode number, UID/GID, etc. This allows archives to be +produced in a deterministic fashion." + (let ((st (stat file))) + (make-cpio-header #:mode (stat:mode st) + #:nlink (stat:nlink st) + #:size (stat:size st) + #:name-size (string-length file-name)))) + (define %trailer "TRAILER!!!")