Changeset View
Changeset View
Standalone View
Standalone View
build_files/buildbot/worker_bundle_dmg.py
| Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | parser.add_argument( | ||||
| '--dmg', | '--dmg', | ||||
| type=Path, | type=Path, | ||||
| help='Optional argument which points to a final DMG file name.') | help='Optional argument which points to a final DMG file name.') | ||||
| parser.add_argument( | parser.add_argument( | ||||
| '--applescript', | '--applescript', | ||||
| type=Path, | type=Path, | ||||
| help="Optional path to applescript to set up folder looks of DMG." | help="Optional path to applescript to set up folder looks of DMG." | ||||
| "If not provided default Blender's one is used.") | "If not provided default Blender's one is used.") | ||||
| parser.add_argument( | |||||
| '--codesign', | |||||
| action="store_true" | |||||
| help="Code sign and notarize DMG contents.") | |||||
| return parser | return parser | ||||
| def collect_app_bundles(source_dir: Path) -> List[Path]: | def collect_app_bundles(source_dir: Path) -> List[Path]: | ||||
| """ | """ | ||||
| Collect all app bundles which are to be put into DMG | Collect all app bundles which are to be put into DMG | ||||
| If the source directory points to FOO.app it will be the only app bundle | If the source directory points to FOO.app it will be the only app bundle | ||||
| ▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | def compress_dmg(writable_dmg_filepath: Path, | ||||
| print('Compressing disk image...') | print('Compressing disk image...') | ||||
| subprocess.run(command) | subprocess.run(command) | ||||
| def create_final_dmg(app_bundles: List[Path], | def create_final_dmg(app_bundles: List[Path], | ||||
| dmg_filepath: Path, | dmg_filepath: Path, | ||||
| background_image_filepath: Path, | background_image_filepath: Path, | ||||
| volume_name: str, | volume_name: str, | ||||
| applescript: Path) -> None: | applescript: Path, | ||||
| codesign: bool) -> None: | |||||
| """ | """ | ||||
| Create DMG with all app bundles | Create DMG with all app bundles | ||||
| Will take care configuring background, signing all binaries and app bundles | Will take care configuring background, signing all binaries and app bundles | ||||
| and notarizing the DMG. | and notarizing the DMG. | ||||
| """ | """ | ||||
| print('Running all routines to create final DMG') | print('Running all routines to create final DMG') | ||||
| Show All 9 Lines | def create_final_dmg(app_bundles: List[Path], | ||||
| create_dmg_image(app_bundles, writable_dmg_filepath, volume_name) | create_dmg_image(app_bundles, writable_dmg_filepath, volume_name) | ||||
| mount_readwrite_dmg(writable_dmg_filepath) | mount_readwrite_dmg(writable_dmg_filepath) | ||||
| # Run codesign first, prior to copying amything else. | # Run codesign first, prior to copying amything else. | ||||
| # | # | ||||
| # This allows to recurs into the content of bundles without worrying about | # This allows to recurs into the content of bundles without worrying about | ||||
| # possible interfereice of Application symlink. | # possible interfereice of Application symlink. | ||||
| if codesign: | |||||
| codesign_app_bundles_in_dmg(mount_directory) | codesign_app_bundles_in_dmg(mount_directory) | ||||
| copy_background_if_needed(background_image_filepath, mount_directory) | copy_background_if_needed(background_image_filepath, mount_directory) | ||||
| create_applications_link(mount_directory) | create_applications_link(mount_directory) | ||||
| run_applescript(applescript, volume_name, app_bundles, | run_applescript(applescript, volume_name, app_bundles, | ||||
| background_image_filepath) | background_image_filepath) | ||||
| print('Ejecting read-write DMG image...') | print('Ejecting read-write DMG image...') | ||||
| eject_volume(volume_name) | eject_volume(volume_name) | ||||
| compress_dmg(writable_dmg_filepath, dmg_filepath) | compress_dmg(writable_dmg_filepath, dmg_filepath) | ||||
| writable_dmg_filepath.unlink() | writable_dmg_filepath.unlink() | ||||
| if codesign: | |||||
| codesign_and_notarize_dmg(dmg_filepath) | codesign_and_notarize_dmg(dmg_filepath) | ||||
| def ensure_dmg_extension(filepath: Path) -> Path: | def ensure_dmg_extension(filepath: Path) -> Path: | ||||
| """ | """ | ||||
| Make sure given file have .dmg extension | Make sure given file have .dmg extension | ||||
| """ | """ | ||||
| if filepath.suffix != '.dmg': | if filepath.suffix != '.dmg': | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
| def main(): | def main(): | ||||
| parser = create_argument_parser() | parser = create_argument_parser() | ||||
| args = parser.parse_args() | args = parser.parse_args() | ||||
| # Get normalized input parameters. | # Get normalized input parameters. | ||||
| source_dir = args.source_dir.absolute() | source_dir = args.source_dir.absolute() | ||||
| background_image_filepath = get_background_image(args.background_image) | background_image_filepath = get_background_image(args.background_image) | ||||
| applescript = get_applescript(args.applescript) | applescript = get_applescript(args.applescript) | ||||
| codesign = args.codesign | |||||
| app_bundles = collect_and_log_app_bundles(source_dir) | app_bundles = collect_and_log_app_bundles(source_dir) | ||||
| if not app_bundles: | if not app_bundles: | ||||
| return | return | ||||
| dmg_filepath = get_dmg_filepath(args.dmg, app_bundles) | dmg_filepath = get_dmg_filepath(args.dmg, app_bundles) | ||||
| volume_name = get_volume_name(args.volume_name, dmg_filepath) | volume_name = get_volume_name(args.volume_name, dmg_filepath) | ||||
| print(f'Will produce DMG "{dmg_filepath.name}" (without quotes)') | print(f'Will produce DMG "{dmg_filepath.name}" (without quotes)') | ||||
| create_final_dmg(app_bundles, | create_final_dmg(app_bundles, | ||||
| dmg_filepath, | dmg_filepath, | ||||
| background_image_filepath, | background_image_filepath, | ||||
| volume_name, | volume_name, | ||||
| applescript) | applescript, | ||||
| codesign) | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| main() | main() | ||||