2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-22 09:19:28 +01:00

Support SOURCE_DATE_EPOCH in some places

This commit is contained in:
Thomas Nagy 2023-02-12 10:19:57 +01:00
parent 99bdb12a60
commit ff0a8cec14
3 changed files with 11 additions and 1 deletions

View File

@ -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:

View File

@ -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):

View File

@ -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