gnu: Properly credit Konrad Hinsen.
[jackhill/guix/guix.git] / guix / cpio.scm
index f1c2130..e4692e2 100644 (file)
@@ -26,6 +26,7 @@
   #:export (cpio-header?
             make-cpio-header
             file->cpio-header
+            file->cpio-header*
             write-cpio-header
             read-cpio-header
 
@@ -174,6 +175,18 @@ using FILE-NAME as its file name."
                       #: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!!!")