summaryrefslogtreecommitdiff
path: root/morphlib/builder.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-02-24 13:48:50 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-02-24 13:48:50 +0000
commit4cf7cfd1890f86de87f0b7c53d6bbd9b71e7ff35 (patch)
treeaca8472d32102120a1356545763955a23ab0e53a /morphlib/builder.py
parentd5fa85b98a213c5e8410a4a4556f65162d7ad2c7 (diff)
downloadmorph-4cf7cfd1890f86de87f0b7c53d6bbd9b71e7ff35.tar.gz
Set mtime of all files after git checkout of source tree for building
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r--morphlib/builder.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py
index dc7d51db..34b77087 100644
--- a/morphlib/builder.py
+++ b/morphlib/builder.py
@@ -19,6 +19,7 @@ import json
import logging
import os
import shutil
+import time
import morphlib
@@ -327,6 +328,7 @@ class ChunkBuilder(BlobBuilder):
morphlib.git.copy_repository(treeish, destdir, self.msg)
morphlib.git.checkout_ref(destdir, treeish.ref, self.msg)
+ self.set_mtime_recursively(destdir)
for submodule in treeish.submodules:
directory = os.path.join(destdir, submodule.path)
@@ -341,6 +343,23 @@ class ChunkBuilder(BlobBuilder):
extract_treeish(self.blob.morph.treeish, self.builddir)
+ def set_mtime_recursively(self, root):
+ '''Set the mtime for every file in a directory tree to the same.
+
+ We do this because git checkout does not set the mtime to anything,
+ and some projects (binutils, gperf for example) include formatted
+ documentation and try to randomly build things or not because of
+ the timestamps. This should help us get more reliable builds.
+
+ '''
+
+ now = time.time()
+ for dirname, subdirs, basenames in os.walk(root, topdown=False):
+ for basename in basenames:
+ pathname = os.path.join(dirname, basename)
+ os.utime(pathname, (now, now))
+ os.utime(dirname, (now, now))
+
def build_with_system_or_commands(self):
'''Run explicit commands or commands from build system.