| 1 | #!/usr/bin/env python3 |
| 2 | """Add Equipo's reviewed Services entry before the final bundle signature.""" |
| 3 | import argparse, json, plistlib, sys |
| 4 | from pathlib import Path |
| 5 | |
| 6 | parser = argparse.ArgumentParser() |
| 7 | parser.add_argument('shared_native', type=Path) |
| 8 | parser.add_argument('--display-name', default='Oficina Equipo') |
| 9 | parser.add_argument('--sign-identity', default='-') |
| 10 | parser.add_argument('--entitlements', type=Path) |
| 11 | parser.add_argument('--provisioning-profile', type=Path) |
| 12 | args, _ = parser.parse_known_args() |
| 13 | root = Path(__file__).resolve().parents[1] |
| 14 | sys.path.insert(0, str(args.shared_native.resolve() / 'tools')) |
| 15 | from mac_updates import read_configuration, signing_declaration, sign_bundle |
| 16 | config_path = root / 'mac-updates.json' |
| 17 | config = read_configuration(config_path) |
| 18 | entitlements, profile = signing_declaration(config_path, args.entitlements, args.provisioning_profile, config) |
| 19 | app = root / 'build' / (args.display_name + '.app') |
| 20 | path = app / 'Contents/Info.plist' |
| 21 | info = plistlib.loads(path.read_bytes()) |
| 22 | words = json.loads((root / 'scripts/strings.json').read_text()) |
| 23 | info['NSServices'] = [{'NSMenuItem': {'default': words['native.share.title']}, |
| 24 | 'NSMessage': 'sendToEquipo', 'NSPortName': 'Equipo', |
| 25 | 'NSSendTypes': ['public.utf8-plain-text', 'public.url', 'public.file-url', 'public.png', 'public.tiff'], |
| 26 | 'NSRequiredContext': {}}] |
| 27 | path.write_bytes(plistlib.dumps(info)) |
| 28 | sign_bundle(app, args.sign_identity, entitlements, profile) |
| 29 | |