aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/tar_directory.py
diff options
context:
space:
mode:
authorworkfork <workfork@yandex-team.ru>2022-02-10 16:46:43 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:43 +0300
commitc3745173272d1cf5b0642debb40d019e7ae71094 (patch)
treedaee509c9d920ccdc727dbf1254b2183bf5f64aa /build/scripts/tar_directory.py
parent656921707c02b816d730f31c1fdc1d615adbfe00 (diff)
downloadydb-c3745173272d1cf5b0642debb40d019e7ae71094.tar.gz
Restoring authorship annotation for <workfork@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'build/scripts/tar_directory.py')
-rw-r--r--build/scripts/tar_directory.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/build/scripts/tar_directory.py b/build/scripts/tar_directory.py
index a91889fa22..51ff079f5a 100644
--- a/build/scripts/tar_directory.py
+++ b/build/scripts/tar_directory.py
@@ -9,35 +9,35 @@ def is_exe(fpath):
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
+ 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]
+ 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
+ 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
+ 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:
+ 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:
+ with tarfile.open(tar, 'w') as out:
out.add(os.path.abspath(source), arcname=os.path.relpath(source, prefix) if prefix else source)