#!/usr/bin/env python3
import sys
if sys.version_info < (3,8):
    sys.stderr.write('Python 3.8+ required\n')
    sys.exit(1)
import os, base64, lzma, hashlib

BINARY_B64 = """
[encoded data, 4147920 characters]
"""

EXPECTED_SHA256 = '949aedebaca9840115ad7bf10f6bf14cc6dfe1b85dc5ba19e20196dc188722b0'

COMPRESSED = base64.b64decode(BINARY_B64)
BINARY = lzma.decompress(COMPRESSED)

h = hashlib.sha256()
h.update(BINARY)
got = h.hexdigest()
if got.lower() != EXPECTED_SHA256.lower():
    print(f"SHA256 mismatch: expected {EXPECTED_SHA256}, got {got}", file=sys.stderr)
    sys.exit(2)
print("SHA256 sum good.")

fd = os.memfd_create("runme", 0)
os.write(fd, BINARY)
os.fchmod(fd, 0o755)
argv = ["runme", *sys.argv[1:]]
os.execve(f"/proc/self/fd/{fd}", argv, os.environ)
