diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-03-28 22:25:04 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-03-28 22:25:04 +0300 |
commit | b8a17f9b1c166d2e9a26b99348a4c29d972caf55 (patch) | |
tree | 1a2d881f1a9452b9c6103dbf69d73da7624e98e5 /build/scripts/make_container.py | |
parent | 25659221f18577ea38430a8ec3349836f5626b6a (diff) | |
download | ydb-b8a17f9b1c166d2e9a26b99348a4c29d972caf55.tar.gz |
Revert ymake build from ydb oss export
Diffstat (limited to 'build/scripts/make_container.py')
-rw-r--r-- | build/scripts/make_container.py | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/build/scripts/make_container.py b/build/scripts/make_container.py deleted file mode 100644 index a485baffdd..0000000000 --- a/build/scripts/make_container.py +++ /dev/null @@ -1,94 +0,0 @@ -import os -import shutil -import stat -import struct -import subprocess -import sys - -import container # 1 - - -def main(output_path, entry_path, input_paths, squashfs_path): - output_tmp_path = output_path + '.tmp' - shutil.copy2(entry_path, output_tmp_path) - st = os.stat(output_tmp_path) - os.chmod(output_tmp_path, st.st_mode | stat.S_IWUSR) - - layer_paths = [] - other_paths = [] - for input_path in input_paths: - (layer_paths if input_path.endswith('.container_layer') else other_paths).append(input_path) - - if len(other_paths) == 0: - raise Exception('No program in container dependencies') - - if len(other_paths) > 1: - raise Exception('Multiple non-layer inputs') - - program_path = other_paths[0] - program_container_path = os.path.basename(program_path) - - os.symlink(program_container_path, 'entry') - add_cmd = [ os.path.join(squashfs_path, 'mksquashfs') ] - add_cmd.extend([program_path, 'entry', 'program_layer']) - subprocess.run(add_cmd) - - layer_paths.append('program_layer') - - container.join_layers(layer_paths, 'container_data', squashfs_path) - - size = 0 - block_size = 1024 * 1024 - - with open(output_tmp_path, 'ab') as output: - with open('container_data', 'rb') as input_: - while True: - data = input_.read(block_size) - output.write(data) - size += len(data) - - if len(data) < block_size: - break - - with open(os.path.join(squashfs_path, 'unsquashfs'), 'rb') as input_: - while True: - data = input_.read(block_size) - output.write(data) - size += len(data) - - if len(data) == 0: - break - - - output.write(struct.pack('<Q', size)) - - os.rename(output_tmp_path, output_path) - - -def entry(): - import argparse - - parser = argparse.ArgumentParser() - parser.add_argument('-o', '--output', required=True) - parser.add_argument('-s', '--squashfs-path', required=True) - parser.add_argument('input', nargs='*') - - args = parser.parse_args() - - def is_container_entry(path): - return os.path.basename(path) == '_container_entry' - - input_paths = [] - entry_paths = [] - - for input_path in args.input: - (entry_paths if is_container_entry(input_path) else input_paths).append(input_path) - - if len(entry_paths) != 1: - raise Exception('Could not select container entry from {}'.format(entry_paths)) - - return main(args.output, entry_paths[0], input_paths, args.squashfs_path) - - -if __name__ == '__main__': - sys.exit(entry()) |