From 93596225daef5cfdbdb2d71f4b29077c520966d8 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Fri, 28 Dec 2018 16:54:04 +0000 Subject: [PATCH] build: Fix timestamp of files created by 'docker export' Currently 'docker export' is used to convert a linuxkit entry in the YAML file to a tar file of the root filesystem. This process creates a number of files and directories which have the timestamp of when the 'docker export' is run. Fix 'em up. Signed-off-by: Rolf Neugebauer --- src/cmd/linuxkit/moby/image.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cmd/linuxkit/moby/image.go b/src/cmd/linuxkit/moby/image.go index 0159823ce..624e30b34 100644 --- a/src/cmd/linuxkit/moby/image.go +++ b/src/cmd/linuxkit/moby/image.go @@ -53,6 +53,18 @@ ff02::2 ip6-allrouters `, } +// Files which may be created as part of 'docker export'. These need their timestamp fixed. +var touch = map[string]bool{ + "dev/": true, + "dev/pts/": true, + "dev/shm/": true, + "etc/": true, + "etc/mtab": true, + "etc/resolv.conf": true, + "proc/": true, + "sys/": true, +} + // tarPrefix creates the leading directories for a path func tarPrefix(path string, tw tarWriter) error { if path == "" { @@ -182,7 +194,12 @@ func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull return err } } else { - log.Debugf("image tar: %s %s add %s (original)", ref, prefix, hdr.Name) + if touch[hdr.Name] { + log.Debugf("image tar: %s %s add %s (touch)", ref, prefix, hdr.Name) + hdr.ModTime = defaultModTime + } else { + log.Debugf("image tar: %s %s add %s (original)", ref, prefix, hdr.Name) + } hdr.Name = prefix + hdr.Name if hdr.Typeflag == tar.TypeLink { // hard links are referenced by full path so need to be adjusted