MCPcopy Create free account
hub / github.com/defold/defold / sign_file

Function sign_file

editor/scripts/bundle.py:254–314  ·  view source on GitHub ↗
(platform, options, file)

Source from the content-addressed store, hash-verified

252 return None
253
254def 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',

Callers 1

signFunction · 0.85

Calls 7

platform_is_windowsFunction · 0.85
platform_is_macosFunction · 0.85
mac_certificateFunction · 0.85
exitMethod · 0.80
commandMethod · 0.80
logFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected