@@ -30,7 +30,6 @@ from swift_build_support.swift_build_support import (
30
30
diagnostics ,
31
31
products ,
32
32
shell ,
33
- tar ,
34
33
targets ,
35
34
workspace
36
35
)
@@ -89,6 +88,25 @@ def print_xcodebuild_versions(file=sys.stdout):
89
88
file .flush ()
90
89
91
90
91
+ def tar (source , destination ):
92
+ """
93
+ Create a gzip archive of the file at 'source' at the given
94
+ 'destination' path.
95
+ """
96
+ # We do not use `tarfile` here because:
97
+ # - We wish to support LZMA2 compression while also supporting Python 2.7.
98
+ # - We wish to explicitly set the owner and group of the archive.
99
+ args = ['tar' , '-c' , '-z' , '-f' , destination ]
100
+
101
+ if platform .system () != 'Darwin' and platform .system () != 'Windows' :
102
+ args += ['--owner=0' , '--group=0' ]
103
+
104
+ # Discard stderr output such as 'tar: Failed to open ...'. We'll detect
105
+ # these cases using the exit code, which should cause 'shell.call' to
106
+ # raise.
107
+ shell .call (args + [source ], stderr = shell .DEVNULL )
108
+
109
+
92
110
class BuildScriptInvocation (object ):
93
111
94
112
"""Represent a single build script invocation."""
@@ -1169,8 +1187,8 @@ def main_normal():
1169
1187
# run `tar` without the leading '/' (we remove it ourselves to keep
1170
1188
# `tar` from emitting a warning).
1171
1189
with shell .pushd (args .install_symroot ):
1172
- tar . tar (source = prefix .lstrip ('/' ),
1173
- destination = args .symbols_package )
1190
+ tar (source = prefix .lstrip ('/' ),
1191
+ destination = args .symbols_package )
1174
1192
1175
1193
return 0
1176
1194
0 commit comments