@@ -75,14 +75,21 @@ def run():
75
75
tarinfo .name = str (pathlib .Path (alt_base_dir , tarinfo .name ))
76
76
if tarinfo .linkname and tarinfo .linkname .startswith ("./" ):
77
77
tarinfo .linkname = str (pathlib .Path (alt_base_dir , tarinfo .linkname ))
78
+ # make metadata deterministic
79
+ tarinfo .mtime = 0
80
+ tarinfo .uid , tarinfo .uname = 0 , ''
81
+ tarinfo .gid , tarinfo .gname = 0 , ''
82
+ # don't use isdir() as there are also executable files present
83
+ tarinfo .mode = 0o0755 if tarinfo .mode & 0o0100 else 0x0644
78
84
return tarinfo
79
85
with cd (dir_to_add ):
86
+ # recursion already adds entries in sorted order
80
87
tarfp .add ("." , recursive = True , filter = change_tarinfo_base )
81
88
82
89
print ("Creating output .tar.gz file..." )
83
90
with out_sdktgz_path .open ("wb" ) as fp :
84
91
with gzip .GzipFile (fileobj = fp , mode = 'wb' , compresslevel = 9 , mtime = 0 ) as gzf :
85
- with tarfile .open (mode = "w" , fileobj = gzf ) as tarfp :
92
+ with tarfile .open (mode = "w" , fileobj = gzf , format = tarfile . GNU_FORMAT ) as tarfp :
86
93
print ("Adding MacOSX SDK {} files..." .format (sdk_version ))
87
94
tarfp_add_with_base_change (tarfp , sdk_dir , out_name )
88
95
print ("Adding libc++ headers..." )
0 commit comments