diff --git a/waflib/Scripting.py b/waflib/Scripting.py index da83a216..a80cb367 100644 --- a/waflib/Scripting.py +++ b/waflib/Scripting.py @@ -388,7 +388,11 @@ class Dist(Context.Context): for x in files: archive_name = self.get_base_name() + '/' + x.path_from(self.base_path) - zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED) + if os.environ.get('SOURCE_DATE_EPOCH'): + # TODO: parse that timestamp + zip.writestr(zipfile.ZipInfo(archive_name), x.read(), zipfile.ZIP_DEFLATED) + else: + zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED) zip.close() else: self.fatal('Valid algo types are tar.bz2, tar.gz, tar.xz or zip') @@ -425,6 +429,8 @@ class Dist(Context.Context): tinfo.gid = 0 tinfo.uname = 'root' tinfo.gname = 'root' + if os.environ.get('SOURCE_DATE_EPOCH'): + tinfo.mtime = int(os.environ.get('SOURCE_DATE_EPOCH')) if os.path.isfile(p): with open(p, 'rb') as f: diff --git a/waflib/extras/distnet.py b/waflib/extras/distnet.py index ff3ed8e1..8084b156 100644 --- a/waflib/extras/distnet.py +++ b/waflib/extras/distnet.py @@ -101,6 +101,8 @@ class package(Context.Context): tarinfo.uid = tarinfo.gid = 0 tarinfo.uname = tarinfo.gname = 'root' tarinfo.size = os.stat(x).st_size + if os.environ.get('SOURCE_DATE_EPOCH'): + tarinfo.mtime = int(os.environ.get('SOURCE_DATE_EPOCH')) # TODO - more archive creation options? if kw.get('bare', True): diff --git a/wscript b/wscript index c7791cb8..59f23446 100644 --- a/wscript +++ b/wscript @@ -293,6 +293,8 @@ def create_waf(self, *k, **kw): tarinfo = tarfile.TarInfo(x) tarinfo.uid = tarinfo.gid = 0 tarinfo.uname = tarinfo.gname = 'root' + if os.environ.get('SOURCE_DATE_EPOCH'): + tarinfo.mtime = int(os.environ.get('SOURCE_DATE_EPOCH')) (code, size, cnt) = sfilter(x) tarinfo.size = size