MCPcopy
hub / github.com/mitmproxy/mitmproxy / installbuilder_installer

Function installbuilder_installer

release/build.py:290–378  ·  view source on GitHub ↗

Windows: Build the InstallBuilder installer.

()

Source from the content-addressed store, hash-verified

288
289@cli.command()
290def installbuilder_installer():
291 """Windows: Build the InstallBuilder installer."""
292 _ensure_pyinstaller_onedir()
293
294 IB_VERSION = "23.4.0"
295 IB_SETUP_SHA256 = "e4ff212ed962f9e0030d918b8a6e4d6dd8a9adc8bf8bc1833459351ee649eff3"
296 IB_DIR = here / "installbuilder"
297 IB_SETUP = IB_DIR / "setup" / f"{IB_VERSION}-installer.exe"
298 IB_CLI = Path(
299 rf"C:\Program Files\InstallBuilder Enterprise {IB_VERSION}\bin\builder-cli.exe"
300 )
301 IB_LICENSE = IB_DIR / "license.xml"
302
303 if not IB_LICENSE.exists():
304 print("Decrypt InstallBuilder license...")
305 f = cryptography.fernet.Fernet(os.environ["CI_BUILD_KEY"].encode())
306 with (
307 open(IB_LICENSE.with_suffix(".xml.enc"), "rb") as infile,
308 open(IB_LICENSE, "wb") as outfile,
309 ):
310 outfile.write(f.decrypt(infile.read()))
311
312 if not IB_CLI.exists():
313 if not IB_SETUP.exists():
314 url = (
315 f"https://github.com/mitmproxy/installbuilder-mirror/releases/download/"
316 f"{IB_VERSION}/installbuilder-enterprise-{IB_VERSION}-windows-x64-installer.exe"
317 )
318 print(f"Downloading InstallBuilder from {url}...")
319
320 def report(block, blocksize, total):
321 done = block * blocksize
322 if round(100 * done / total) != round(100 * (done - blocksize) / total):
323 print(f"Downloading... {round(100 * done / total)}%")
324
325 tmp = IB_SETUP.with_suffix(".tmp")
326 urllib.request.urlretrieve(
327 url,
328 tmp,
329 reporthook=report,
330 )
331 tmp.rename(IB_SETUP)
332
333 ib_setup_hash = hashlib.sha256()
334 with IB_SETUP.open("rb") as fp:
335 while True:
336 data = fp.read(65_536)
337 if not data:
338 break
339 ib_setup_hash.update(data)
340 if ib_setup_hash.hexdigest() != IB_SETUP_SHA256: # pragma: no cover
341 raise RuntimeError(
342 f"InstallBuilder hashes don't match: {ib_setup_hash.hexdigest()}"
343 )
344
345 print("Install InstallBuilder...")
346 subprocess.run(
347 [IB_SETUP, "--mode", "unattended", "--unattendedmodeui", "none"], check=True

Callers

nothing calls this directly

Calls 11

PathClass · 0.85
_test_binariesFunction · 0.85
versionFunction · 0.70
encodeMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
openMethod · 0.45
updateMethod · 0.45
runMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…