Skip to content

Commit fecaca5

Browse files
authored
Merge pull request swiftlang#29468 from Rostepher/remove-tar-module
[Build System: build-script] Remove the tar module from swift_build_support.
2 parents efa526e + ca4fc19 commit fecaca5

File tree

3 files changed

+21
-109
lines changed

3 files changed

+21
-109
lines changed

utils/build-script

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ from swift_build_support.swift_build_support import (
3030
diagnostics,
3131
products,
3232
shell,
33-
tar,
3433
targets,
3534
workspace
3635
)
@@ -89,6 +88,25 @@ def print_xcodebuild_versions(file=sys.stdout):
8988
file.flush()
9089

9190

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+
92110
class BuildScriptInvocation(object):
93111

94112
"""Represent a single build script invocation."""
@@ -1169,8 +1187,8 @@ def main_normal():
11691187
# run `tar` without the leading '/' (we remove it ourselves to keep
11701188
# `tar` from emitting a warning).
11711189
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)
11741192

11751193
return 0
11761194

utils/swift_build_support/swift_build_support/tar.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

utils/swift_build_support/tests/test_tar.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)