aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnermolaev <snermolaev@yandex-team.com>2023-10-10 06:42:42 +0300
committersnermolaev <snermolaev@yandex-team.com>2023-10-10 06:57:50 +0300
commit3e580792936eb07affc3cf691eab771952af8055 (patch)
tree00d6841572f1217dba6bcce3998b927a64df7059
parent12baaa1282dd0a3bac01ff72b0837ff95f09facd (diff)
downloadydb-3e580792936eb07affc3cf691eab771952af8055.tar.gz
binary stable preprocessed.tar.gz and .jsrc
-rw-r--r--build/scripts/tar_sources.py31
-rw-r--r--build/scripts/tared_protoc.py18
2 files changed, 36 insertions, 13 deletions
diff --git a/build/scripts/tar_sources.py b/build/scripts/tar_sources.py
index d7e650e4ac..33555e3f20 100644
--- a/build/scripts/tar_sources.py
+++ b/build/scripts/tar_sources.py
@@ -1,5 +1,6 @@
import argparse
import os
+import stat
import tarfile
@@ -17,12 +18,6 @@ def parse_args():
def main():
args = parse_args()
- srcs = []
- for root, _, files in os.walk(args.input):
- for f in files:
- if not args.exts or f.endswith(tuple(args.exts)):
- srcs.append(os.path.join(root, f))
-
compression_mode = ''
if args.output.endswith(('.tar.gz', '.tgz')):
compression_mode = 'gz'
@@ -30,11 +25,25 @@ def main():
compression_mode = 'bz2'
with tarfile.open(args.output, 'w:{}'.format(compression_mode)) as out:
- for f in srcs:
- arcname = os.path.basename(f) if args.flat else os.path.relpath(f, args.input)
- if args.prefix:
- arcname = os.path.join(args.prefix, arcname)
- out.add(f, arcname=arcname)
+ for root, dirs, files in os.walk(args.input, topdown=True):
+ dirs.sort()
+ for name in sorted(files):
+ fname = os.path.join(root, name)
+ if args.exts and not fname.endswith(tuple(args.exts)):
+ continue
+ arcname = os.path.basename(fname) if args.flat else os.path.relpath(fname, args.input)
+ if args.prefix:
+ arcname = os.path.join(args.prefix, arcname)
+ with open(fname, 'rb') as fin:
+ tarinfo = out.gettarinfo(fname, arcname)
+ tarinfo.mode = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH if tarinfo.mode | stat.S_IXUSR else 0
+ tarinfo.mode = tarinfo.mode | stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH
+ tarinfo.mtime = 0
+ tarinfo.uid = 0
+ tarinfo.gid = 0
+ tarinfo.uname = 'dummy'
+ tarinfo.gname = 'dummy'
+ out.addfile(tarinfo, fin)
if __name__ == '__main__':
diff --git a/build/scripts/tared_protoc.py b/build/scripts/tared_protoc.py
index 7643e1dbfe..48ced0c479 100644
--- a/build/scripts/tared_protoc.py
+++ b/build/scripts/tared_protoc.py
@@ -2,6 +2,7 @@ import os
import optparse
import tarfile
import contextlib
+import stat
import subprocess as sp
@@ -23,8 +24,21 @@ def main():
sp.check_call(args)
- with contextlib.closing(tarfile.open(opts.tar_output, 'w')) as tf:
- tf.add(opts.protoc_out_dir, arcname='')
+ with tarfile.open(opts.tar_output, 'w', format=tarfile.USTAR_FORMAT) as tf:
+ for root, dirs, files in os.walk(opts.protoc_out_dir, topdown=True):
+ dirs.sort()
+ for name in sorted(files):
+ fname = os.path.join(root, name)
+ with open(fname, 'rb') as fin:
+ tarinfo = tf.gettarinfo(fname, os.path.relpath(fname, opts.protoc_out_dir))
+ tarinfo.mode = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH if tarinfo.mode | stat.S_IXUSR else 0
+ tarinfo.mode = tarinfo.mode | stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH
+ tarinfo.mtime = 0
+ tarinfo.uid = 0
+ tarinfo.gid = 0
+ tarinfo.uname = 'dummy'
+ tarinfo.gname = 'dummy'
+ tf.addfile(tarinfo, fin)
if __name__ == '__main__':