diff options
author | snermolaev <snermolaev@yandex-team.com> | 2023-10-10 06:42:42 +0300 |
---|---|---|
committer | snermolaev <snermolaev@yandex-team.com> | 2023-10-10 06:57:50 +0300 |
commit | 3e580792936eb07affc3cf691eab771952af8055 (patch) | |
tree | 00d6841572f1217dba6bcce3998b927a64df7059 /build/scripts/tar_sources.py | |
parent | 12baaa1282dd0a3bac01ff72b0837ff95f09facd (diff) | |
download | ydb-3e580792936eb07affc3cf691eab771952af8055.tar.gz |
binary stable preprocessed.tar.gz and .jsrc
Diffstat (limited to 'build/scripts/tar_sources.py')
-rw-r--r-- | build/scripts/tar_sources.py | 31 |
1 files changed, 20 insertions, 11 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__': |