diff options
| author | monster <[email protected]> | 2022-07-07 14:41:37 +0300 |
|---|---|---|
| committer | monster <[email protected]> | 2022-07-07 14:41:37 +0300 |
| commit | 06e5c21a835c0e923506c4ff27929f34e00761c2 (patch) | |
| tree | 75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /build/scripts/tar_directory.py | |
| parent | 03f024c4412e3aa613bb543cf1660176320ba8f4 (diff) | |
fix ya.make
Diffstat (limited to 'build/scripts/tar_directory.py')
| -rw-r--r-- | build/scripts/tar_directory.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/build/scripts/tar_directory.py b/build/scripts/tar_directory.py deleted file mode 100644 index a91889fa22f..00000000000 --- a/build/scripts/tar_directory.py +++ /dev/null @@ -1,45 +0,0 @@ -import os -import sys -import tarfile - - -def is_exe(fpath): - return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - - -def main(args): - if len(args) < 2 or len(args) > 3: - raise Exception("Illegal usage: `tar_directory.py archive.tar directory [skip prefix]` or `tar_directory.py archive.tar output_directory --extract`") - tar, directory, prefix, extract = args[0], args[1], None, False - if len(args) == 3: - if args[2] == '--extract': - extract = True - else: - prefix = args[2] - for tar_exe in ('/usr/bin/tar', '/bin/tar'): - if not is_exe(tar_exe): - continue - if extract: - dest = os.path.abspath(directory) - if not os.path.exists(dest): - os.makedirs(dest) - os.execv(tar_exe, [tar_exe, '-xf', tar, '-C', dest]) - else: - source = os.path.relpath(directory, prefix) if prefix else directory - os.execv(tar_exe, [tar_exe, '-cf', tar] + (['-C', prefix] if prefix else []) + [source]) - break - else: - if extract: - dest = os.path.abspath(directory) - if not os.path.exists(dest): - os.makedirs(dest) - with tarfile.open(tar, 'r') as tar_file: - tar_file.extractall(dest) - else: - source = directory - with tarfile.open(tar, 'w') as out: - out.add(os.path.abspath(source), arcname=os.path.relpath(source, prefix) if prefix else source) - - -if __name__ == '__main__': - main(sys.argv[1:]) |
