summaryrefslogtreecommitdiff
path: root/morphlib/bins.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-06-28 18:00:21 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-06-28 18:49:14 +0100
commitd32c98f4b524b56938a7d5b942b100924dc5df61 (patch)
tree09b615288f9a28b0939a4d7ead6fe304a8cefdaa /morphlib/bins.py
parente673826fbab90b1bb3b1b93277cab0e489fec190 (diff)
downloadmorph-d32c98f4b524b56938a7d5b942b100924dc5df61.tar.gz
Normalize timestamps of files in chunk artifacts
This avoids problems with clock skew between the machine that built an artifact and the machine the uses it. I ran into this problem during a test build of other changes in this patch series. We have seen it before, now it is fixed.
Diffstat (limited to 'morphlib/bins.py')
-rw-r--r--morphlib/bins.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/morphlib/bins.py b/morphlib/bins.py
index 0c9ecadf..f1d841ef 100644
--- a/morphlib/bins.py
+++ b/morphlib/bins.py
@@ -42,6 +42,12 @@ def create_chunk(rootdir, f, regexps, dump_memory_profile=None):
'''
dump_memory_profile = dump_memory_profile or (lambda msg: None )
+
+ # This timestamp is used to normalize the mtime for every file in
+ # chunk artifact. This is useful to avoid problems from smallish
+ # clock skew. It needs to be recent enough, however, that GNU tar
+ # does not complain about an implausibly old timestamp.
+ normalized_timestamp = (683074800, 683074800)
def mkrel(filename):
assert filename.startswith(rootdir)
@@ -82,6 +88,9 @@ def create_chunk(rootdir, f, regexps, dump_memory_profile=None):
include = sorted(include) # get dirs before contents
tar = tarfile.open(fileobj=f, mode='w:gz')
for filename in include:
+ # Normalize mtime for everything.
+ if not os.path.islink(filename):
+ os.utime(filename, normalized_timestamp)
tar.add(filename, arcname=mkrel(filename), recursive=False)
tar.close()