-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Build-Project.command
executable file
·168 lines (135 loc) · 7.21 KB
/
Build-Project.command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env python3
"""
Build-Project.command: Generate OpenCore-Patcher.app and OpenCore-Patcher.pkg
"""
import os
import sys
import time
import argparse
import plistlib
from pathlib import Path
from ci_tooling.build_modules import (
application,
disk_images,
package,
sign_notarize,
shim
)
from opencore_legacy_patcher import constants
def main() -> None:
"""
Parse Command Line Arguments
"""
parser = argparse.ArgumentParser(description="Build OpenCore Legacy Patcher Suite", add_help=False)
# Signing Parameters
parser.add_argument("--application-signing-identity", type=str, help="Application Signing Identity")
parser.add_argument("--installer-signing-identity", type=str, help="Installer Signing Identity")
# Notarization Parameters
parser.add_argument("--notarization-apple-id", type=str, help="Notarization Apple ID", default=None)
parser.add_argument("--notarization-password", type=str, help="Notarization Password", default=None)
parser.add_argument("--notarization-team-id", type=str, help="Notarization Team ID", default=None)
# GitHub Actions CI/CD Parameters
parser.add_argument("--git-branch", type=str, help="Git Branch", default=None)
parser.add_argument("--git-commit-url", type=str, help="Git Commit URL", default=None)
parser.add_argument("--git-commit-date", type=str, help="Git Commit Date", default=None)
# Local Build Parameters
parser.add_argument("--reset-dmg-cache", action="store_true", help="Redownload PatcherSupportPkg.dmg and regenerate payloads.dmg", default=False)
parser.add_argument("--reset-pyinstaller-cache", action="store_true", help="Clean PyInstaller Cache", default=False)
# CI/CD Parameters for individual steps
# If not specified, will run all steps
parser.add_argument("--run-as-individual-steps", action="store_true", help="CI: Run as individual steps", default=False)
parser.add_argument("--prepare-application", action="store_true", help="CI: Prepare Application", default=False)
parser.add_argument("--prepare-package", action="store_true", help="CI: Prepare Package", default=False)
parser.add_argument("--prepare-assets", action="store_true", help="CI: Prepare Assets", default=False)
# CI/CD Parameters for additional steps
# If not specified, will not run additional steps
parser.add_argument("--prepare-shim", action="store_true", help="CI: Prepare Update Shim", default=False)
# Analytics Parameters
parser.add_argument("--analytics-key", type=str, help="Analytics Key", default=None)
parser.add_argument("--analytics-endpoint", type=str, help="Analytics Endpoint", default=None)
# Help
parser.add_argument("--help", action="store_true", help="Show this help message and exit", default=False)
# Parse Arguments
args = parser.parse_args()
if args.help:
parser.print_help()
print("\n\nIf running outside of CI/CD, simply run the following command:")
print("$ python3 Build-Project.command")
sys.exit(0)
# Set 'Current Working Directory' to script directory
os.chdir(Path(__file__).resolve().parent)
if (args.run_as_individual_steps is False) or (args.run_as_individual_steps and args.prepare_assets):
# Prepare workspace
disk_images.GenerateDiskImages(args.reset_dmg_cache).generate()
if (args.run_as_individual_steps is False) or (args.run_as_individual_steps and args.prepare_application):
# Prepare Privileged Helper Tool
sign_notarize.SignAndNotarize(
path=Path("./ci_tooling/privileged_helper_tool/com.dortania.opencore-legacy-patcher.privileged-helper"),
signing_identity=args.application_signing_identity,
notarization_apple_id=args.notarization_apple_id,
notarization_password=args.notarization_password,
notarization_team_id=args.notarization_team_id,
).sign_and_notarize()
# Build OpenCore-Patcher.app
application.GenerateApplication(
reset_pyinstaller_cache=args.reset_pyinstaller_cache,
git_branch=args.git_branch,
git_commit_url=args.git_commit_url,
git_commit_date=args.git_commit_date,
analytics_key=args.analytics_key,
analytics_endpoint=args.analytics_endpoint,
).generate()
# Sign OpenCore-Patcher.app
sign_notarize.SignAndNotarize(
path=Path("dist/OpenCore-Patcher.app"),
signing_identity=args.application_signing_identity,
notarization_apple_id=args.notarization_apple_id,
notarization_password=args.notarization_password,
notarization_team_id=args.notarization_team_id,
entitlements=Path("./ci_tooling/entitlements/entitlements.plist"),
).sign_and_notarize()
if (args.run_as_individual_steps is False) or (args.run_as_individual_steps and args.prepare_package):
# Build OpenCore-Patcher.pkg and OpenCore-Patcher-Uninstaller.pkg
package.GeneratePackage().generate()
# Sign OpenCore-Patcher.pkg
sign_notarize.SignAndNotarize(
path=Path("dist/OpenCore-Patcher.pkg"),
signing_identity=args.installer_signing_identity,
notarization_apple_id=args.notarization_apple_id,
notarization_password=args.notarization_password,
notarization_team_id=args.notarization_team_id,
).sign_and_notarize()
# Sign OpenCore-Patcher-Uninstaller.pkg
sign_notarize.SignAndNotarize(
path=Path("dist/OpenCore-Patcher-Uninstaller.pkg"),
signing_identity=args.installer_signing_identity,
notarization_apple_id=args.notarization_apple_id,
notarization_password=args.notarization_password,
notarization_team_id=args.notarization_team_id,
).sign_and_notarize()
# Create Update Shim
if args.prepare_shim:
shim.GenerateShim().generate()
if Path("dist/OpenCore-Patcher.app").exists():
if Path("dist/OpenCore-Patcher (Original).app").exists():
Path("dist/OpenCore-Patcher (Original).app").unlink()
Path("dist/OpenCore-Patcher.app").rename("dist/OpenCore-Patcher (Original).app")
Path("dist/OpenCore-Patcher (Shim).app").rename("dist/OpenCore-Patcher.app")
# Update app version in Info.plist
plist_path = Path("dist/OpenCore-Patcher.app/Contents/Info.plist")
contents = plistlib.load(plist_path.open("rb"))
contents["CFBundleVersion"] = constants.Constants().patcher_version
contents["CFBundleShortVersionString"] = constants.Constants().patcher_version
plistlib.dump(contents, plist_path.open("wb"))
sign_notarize.SignAndNotarize(
path=Path("dist/OpenCore-Patcher.app"),
signing_identity=args.application_signing_identity,
notarization_apple_id=args.notarization_apple_id,
notarization_password=args.notarization_password,
notarization_team_id=args.notarization_team_id,
entitlements=Path("./ci_tooling/entitlements/entitlements.plist"),
).sign_and_notarize()
if __name__ == '__main__':
_start = time.time()
main()
print(f"Build script completed in {str(round(time.time() - _start, 2))} seconds")