diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
commit | bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch) | |
tree | 1d1df72c0541a59a81439842f46d95396d3e7189 /build/scripts/pack_ios.py | |
parent | 8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff) | |
download | ydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz |
add ymake export to ydb
Diffstat (limited to 'build/scripts/pack_ios.py')
-rw-r--r-- | build/scripts/pack_ios.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/build/scripts/pack_ios.py b/build/scripts/pack_ios.py new file mode 100644 index 0000000000..37c36d1f95 --- /dev/null +++ b/build/scripts/pack_ios.py @@ -0,0 +1,48 @@ +import argparse +import os +import shutil +import subprocess +import sys +import tarfile + + +def just_do_it(): + parser = argparse.ArgumentParser() + parser.add_argument("--binary", required=True, help="executable file") + parser.add_argument("--target", required=True, help="target archive path") + parser.add_argument("--temp-dir", required=True, help="temp dir") + parser.add_argument("peers", nargs='*') + args = parser.parse_args() + app_tar = [p for p in args.peers if p.endswith('.ios.interface')] + if not app_tar: + print >> sys.stderr, 'No one IOS_INTERFACE module found' + shutil.copyfile(args.binary, os.path.join(args.temp_dir, 'bin')) + if os.path.exists(args.target): + os.remove(args.target) + with tarfile.open(args.target, 'w') as tf: + tf.add(os.path.join(args.temp_dir, 'bin'), arcname=os.path.join(os.path.basename(args.binary) + '.app', 'bin')) + return + if len(app_tar) > 1: + app_tar = [p for p in args.peers if not p.endswith('.default.ios.interface')] + if len(app_tar) > 1: + print >> sys.stderr, 'Many IOS_INTERFACE modules found, {} will be used'.format(app_tar[-1]) + app_tar = app_tar[-1] + with tarfile.open(app_tar) as tf: + tf.extractall(args.temp_dir) + tar_suffix = '.default.ios.interface' if app_tar.endswith('.default.ios.interface') else '.ios.interface' + app_unpacked_path = os.path.join(args.temp_dir, os.path.basename(app_tar)[:-len(tar_suffix)] + '.app') + if not os.path.exists(app_unpacked_path): + raise Exception('Bad IOS_INTERFACE resource: {}'.format(app_tar)) + shutil.copyfile(args.binary, os.path.join(app_unpacked_path, 'bin')) + subprocess.check_call(['/usr/bin/codesign', '--force', '--sign', '-', app_unpacked_path]) + if os.path.exists(args.target): + os.remove(args.target) + binary_origin_name = os.path.basename(args.binary) + while os.path.splitext(binary_origin_name)[1]: + binary_origin_name = os.path.splitext(binary_origin_name)[0] + with tarfile.open(args.target, 'w') as tf: + tf.add(app_unpacked_path, arcname=binary_origin_name + '.app', recursive=True) + + +if __name__ == '__main__': + just_do_it() |