summaryrefslogtreecommitdiffstats
path: root/build/scripts/tar_directory.py
diff options
context:
space:
mode:
authoralexv-smirnov <[email protected]>2023-03-28 22:25:04 +0300
committeralexv-smirnov <[email protected]>2023-03-28 22:25:04 +0300
commitb8a17f9b1c166d2e9a26b99348a4c29d972caf55 (patch)
tree1a2d881f1a9452b9c6103dbf69d73da7624e98e5 /build/scripts/tar_directory.py
parent25659221f18577ea38430a8ec3349836f5626b6a (diff)
Revert ymake build from ydb oss export
Diffstat (limited to 'build/scripts/tar_directory.py')
-rw-r--r--build/scripts/tar_directory.py45
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:])