(platform, options, file)
| 252 | return None |
| 253 | |
| 254 | def sign_file(platform, options, file): |
| 255 | if platform_is_windows(platform): |
| 256 | if not shutil.which('gcloud'): |
| 257 | sys.exit("No gcloud tool found") |
| 258 | gcloud = shutil.which('gcloud') |
| 259 | run.command([ |
| 260 | gcloud, |
| 261 | 'auth', |
| 262 | 'activate-service-account', |
| 263 | '--key-file', options.gcloud_keyfile], silent = True) |
| 264 | |
| 265 | # Capture the token ourselves so we can strip any stray lines emitted by the Windows |
| 266 | # Microsoft Store shim when `python.exe` is missing (it writes that warning to stdout). |
| 267 | token_proc = subprocess.run( |
| 268 | [gcloud, 'auth', 'print-access-token'], |
| 269 | stdout = subprocess.PIPE, |
| 270 | stderr = subprocess.PIPE, |
| 271 | check = False, |
| 272 | text = True) |
| 273 | if token_proc.returncode != 0: |
| 274 | log("gcloud auth print-access-token failed with exit code %d" % token_proc.returncode) |
| 275 | if token_proc.stderr: |
| 276 | log(token_proc.stderr.strip()) |
| 277 | sys.exit(1) |
| 278 | |
| 279 | token_lines = [line.strip() for line in token_proc.stdout.splitlines() if line.strip()] |
| 280 | if not token_lines: |
| 281 | log("Failed to read Google Cloud access token from gcloud output") |
| 282 | if token_proc.stderr: |
| 283 | log(token_proc.stderr.strip()) |
| 284 | sys.exit(1) |
| 285 | storepass = token_lines[-1] |
| 286 | |
| 287 | jsign = os.path.join(os.environ['DYNAMO_HOME'], 'ext','share','java','jsign-4.2.jar') |
| 288 | keystore = "projects/%s/locations/%s/keyRings/%s" % (options.gcloud_projectid, options.gcloud_location, options.gcloud_keyringname) |
| 289 | run.command([ |
| 290 | 'java', '-jar', jsign, |
| 291 | '--storetype', 'GOOGLECLOUD', |
| 292 | '--storepass', storepass, |
| 293 | '--keystore', keystore, |
| 294 | '--alias', options.gcloud_keyname, |
| 295 | '--certfile', options.gcloud_certfile, |
| 296 | '--tsmode', 'RFC3161', |
| 297 | '--tsaurl', 'http://timestamp.globalsign.com/tsa/r6advanced1', |
| 298 | file], silent = True) |
| 299 | |
| 300 | if platform_is_macos(platform): |
| 301 | codesigning_identity = options.codesigning_identity |
| 302 | certificate = mac_certificate(codesigning_identity) |
| 303 | if certificate is None: |
| 304 | log("Codesigning certificate not found for signing identity %s" % codesigning_identity) |
| 305 | sys.exit(1) |
| 306 | |
| 307 | run.command([ |
| 308 | 'codesign', |
| 309 | '--deep', |
| 310 | '--force', |
| 311 | '--options', 'runtime', |
no test coverage detected