|
1 | 1 | import subprocess
|
2 |
| -import itertools |
3 | 2 |
|
4 | 3 | from briefcase.commands import (
|
5 | 4 | BuildCommand,
|
|
11 | 10 | )
|
12 | 11 | from briefcase.config import BaseConfig
|
13 | 12 | from briefcase.exceptions import BriefcaseCommandError
|
14 |
| -from briefcase.console import select_option |
15 |
| -from briefcase.platforms.macOS import macOSMixin, macOSPackageDMGMixin |
16 |
| -from briefcase.integrations.xcode import get_identities |
| 13 | +from briefcase.platforms.macOS import macOSMixin, macOSPackageMixin |
17 | 14 |
|
18 | 15 |
|
19 | 16 | class macOSXcodeMixin(macOSMixin):
|
@@ -114,88 +111,9 @@ def run_app(self, app: BaseConfig, **kwargs):
|
114 | 111 | )
|
115 | 112 |
|
116 | 113 |
|
117 |
| -class macOSXcodePackageCommand(macOSXcodeMixin, macOSPackageDMGMixin, PackageCommand): |
| 114 | +class macOSXcodePackageCommand(macOSXcodeMixin, macOSPackageMixin, PackageCommand): |
118 | 115 | description = "Package a macOS app for distribution."
|
119 | 116 |
|
120 |
| - def __init__(self, *args, **kwargs): |
121 |
| - super().__init__(*args, **kwargs) |
122 |
| - |
123 |
| - # External service APIs. |
124 |
| - # These are abstracted to enable testing without patching. |
125 |
| - self.get_identities = get_identities |
126 |
| - |
127 |
| - def select_identity(self, identity=None): |
128 |
| - """ |
129 |
| - Get the codesigning identity to use. |
130 |
| -
|
131 |
| - :param identity: A pre-specified identity (either the 40-digit |
132 |
| - hex checksum, or the string name of the identity). If provided, it |
133 |
| - will be validated against the list of available identities to |
134 |
| - confirm that it is a valid codesigning identity. |
135 |
| - :returns: The final identity to use |
136 |
| - """ |
137 |
| - # Obtain the valid codesigning identities. |
138 |
| - identities = self.get_identities(self, 'codesigning') |
139 |
| - |
140 |
| - if identity: |
141 |
| - try: |
142 |
| - # Try to look up the identity as a hex checksum |
143 |
| - return identities[identity] |
144 |
| - except KeyError: |
145 |
| - # It's not a valid checksum; try to use it as a value. |
146 |
| - if identity in identities.values(): |
147 |
| - return identity |
148 |
| - |
149 |
| - raise BriefcaseCommandError( |
150 |
| - "Invalid code signing identity {identity!r}".format( |
151 |
| - identity=identity |
152 |
| - ) |
153 |
| - ) |
154 |
| - |
155 |
| - if len(identities) == 0: |
156 |
| - raise BriefcaseCommandError( |
157 |
| - "No code signing identities are available." |
158 |
| - ) |
159 |
| - elif len(identities) == 1: |
160 |
| - identity = list(identities.items())[0][1] |
161 |
| - else: |
162 |
| - print() |
163 |
| - print("Select code signing identity to use:") |
164 |
| - print() |
165 |
| - selection = select_option(identities, input=self.input) |
166 |
| - identity = identities[selection] |
167 |
| - print("selected", identity) |
168 |
| - |
169 |
| - return identity |
170 |
| - |
171 |
| - def sign(self, path, entitlements, identity): |
172 |
| - """ |
173 |
| - Code sign a file. |
174 |
| -
|
175 |
| - :param path: The path to the file to sign. |
176 |
| - :param entitlements: The path to the entitlements file to use. |
177 |
| - :param identity: The code signing identity to use. Either the 40-digit |
178 |
| - hex checksum, or the string name of the identity. |
179 |
| - """ |
180 |
| - try: |
181 |
| - print("Signing", path) |
182 |
| - self.subprocess.run( |
183 |
| - [ |
184 |
| - 'codesign', |
185 |
| - '--sign', identity, |
186 |
| - '--entitlements', str(entitlements), |
187 |
| - '--deep', str(path), |
188 |
| - '--force', |
189 |
| - '--options', 'runtime', |
190 |
| - ], |
191 |
| - check=True, |
192 |
| - ) |
193 |
| - except subprocess.CalledProcessError: |
194 |
| - print() |
195 |
| - raise BriefcaseCommandError( |
196 |
| - "Unable to code sign {path}.".format(path=path) |
197 |
| - ) |
198 |
| - |
199 | 117 |
|
200 | 118 | class macOSXcodePublishCommand(macOSXcodeMixin, PublishCommand):
|
201 | 119 | description = "Publish a macOS app."
|
|
0 commit comments